• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ identity函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中identity函数的典型用法代码示例。如果您正苦于以下问题:C++ identity函数的具体用法?C++ identity怎么用?C++ identity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了identity函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: VideoConsumer

/**
* @brief 
*
* @param provider
*/
QueuedVideoFilter::QueuedVideoFilter( AudioVideoProvider &provider ) :
    VideoConsumer( cClass(), provider, FeedLink( FEED_QUEUED, AudioVideoProvider::videoFramesOnly ) ),
    VideoProvider( cClass(), provider.name() ),
    Thread( identity() )
{
}
开发者ID:jianhongwei,项目名称:ozonebase,代码行数:11,代码来源:ozVideoFilter.cpp


示例2: identity

eMatrix3x3::eMatrix3x3()
{
    identity();
}
开发者ID:enigmastudio,项目名称:Enigma-Studio-4,代码行数:4,代码来源:matrix.cpp


示例3: errno_assert

int zmq::xrep_t::xrecv (msg_t *msg_, int flags_)
{
    //  if there is a prefetched identity, return it.
    if (prefetched == 2)
    {
        int rc = msg_->init_size (prefetched_id.size ());
        errno_assert (rc == 0);
        memcpy (msg_->data (), prefetched_id.data (), prefetched_id.size ());
        msg_->set_flags (msg_t::more);
        prefetched = 1;
        return 0;
    }

    //  If there is a prefetched message, return it.
    if (prefetched == 1) {
        int rc = msg_->move (prefetched_msg);
        errno_assert (rc == 0);
        more_in = msg_->flags () & msg_t::more ? true : false;
        prefetched = 0;
        return 0;
    }

    pipe_t *pipe = NULL;
    while (true) {

        //  Get next message part.
        int rc = fq.recvpipe (msg_, flags_, &pipe);
        if (rc != 0)
            return -1;

        //  If identity is received, change the key assigned to the pipe.
        if (likely (!(msg_->flags () & msg_t::identity)))
            break;

        zmq_assert (!more_in);

        //  Empty identity means we can preserve the auto-generated identity.
        if (msg_->size () != 0) {

            //  Actual change of the identity.
            outpipes_t::iterator it = outpipes.begin ();
            while (it != outpipes.end ()) {
                if (it->second.pipe == pipe) {
                    blob_t identity ((unsigned char*) msg_->data (),
                        msg_->size ());
                    pipe->set_identity (identity);
                    outpipes.erase (it);
                    outpipe_t outpipe = {pipe, true};
                    outpipes.insert (outpipes_t::value_type (identity,
                        outpipe));
                    break;
                }
                ++it;
            }
            zmq_assert (it != outpipes.end ());
        }
    }

    //  If we are in the middle of reading a message, just return the next part.
    if (more_in) {
        more_in = msg_->flags () & msg_t::more ? true : false;
        return 0;
    }
 
    //  We are at the beginning of a new message. Move the message part we
    //  have to the prefetched and return the ID of the peer instead.
    int rc = prefetched_msg.move (*msg_);
    errno_assert (rc == 0);
    prefetched = 1;
    rc = msg_->close ();
    errno_assert (rc == 0);

    blob_t identity = pipe->get_identity ();
    rc = msg_->init_size (identity.size ());
    errno_assert (rc == 0);
    memcpy (msg_->data (), identity.data (), identity.size ());
    msg_->set_flags (msg_t::more);
    return 0;
}
开发者ID:Shajon,项目名称:libzmq,代码行数:79,代码来源:xrep.cpp


示例4: gfx_step

