void LLDrawPoolMaterials::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures) { applyModelMatrix(params); bool tex_setup = false; if (batch_textures && params.mTextureList.size() > 1) { for (U32 i = 0; i < params.mTextureList.size(); ++i) { if (params.mTextureList[i].notNull()) { gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE); } } } else { //not batching textures or batch has only 1 texture -- might need a texture matrix if (params.mTextureMatrix) { //if (mShiny) { gGL.getTexUnit(0)->activate(); gGL.matrixMode(LLRender::MM_TEXTURE); } gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix); gPipeline.mTextureMatrixOps++; tex_setup = true; } if (mVertexShaderLevel > 1 && texture) { if (params.mTexture.notNull()) { gGL.getTexUnit(diffuse_channel)->bind(params.mTexture); params.mTexture->addTextureStats(params.mVSize); } else { gGL.getTexUnit(diffuse_channel)->unbind(LLTexUnit::TT_TEXTURE); } } } if (params.mGroup) { params.mGroup->rebuildMesh(); } params.mVertexBuffer->setBuffer(mask); params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); if (tex_setup) { gGL.getTexUnit(0)->activate(); gGL.loadIdentity(); gGL.matrixMode(LLRender::MM_MODELVIEW); } }
/** The rendering routine, a.k.a., glutDisplayFunc() */ void eqHello::Renderer::draw( co::Object* frameData ) { applyRenderContext(); // set up OpenGL State const float lightPos[] = { 0.0f, 0.0f, 1.0f, 0.0f }; glLightfv( GL_LIGHT0, GL_POSITION, lightPos ); const float lightAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f }; glLightfv( GL_LIGHT0, GL_AMBIENT, lightAmbient ); applyModelMatrix(); // global camera // render six axis-aligned colored quads around the origin for( int i = 0; i < 6; i++ ) { glColor3f( (i&1) ? 0.5f:1.0f, (i&2) ? 1.0f:0.5f, (i&4) ? 1.0f:0.5f ); glNormal3f( 0.0f, 0.0f, 1.0f ); glBegin( GL_TRIANGLE_STRIP ); glVertex3f( .7f, .7f, -1.0f ); glVertex3f( -.7f, .7f, -1.0f ); glVertex3f( .7f, -.7f, -1.0f ); glVertex3f( -.7f, -.7f, -1.0f ); glEnd(); if( i < 3 ) glRotatef( 90.0f, 0.0f, 1.0f, 0.0f ); else if( i == 3 ) glRotatef( 90.0f, 1.0f, 0.0f, 0.0f ); else glRotatef( 180.0f, 1.0f, 0.0f, 0.0f ); } }
void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE) { LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; applyModelMatrix(params); params.mVertexBuffer->setBuffer(mask); params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); } }
void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) { applyModelMatrix(params); if (texture) { if (params.mTexture.notNull()) { params.mTexture->addTextureStats(params.mVSize); gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ; if (params.mTextureMatrix) { glMatrixMode(GL_TEXTURE); glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); gPipeline.mTextureMatrixOps++; } } else { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } if (params.mVertexBuffer.notNull()) { if (params.mGroup) { params.mGroup->rebuildMesh(); } params.mVertexBuffer->setBuffer(mask); params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); gPipeline.addTrianglesDrawn(params.mCount/3); } if (params.mTextureMatrix && texture && params.mTexture.notNull()) { glLoadIdentity(); glMatrixMode(GL_MODELVIEW); } }
void Renderer::draw( co::Object* frameDataObj ) { EQASSERT( _state ); const FrameData* frameData = static_cast< FrameData* >( frameDataObj ); Application& application = static_cast< Application& >( getApplication( )); const eq::uint128_t id = frameData->getModelID(); const Model* model = application.getModel( id ); if( !model ) return; applyRenderContext(); glLightfv( GL_LIGHT0, GL_POSITION, lightPosition ); glLightfv( GL_LIGHT0, GL_AMBIENT, lightAmbient ); glLightfv( GL_LIGHT0, GL_DIFFUSE, lightDiffuse ); glLightfv( GL_LIGHT0, GL_SPECULAR, lightSpecular ); glMaterialfv( GL_FRONT, GL_AMBIENT, materialAmbient ); glMaterialfv( GL_FRONT, GL_DIFFUSE, materialDiffuse ); glMaterialfv( GL_FRONT, GL_SPECULAR, materialSpecular ); glMateriali( GL_FRONT, GL_SHININESS, materialShininess ); applyModelMatrix(); glColor3f( .75f, .75f, .75f ); // Compute cull matrix const eq::Matrix4f& modelM = getModelMatrix(); const eq::Matrix4f& view = getViewMatrix(); const eq::Frustumf& frustum = getFrustum(); const eq::Matrix4f projection = frustum.compute_matrix(); const eq::Matrix4f pmv = projection * view * modelM; _state->setProjectionModelViewMatrix( pmv ); //_state->setRange( &getRange().start); _state->setColors( model->hasColors( )); model->cullDraw( *_state ); }