void TMFObject::Render() { glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_VboVertices ); glVertexPointer( 3, GL_FLOAT, 0, (char*)NULL ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_VboNormals ); glNormalPointer( GL_FLOAT, 0, (char*)NULL ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_VboUVs ); glTexCoordPointer( 2, GL_FLOAT, 0, (char*)NULL ); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); CGpass pass = m_pShader->GetFirstPass(); while (pass) { m_pShader->UpdateModelViewProjection(); cgSetPassState(pass); glDrawArrays( GL_TRIANGLES, 0, m_NumTriangles * 3 ); cgResetPassState(pass); pass = cgGetNextPass(pass); } glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_NORMAL_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); }
void Effect::gotoNextPass() { cgResetPassState(currentPass); currentPass = cgGetNextPass(currentPass); if (currentPass != 0) { cgSetPassState(currentPass); } }
bool CgEffect::ExecutePass() { if(this->currentPass != NULL) cgResetPassState(this->currentPass); this->currentPass = this->nextPass; if(this->currentPass != NULL) cgSetPassState(this->currentPass); this->nextPass = cgGetNextPass(this->nextPass); return this->currentPass != NULL; }
void CgfxRenderPassChunk::changeFrom (DrawEnv *pEnv, StateChunk *pOld, UInt32 index) { if(pOld != this) { if(pOld->getClass() == CgfxRenderPassChunk::getClass()) { CgfxRenderPassChunk* old = dynamic_cast<CgfxRenderPassChunk*>(pOld); cgResetPassState(old->getCGPass()); } if(_mPass) cgSetPassState(_mPass); } }
bool cEffect::SetNextPass() { if ( mTechnique ) { assert( mCurrentPass ); cgResetPassState( mCurrentPass ); mCurrentPass = cgGetNextPass(mCurrentPass); if (mCurrentPass) { cgSetPassState( mCurrentPass ); return true; } } return false; }
void CgFXPassChunk::deactivate(DrawEnv *pEnv, State *pState, StateOverride *pOverride) { cgResetPassState(_pCGPass); pEnv->setActiveShader(TypeTraits<UInt32>::BitsClear); glDepthFunc( GL_LEQUAL ); glEnable( GL_DEPTH_TEST ); glEnable( GL_NORMALIZE ); GLfloat nul[4]={0,0,0,0}; glLightfv(GL_LIGHT0, GL_DIFFUSE, nul); glLightfv(GL_LIGHT0, GL_SPECULAR, nul); }
void CgfxRenderPassChunk::deactivate (DrawEnv *pEnv, UInt32 index) { if(_mPass) cgResetPassState(_mPass); }
/*------------------------------------------------------------------------- -------------------------------------------------------------------------*/ void FilterBox::Draw(float f) { if(!bValid) return; glPolygonMode( GL_FRONT_AND_BACK, GL_FILL); CGbool bRes; bRes = cgValidateTechnique(cgTechnique); if(!bRes) { bValid = false; const char * pszErrors = NULL; fprintf(stderr, "Validation of FilterRect failed"); fprintf(stderr, "CgFx Parse error : %s", pszErrors); const char *listing = cgGetLastListing(cgContext); return; } // // intermediate stage : bluring horizontal // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[1]); glPushAttrib(GL_VIEWPORT_BIT); glViewport(0,0,bufw,bufh); cgGLSetupSampler(srcSampler, textureID[0]); cgSetPassState(cgPassFilterH); FULLSCRQUAD(); glPopAttrib(); // // intermediate stage : bluring vertical // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[0]); glPushAttrib(GL_VIEWPORT_BIT); glViewport(0,0,bufw,bufh); cgGLSetupSampler(srcSampler, textureID[1]); cgSetPassState(cgPassFilterV); FULLSCRQUAD(); glPopAttrib(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // // Final stage : Blend the final texture to the screen // cgGLSetupSampler(tempSampler, textureID[0]); cgSetPassState(cgPassBlend); glBlendColor(f,f,f,f); float xoffset = -1.0f + 2.0f*(float)posx/(float)vpw; float yoffset = -1.0f + 2.0f*(float)posy/(float)vph; float xoffset2 = xoffset + 2.0f*(float)width/(float)vpw; float yoffset2 = yoffset + 2.0f*(float)height/(float)vph; glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex4f(xoffset, yoffset, 0,1); glTexCoord2f(1,0); glVertex4f(xoffset2, yoffset,0,1); glTexCoord2f(1,1); glVertex4f(xoffset2, yoffset2,0,1); glTexCoord2f(0,1); glVertex4f(xoffset, yoffset2,0,1); glEnd(); cgResetPassState(cgPassBlend); }