int gfx_step(  uint32_t *fifo,  uint32_t jmp, int off )
{

	static bool init_particles = false;
	
	if( !init_particles )
	{
	    init_particles = true;
	    
	    for( size_t i = 0; i < INUMBER; ++i )
	    {
		dt[i] = ( rand() & 63 ) + 32;
		rnds[i][0] = 360.0f * i / (float)( INUMBER );//rnd( 0.0f, 360.0f );
		rnds[i][1] = rnd( -0.2f, +0.2f );
		rnds[i][2] = rnd( -0.8f, +0.3f );
		rnds[i][3] = rnd( 0.3f, 1.0f );
		
		
		insts[i].time 	= rand();
		insts[i].col[0] = rnd( 0.8f, 1.0f );
		insts[i].col[1] = rnd( 0.8f, 1.0f );
		insts[i].col[2] = rnd( 0.8f, 1.0f );
		insts[i].col[3] = 1.0f;				
	    }
	}
	
	
	for( size_t i = 0; i < INUMBER; ++i )
	{
	    insts[i].time += dt[i];
	    identity( insts[i].mat );
	
	    rotatef( 80.0f, 1.0f, 0.0f, 0.0f, insts[i].mat );
	    rotatef( off * 0.5f + rnds[i][0], 0.0f, 0.0f, 1.0f, insts[i].mat );
	    translatef( 1.6f, rnds[i][1], rnds[i][2], insts[i].mat );
	    scalef( rnds[i][3], insts[i].mat );
	    
	    float d = insts[i].mat[11];
	    
	    d = ( 1.0f - 0.6f * d );
	    insts[i].scale = rnds[i][3];
	    insts[i].col[0] = d;
	    insts[i].col[1] = 0.5f + d;
	    insts[i].col[2] = d;
	    
	    //translatef( 1.0f * sin( t * rnds[i][0] ), 1.0f * cos( t * rnds[i][0] ), 1.0f * sin( t * rnds[i][2] ), insts[i].mat );
	}
	
	
	
	clear_buffer_t clear;
	clear.clearR = clear.clearG = clear.clearB = clear.clearA = clear.clearD = 1;
	clear.rgba = 50 + ( 10 << 8 ) + ( 5 << 16 );
	clear.depth = 0xffff;

	static job_t job;
	
	static size_t curr = 0x0;

	job.pd.insts = (uint32_t)insts;
	job.pd.isize = INUMBER;
	job.pd.dynamic = (uint32_t)( dynamic ) + curr * 24;
	job.pd.fx = (uint32_t)fx.get_data();
	job.pd.atlas = (uint32_t)atlas.get_data();
	job.pd.asize = atlas.get_size();
	job.kick_job( );
	job.join();

	
	uint32_t *ptr = fifo;
	static float angle = 180.0f;
	ptr += setup_surfaces_with_offset( ptr, off % 3 );
	ptr += clear_buffers( &clear, ptr, Nv3D );
	
	ptr += set_mvp( ptr, angle );
	ptr += set_cnst( ptr );
	//ptr += troll_texture.set( ptr );
	//ptr += troll.set( ptr );
	
	//ptr += custom.set( ptr );
	ptr += particles.set( ptr );
	ptr += particle_texture.set( ptr );
	
	ptr += draw_primitives( 0, QUADS, curr, job.pd.quads * 4, ptr, Nv3D );
	
	curr += job.pd.quads * 4;// + 128;
	curr = ( curr + 16 ) & 2047;
	
	//printf( "%d \n", job.pd.quads );
	ptr += jump_to_address( ptr, jmp );
	return ptr - fifo;
}
开发者ID:joshdekock,项目名称:jim-ps3ware,代码行数:92,代码来源:ps3gpu.cpp


示例5: translation

void translation(double tx, double ty, LTransform m)
{
    identity(m);
    m[2][0] = tx;
    m[2][1] = ty;
}
开发者ID:csilles,项目名称:cxxr,代码行数:6,代码来源:matrix.c


示例6: invert

GLboolean
invert(GLdouble src[16], GLdouble inverse[16])
{
    double t;
    int i, j, k, swap;
    GLdouble tmp[4][4];
    
    identity(inverse);
    
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 4; j++) {
            tmp[i][j] = src[i*4+j];
        }
    }
    
    for (i = 0; i < 4; i++) {
        /* look for largest element in column. */
        swap = i;
        for (j = i + 1; j < 4; j++) {
            if (fabs(tmp[j][i]) > fabs(tmp[i][i])) {
                swap = j;
            }
        }
        
        if (swap != i) {
            /* swap rows. */
            for (k = 0; k < 4; k++) {
                t = tmp[i][k];
                tmp[i][k] = tmp[swap][k];
                tmp[swap][k] = t;
                
                t = inverse[i*4+k];
                inverse[i*4+k] = inverse[swap*4+k];
                inverse[swap*4+k] = t;
            }
        }
        
        if (tmp[i][i] == 0) {
        /* no non-zero pivot.  the matrix is singular, which
        shouldn't happen.  This means the user gave us a bad
            matrix. */
            return GL_FALSE;
        }
        
        t = tmp[i][i];
        for (k = 0; k < 4; k++) {
            tmp[i][k] /= t;
            inverse[i*4+k] /= t;
        }
        for (j = 0; j < 4; j++) {
            if (j != i) {
                t = tmp[j][i];
                for (k = 0; k < 4; k++) {
                    tmp[j][k] -= tmp[i][k]*t;
                    inverse[j*4+k] -= inverse[i*4+k]*t;
                }
            }
        }
    }
    return GL_TRUE;
}
开发者ID:OpenGL-IFG,项目名称:OpenGL,代码行数:61,代码来源:transformation.c


示例7: identity

Matrix3::Matrix3()
{
    identity();
}
开发者ID:AiEra,项目名称:JungleIN,代码行数:4,代码来源:matrix3.cpp


示例8: GetDiagonal

void GetDiagonal( const Matrix<T>& A, Matrix<T>& d, Int offset )
{
    DEBUG_ONLY(CSE cse("GetDiagonal"))
    function<T(T)> identity( []( T alpha ) { return alpha; } ); 
    GetMappedDiagonal( A, d, identity, offset );
}
开发者ID:restrin,项目名称:Elemental,代码行数:6,代码来源:GetDiagonal.hpp


示例9: identity

///////////////////////////////////////////////////////////////////////////
// inline functions for Mat2
///////////////////////////////////////////////////////////////////////////
inline Mat2::Mat2()
{
    // initially identity matrix
    identity();
}
开发者ID:sogimu,项目名称:glRender,代码行数:8,代码来源:mat2.hpp


示例10: identity

etk::Matrix2::Matrix2() {
	// TODO: Remove this ...
	identity();
}
开发者ID:atria-soft,项目名称:etk,代码行数:4,代码来源:Matrix2.cpp


示例11: metric

      virtual double metric(stk::mesh::Entity& element, bool& valid)
      {
        valid = true;
        JacobianUtil jacA, jacW;

        int spatialDim = m_eMesh->get_spatial_dim();
        double A_ = 0.0, W_ = 0.0; // current and reference detJ
        jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data);
        jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data);
        double val=0.0, val_shape=0.0;
        MsqMatrix<3,3> Ident; 
        identity(Ident);

        MsqMatrix<3,3> WI, T;

        for (int i=0; i < jacA.m_num_nodes; i++)
          {
            double detAi = jacA.m_detJ[i];
            if (detAi < 0)
              {
                valid = false;
              }
            MsqMatrix<3,3>& W = jacW.m_J[i];
            MsqMatrix<3,3>& A = jacA.m_J[i];

            // frob2 = h^2 + h^2 + 1
            // frob21 = 2 h^2
            // f = h sqrt(2)
            // det = h*h
            // met = f*f / (det*2) - 1
            // frob3 = 3 h^2
            // f = h sqrt(3)
            // det = h*h*h
            // met = f*f*f/(3^3/2 *det) - 1 = f*f*f/(3*sqrt(3)*det) - 1
            double shape_metric = 0.0;
            if (std::fabs(detAi) > 1.e-15)
              {
                inverse(W, WI);
                product(A, WI, T);
                double d = det(T);
                double f = my_sqr_Frobenius(T);
                if (spatialDim==2)
                  {
                    // all our jacobians are 3D, with a 1 in the 3,3 slot for 2d, so we subtract it here
                    f = f - 1.0;
                    f = std::sqrt(f);
                    double fac = 2.0;
                    double den = fac * d;
                    shape_metric = (f*f)/den - 1.0;
                  }
                else
                  {
                    f = std::sqrt(f);
                    double fac = 3.0*std::sqrt(3.0);
                    double den = fac * d;
                    shape_metric = (f*f*f)/den - 1.0;
                  }
                //shape_metric = std::fabs(shape_metric);
                //shape_metric = f/std::pow(den,1./3.) - 1.0;
              }
            val_shape += shape_metric;
            //val_shape += std::fabs(shape_metric);
            //val_shape += shape_metric*shape_metric;
          }
        val = val_shape;
        //val = val_shape*val_shape;
        return val;
      }
开发者ID:gitter-badger,项目名称:quinoa,代码行数:68,代码来源:PMMSmootherMetric.hpp


示例12: Verificator

 Verificator()
 {
   Name identity(IDENTITY_NAME);
   Name keyName = m_keyChain.getDefaultKeyNameForIdentity(identity);
   m_publicKey = m_keyChain.getPublicKey(keyName); 
 };
开发者ID:jdlee6461,项目名称:Consumer-Producer-API,代码行数:6,代码来源:rdr-exclude-consumer.cpp


示例13: zmq_assert

int zmq::xrep_t::xsend (zmq_msg_t *msg_, int flags_)
{
    //  If this is the first part of the message it's the identity of the
    //  peer to send the message to.
    if (!more_out) {
        zmq_assert (!current_out);

        //  If we have malformed message (prefix with no subsequent message)
        //  then just silently ignore it.
        if (msg_->flags & ZMQ_MSG_MORE) {

            more_out = true;

            //  Find the pipe associated with the identity stored in the prefix.
            //  If there's no such pipe just silently ignore the message.
            blob_t identity ((unsigned char*) zmq_msg_data (msg_),
                zmq_msg_size (msg_));
            outpipes_t::iterator it = outpipes.find (identity);

            if (it != outpipes.end ()) {
                current_out = it->second.writer;
                zmq_msg_t empty;
                int rc = zmq_msg_init (&empty);
                zmq_assert (rc == 0);
                if (!current_out->check_write (&empty)) {
                    it->second.active = false;
                    more_out = false;
                    current_out = NULL;
                }
                rc = zmq_msg_close (&empty);
                zmq_assert (rc == 0);
            }
        }

        int rc = zmq_msg_close (msg_);
        zmq_assert (rc == 0);
        rc = zmq_msg_init (msg_);
        zmq_assert (rc == 0);
        return 0;
    }

    //  Check whether this is the last part of the message.
    more_out = msg_->flags & ZMQ_MSG_MORE;

    //  Push the message into the pipe. If there's no out pipe, just drop it.
    if (current_out) {
        bool ok = current_out->write (msg_);
        zmq_assert (ok);
        if (!more_out) {
            current_out->flush ();
            current_out = NULL;
        }
    }
    else {
        int rc = zmq_msg_close (msg_);
        zmq_assert (rc == 0);
    }
    //  Detach the message from the data buffer.
    int rc = zmq_msg_init (msg_);
    zmq_assert (rc == 0);

    return 0;
}
开发者ID:roeyaus,项目名称:adHear,代码行数:63,代码来源:xrep.cpp


示例14: identity

bool PlayPG::doLogin() {
	const auto logger = el::Loggers::getLogger("PlayPG");
	if (!socket.isConnected()) {
		socket.connect();

		if (socket.hasError()) {
			return false;
		}

		if (!socket.waitForActivity(2000)) {
			logger->error("Server didn't respond in time.");
			return false;
		}

		int read = socket.recv();

		const auto opcode = socket.getShort();

		logger->info("Got %v bytes, opcode %v.", read, opcode);

		if (opcode != static_cast<opcode_type_t>(ServerOpcode::LOGIN_AUTHENTICATION_CHALLENGE)) {
			logger->info("Got opcode %v which doesn't match the expected value. Ignoring.");
			socket.clear();
			return false;
		}

		const uint16_t jsonSize = socket.getShort();

		auto json = socket.getStringByLength(jsonSize);

//		logger->info("JSON: %v", json);

		APG::JSONSerializer<AuthenticationChallenge> challengeS11N;
		const auto challenge = challengeS11N.fromJSON(json.c_str());

		logger->info("Got challenge from \"%v\", v%v (%v).", challenge.name, challenge.version, challenge.versionHash);
//		logger->info("Got pubkey: %v", challenge.pubKey);

		serverPubKey = challenge.pubKey;

		crypto = std::make_unique<RSACrypto>(serverPubKey, true);

		socket.clear();

		if (std::strcmp(challenge.version.c_str(), Version::versionString) != 0
		        || std::strcmp(challenge.versionHash.c_str(), Version::gitHash) != 0) {
			logger->info("Version check failed.");

			VersionMismatch mismatchPacket;

			socket.put(&mismatchPacket.buffer);
			socket.send();

			return false;
		}

		logger->info("Version check successful.");
	} else {
		socket.clear();
	}

	const auto encPass = crypto->encryptStringPublic("testa");
	logger->info("Sending %v byte password", encPass.size());

	AuthenticationIdentity identity(username, encPass);

	socket.put(&identity.buffer);
	const auto sentAuthDetailBytes = socket.send();
	logger->info("Sent %v auth detail bytes, opcode %v.", sentAuthDetailBytes, (opcode_type_t) identity.opcode);

	socket.clear();

	socket.waitForActivity(2000);

	socket.recv();

	const auto respOpcode = socket.getShort();

	if (respOpcode != static_cast<opcode_type_t>(ServerOpcode::LOGIN_AUTHENTICATION_RESPONSE)) {
		return false;
	}

	const auto respSize = socket.getShort();
	const auto respJSON = socket.getStringByLength(respSize);
	logger->info("Got authentication response: %v", respJSON);

	APG::JSONSerializer<AuthenticationResponse> responseS11N;
	const auto response = responseS11N.fromJSON(respJSON.c_str());

	if (!response.successful) {
		logger->info("Authentication failed with username %v: %v", username, response.message);

		if (response.attemptsRemaining == 0) {
			socket.disconnect();
		}

		return false;
	}

	return true;
//.........这里部分代码省略.........
开发者ID:SgtCoDFish,项目名称:PlayPG,代码行数:101,代码来源:PlayPG.cpp


示例15: regionNames_

// Construct with length.
Foam::searchableSurfaces::searchableSurfaces(const label size)
    :
    PtrList<searchableSurface>(size),
    regionNames_(size),
    allSurfaces_(identity(size))
{}
开发者ID:degirmen,项目名称:openfoam-extend-OpenFOAM-1.6-ext,代码行数:7,代码来源:searchableSurfaces.C


示例16: makeProgram

static void makeProgram( RenderData *renderData) {

    GLint ok;

    const char *vertexShader =  "attribute vec3 position;\n"
                                "attribute vec2 texCoord0;\n"
                                "varying vec2 v_texCoord0;\n"
                                "varying float dist;\n"
                                "uniform mat4 modelView;\n"
                                "uniform mat4 projection;\n"
                                "void main(void)\n"
                                "{\n"
                                "    vec4 p = modelView*vec4(position,1.0);\n"
                                "    gl_Position = projection*p;\n"
                                "    v_texCoord0 = texCoord0;\n"
                                "    dist = gl_Position.z*0.1;\n"
                                "}\n";


    const char *fragmentShader =
                                //"precision mediump float;\n"
                                "varying vec2 v_texCoord0;\n"
                                "varying float dist;\n"
                                "uniform sampler2D texUnit0;\n"
                                "uniform float alpha;\n"
                                "uniform float imgAlpha;\n"
                                "uniform vec4 color;\n"
                                "void main()\n"
                                "{\n"
                                "    vec4 txt = texture2D(texUnit0, v_texCoord0)*imgAlpha;\n"
                                "    gl_FragColor =vec4(1.0,1.0,1.0,1.0)*(1.0-dist);\n"
                                "    gl_FragColor.a =1.0;\n"
                                "}\n";



    GLuint vs = glCreateShader(GL_VERTEX_SHADER);
    
    glShaderSource(vs, 1, &vertexShader, NULL);
    glCompileShader(vs);
    glGetShaderiv(vs, GL_COMPILE_STATUS, &ok);
    
    assert(ok);

    GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
    
    glShaderSource(fs, 1, &fragmentShader, NULL);
    glCompileShader(fs);
    glGetShaderiv(fs, GL_COMPILE_STATUS, &ok);


    assert(ok);

    GLuint program = glCreateProgram();
    renderData->program = program;
    
    glAttachShader(program, vs);
    glAttachShader(program, fs);
    glLinkProgram(program);
    glGetProgramiv(program, GL_LINK_STATUS, &ok);
    assert(ok);

    glUseProgram(program);

    identity(renderData->model);
    translate2(renderData->model,-0.2, 0.2, -50.6);

    perspective(renderData->model_view_projection, 90.0, WIDTH/HEIGHT, 1.0, 500.0);

    renderData->mvLocation = glGetUniformLocation(program, "modelView");
    glUniformMatrix4fv(renderData->mvLocation, 1, GL_FALSE, renderData->model); 

    GLint projectionLocation = glGetUniformLocation(program, "projection");
    glUniformMatrix4fv(projectionLocation, 1, GL_FALSE, renderData->model_view_projection); 

    GLint texLocation = glGetUniformLocation(program, "texUnit0");
    glUniform1i(texLocation, 0);

    GLint alphaLocation = glGetUniformLocation(program, "alpha");
    glUniform1f(alphaLocation, 1.0);

    GLint imgAlphaLocation = glGetUniformLocation(program, "imgAlpha");
    glUniform1f(imgAlphaLocation, 1.0);

    GLint colorLocation = glGetUniformLocation(program, "color");
    

    renderData->texCoordLocation = glGetAttribLocation(program, "texCoord0");
    renderData->positionLocation = glGetAttribLocation(program, "position");
    renderData->alphaLocation = alphaLocation;
    renderData->imgAlphaLocation = imgAlphaLocation;
    renderData->colorLocation = colorLocation;

    GLfloat vVertices[] = {1.0, -1.0, 0.0,
                            0.0, -1.0, 0.0,
                           1.0,  0.0, 0.0,
                            0.0,  0.0, 0.0};

    GLfloat vTexCoord[] = {1.0, 1.0,
                           0.0, 1.0,
//.........这里部分代码省略.........
开发者ID:abustin,项目名称:BroCode,代码行数:101,代码来源:app1.c


示例17: identity

Matrix::Matrix()
{
	identity();
}
开发者ID:WilsonLiCode,项目名称:GamePro,代码行数:4,代码来源:Matrix.cpp


示例18: identity

Quat::Quat()
{
 identity();
}
开发者ID:cloudstrifegit,项目名称:XkLib,代码行数:4,代码来源:XkQuat.cpp


示例19: fc

void Foam::meshRefinement::findNearest
(
    const labelList& meshFaces,
    List<pointIndexHit>& nearestInfo,
    labelList& nearestSurface,
    labelList& nearestRegion,
    vectorField& nearestNormal
) const
{
    pointField fc(meshFaces.size());
    forAll(meshFaces, i)
    {
        fc[i] = mesh_.faceCentres()[meshFaces[i]];
    }

    const labelList allSurfaces(identity(surfaces_.surfaces().size()));

    surfaces_.findNearest
    (
        allSurfaces,
        fc,
        scalarField(fc.size(), sqr(GREAT)),    // sqr of attraction
        nearestSurface,
        nearestInfo
    );

    // Do normal testing per surface.
    nearestNormal.setSize(nearestInfo.size());
    nearestRegion.setSize(nearestInfo.size());

    forAll(allSurfaces, surfI)
    {
        DynamicList<pointIndexHit> localHits;

        forAll(nearestSurface, i)
        {
            if (nearestSurface[i] == surfI)
            {
                localHits.append(nearestInfo[i]);
            }
        }

        label geomI = surfaces_.surfaces()[surfI];

        pointField localNormals;
        surfaces_.geometry()[geomI].getNormal(localHits, localNormals);

        labelList localRegion;
        surfaces_.geometry()[geomI].getRegion(localHits, localRegion);

        label localI = 0;
        forAll(nearestSurface, i)
        {
            if (nearestSurface[i] == surfI)
            {
                nearestNormal[i] = localNormals[localI];
                nearestRegion[i] = localRegion[localI];
                localI++;
            }
        }
    }
开发者ID:WensiWu,项目名称:openfoam-extend-foam-extend-3.1,代码行数:61,代码来源:meshRefinementProblemCells.C


示例20: display

//------------------------------------------------------------------------------
static void
display() {

    // set effect
    g_effect.displayStyle = g_displayStyle;
    g_effect.screenSpaceTess = (g_screenSpaceTess != 0);
    g_effect.displayPatchColor = (g_displayPatchColor != 0);

    // prepare view matrix
    float aspect = g_width/(float)g_height;
    float modelview[16], projection[16];
    identity(modelview);
    translate(modelview, -g_pan[0], -g_pan[1], -g_dolly);
    rotate(modelview, g_rotate[1], 1, 0, 0);
    rotate(modelview, g_rotate[0], 0, 1, 0);
    rotate(modelview, -90, 1, 0, 0);
    translate(modelview, -g_center[0], -g_center[1], -g_center[2]);
    perspective(projection, 45.0f, aspect, 0.01f, 500.0f);

    g_effect.SetMatrix(modelview, projection);
    g_effect.SetTessLevel((float)(1 << g_tessLevel));
    g_effect.SetLighting();

    // -----------------------------------------------------------------------
    // prepare draw items

    Stopwatch s;
    s.Start();

    OpenSubdiv::OsdUtilDrawItem<MyDrawDelegate::EffectHandle, MyDrawContext>::Collection items;
    OpenSubdiv::OsdUtilDrawItem<MyDrawDelegate::EffectHandle, MyDrawContext>::Collection cachedDrawItems;

    int numModels = g_modelCount*g_modelCount;
    items.reserve(numModels);

    for (int i = 0; i < numModels; ++i) {
        // Here, client can pack arbitrary mesh and effect into drawItems.

        items.push_back(OpenSubdiv::OsdUtilDrawItem<MyDrawDelegate::EffectHandle, MyDrawContext>(
                            g_batch, &g_effect, g_batch->GetPatchArrays(i)));
    }

    if (g_batching) {
        // create cached draw items
        OpenSubdiv::OsdUtil::OptimizeDrawItem(items, cachedDrawItems, &g_drawDelegate);
    }

    s.Stop();
    float prepCpuTime = float(s.GetElapsed() * 1000.0f);

    // -----------------------------------------------------------------------
    // draw items
    s.Start();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glViewport(0, 0, g_width, g_height);

    // primitive counting
    glBeginQuery(GL_PRIMITIVES_GENERATED, g_queries[0]);
#if defined(GL_VERSION_3_3)
    glBeginQuery(GL_TIME_ELAPSED, g_queries[1]);
#endif
    g_drawDelegate.ResetNumDrawCalls();

    if (g_displayStyle == kWire) glDisable(GL_CULL_FACE);

    if (g_batching) {
        OpenSubdiv::OsdUtil::DrawCollection(cachedDrawItems, &g_drawDelegate);
    } else {
        OpenSubdiv::OsdUtil::DrawCollection(items, &g_drawDelegate);
    }

    if (g_displayStyle == kWire) glEnable(GL_CULL_FACE);

    glEndQuery(GL_PRIMITIVES_GENERATED);
#if defined(GL_VERSION_3_3)
    glEndQuery(GL_TIME_ELAPSED);
#endif

    s.Stop();
    float drawCpuTime = float(s.GetElapsed() * 1000.0f);

    // -----------------------------------------------------------------------

    GLuint numPrimsGenerated = 0;
    GLuint timeElapsed = 0;
    glGetQueryObjectuiv(g_queries[0], GL_QUERY_RESULT, &numPrimsGenerated);
#if defined(GL_VERSION_3_3)
    glGetQueryObjectuiv(g_queries[1], GL_QUERY_RESULT, &timeElapsed);
#endif
    float drawGpuTime = timeElapsed / 1000.0f / 1000.0f;

    if (g_hud.IsVisible()) {
        g_fpsTimer.Stop();
        g_totalTime += g_fpsTimer.GetElapsed();
        double fps = 1.0/g_fpsTimer.GetElapsed();
        g_fpsTimer.Start();
        g_hud.DrawString(10, -200, "Draw Calls : %d", g_drawDelegate.GetNumDrawCalls());
        g_hud.DrawString(10, -180, "Tess level : %d", g_tessLevel);
//.........这里部分代码省略.........
开发者ID:EweEwe,项目名称:OpenSubdiv,代码行数:101,代码来源:viewer.cpp



注:本文中的identity函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ identity_context函数代码示例发布时间:2022-05-30
下一篇:
C++ identify函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap