void BasicDemo::renderme() { renderscene(0); if(gbDrawBatches) { ((btGpuDemoDynamicsWorld*)m_dynamicsWorld)->debugDrawConstraints(gSelectedBatch, cBatchColorTab); } // if (0) if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0) { setOrthographicProjection(); int xOffset = 10.f; int yStart = 20.f; int yIncr = 20.f; showProfileInfo(xOffset, yStart, yIncr); DrawConstraintInfo(); outputDebugInfo(xOffset, yStart, yIncr); resetPerspectiveProjection(); } }
void BasicDemo3D::renderme() { updateCamera(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(gDrawWire) { glColor3f(1.f, 1.f, 1.f); glDisable(GL_LIGHTING); setTexturing(false); } else { myinit(); setTexturing(true); } renderscene(0); if(gbDrawBatches) { ((btCudaDemoDynamicsWorld3D*)m_dynamicsWorld)->debugDrawConstraints(gSelectedBatch, cBatchColorTab); } glColor3f(0, 0, 0); if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0) { setOrthographicProjection(); int xOffset = 10.f; int yStart = 20.f; int yIncr = 20.f; showProfileInfo(xOffset, yStart, yIncr); DrawConstraintInfo(); outputDebugInfo(xOffset, yStart, yIncr); resetPerspectiveProjection(); } }
void rt_renderscene(SceneHandle voidscene) { scenedef * scene = (scenedef *) voidscene; renderscene(*scene); }
void DemoApplication::renderme() { myinit(); updateCamera(); if (m_dynamicsWorld) { if(m_enableshadows) { glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_CULL_FACE); renderscene(0); glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); glDepthFunc(GL_LEQUAL); glEnable(GL_STENCIL_TEST); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL); glFrontFace(GL_CCW); glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); renderscene(1); glFrontFace(GL_CW); glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); renderscene(1); glFrontFace(GL_CCW); glPolygonMode(GL_FRONT,GL_FILL); glPolygonMode(GL_BACK,GL_FILL); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_LIGHTING); glDepthMask(GL_TRUE); glCullFace(GL_BACK); glFrontFace(GL_CCW); glEnable(GL_CULL_FACE); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glDepthFunc(GL_LEQUAL); glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL ); glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); glDisable(GL_LIGHTING); renderscene(2); glEnable(GL_LIGHTING); glDepthFunc(GL_LESS); glDisable(GL_STENCIL_TEST); glDisable(GL_CULL_FACE); } else { glDisable(GL_CULL_FACE); renderscene(0); } int xOffset = 10; int yStart = 20; int yIncr = 20; glDisable(GL_LIGHTING); glColor3f(0, 0, 0); if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0) { setOrthographicProjection(); showProfileInfo(xOffset,yStart,yIncr); #ifdef USE_QUICKPROF if ( getDebugMode() & btIDebugDraw::DBG_ProfileTimings) { static int counter = 0; counter++; std::map<std::string, hidden::ProfileBlock*>::iterator iter; for (iter = btProfiler::mProfileBlocks.begin(); iter != btProfiler::mProfileBlocks.end(); ++iter) { char blockTime[128]; sprintf(blockTime, "%s: %lf",&((*iter).first[0]),btProfiler::getBlockTime((*iter).first, btProfiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT)); glRasterPos3f(xOffset,yStart,0); GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),blockTime); yStart += yIncr; } } #endif //USE_QUICKPROF resetPerspectiveProjection(); } glEnable(GL_LIGHTING); } updateCamera(); }
void KeplerBtDynamics::draw() { GLfloat light_ambient[] = { btScalar(0.2), btScalar(0.2), btScalar(0.2), btScalar(1.0) }; GLfloat light_diffuse[] = { btScalar(1.0), btScalar(1.0), btScalar(1.0), btScalar(1.0) }; GLfloat light_specular[] = { btScalar(1.0), btScalar(1.0), btScalar(1.0), btScalar(1.0 )}; /* light_position is NOT default value */ GLfloat light_position0[] = { btScalar(1.0), btScalar(10.0), btScalar(1.0), btScalar(0.0 )}; GLfloat light_position1[] = { btScalar(-1.0), btScalar(-10.0), btScalar(-1.0), btScalar(0.0) }; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT0, GL_POSITION, light_position0); glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT1, GL_POSITION, light_position1); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); if (m_dynamicsWorld) { glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_CULL_FACE); renderscene(0); glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); glDepthFunc(GL_LEQUAL); glEnable(GL_STENCIL_TEST); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL); glFrontFace(GL_CCW); glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); renderscene(1); glFrontFace(GL_CW); glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); renderscene(1); glFrontFace(GL_CCW); glPolygonMode(GL_FRONT,GL_FILL); glPolygonMode(GL_BACK,GL_FILL); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_LIGHTING); glDepthMask(GL_TRUE); glCullFace(GL_BACK); glFrontFace(GL_CCW); glEnable(GL_CULL_FACE); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glDepthFunc(GL_LEQUAL); glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL ); glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); glDisable(GL_LIGHTING); renderscene(2); glEnable(GL_LIGHTING); glDepthFunc(GL_LESS); glDisable(GL_STENCIL_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); } }
void drawevent(event *e, float t) { glPushAttrib(GL_ALL_ATTRIB_BITS); float x1,y1,x2,y2; x1=(float)floor(linear((float)e->startrectx1,(float)e->endrectx1,t)); y1=(float)floor(linear((float)e->startrecty1,(float)e->endrecty1,t)); if (xres==320) y1+=0.5; if (xres==1024) y1+=1; x2=(float)floor(linear((float)e->startrectx2,(float)e->endrectx2,t))+1; y2=(float)floor(linear((float)e->startrecty2,(float)e->endrecty2,t))+1; if (e->eventtype==layer2d) { glDepthMask(false); glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glColor4f(linear(e->startcol[0],e->endcol[0],t),linear(e->startcol[1],e->endcol[1],t),linear(e->startcol[2],e->endcol[2],t),linear(e->startcol[3],e->endcol[3],t)); glEnable(GL_BLEND); glBlendFunc(e->blendfunc1,e->blendfunc2); if (e->textured) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,e->mattexture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(x1,y1-1); glTexCoord2f(0,1); glVertex2f(x2,y1-1); glTexCoord2f(1,1); glVertex2f(x2,y2+1); glTexCoord2f(1,0); glVertex2f(x1,y2+1); glEnd(); } else { glDisable(GL_TEXTURE_2D); quad(x1,y1,x2,y2); } } if (e->eventtype==layer3d) { float animtimer=linear((float)e->animstart,(float)e->animend,t); scene *pf = e->iscene; camera *cam=e->icam; if (calculatehierarchy[pf->number]) { getscenestate(pf,animtimer,e->ianim); calculateobjhierarchy(pf,-1,NULL); } float f=linear((float)e->camstart,(float)e->camend,t); cam->eye.x=cam->eyex->GetKey(f); cam->eye.y=cam->eyey->GetKey(f); cam->eye.z=cam->eyez->GetKey(f); cam->target.x=cam->trgx->GetKey(f); cam->target.y=cam->trgy->GetKey(f); cam->target.z=cam->trgz->GetKey(f); cam->fov=cam->fovt->GetKey(f); cam->roll=cam->rollt->GetKey(f); glLoadIdentity(); if (!cam->eyex || (cam->eyex && cam->eyex->numkey==0) ) cam=lastcam; setcameraview(*cam,(float)(x2-x1)/(float)(y2-y1)); lastcam=cam; glViewport((int)(x1*(float)xres/640.0),(int)(yres-y2*(float)yres/480.0),(int)((x2-x1)*(float)xres/640.0),(int)((y2-y1)*(float)yres/480.0)); glEnable(GL_BLEND); glEnable(GL_LIGHTING); renderscene(pf); //switchto2d(); } if (e->eventtype==cleargl) { if (e->clearzbuffer && !e->clearscreen) glClear(0x100); if (!e->clearzbuffer && e->clearscreen) glClear(0x4000); if (e->clearzbuffer && e->clearscreen) glClear(0x4100); } if (e->eventtype==rendertotext) { glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,shots[e->texture].texture); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,(int)(x1*(float)xres/640.0),(int)(yres-y2*(float)yres/480.0), 1024, 1024,0); shots[e->texture].x1=0; shots[e->texture].y1=(y2-y1)*(float)xres/640.0f/1024.0f; shots[e->texture].x2=(x2-x1)*(float)yres/480.0f/1024.0f; shots[e->texture].y2=0; } if (e->eventtype==feedback) { glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glColor4f(linear(e->startcol[0],e->endcol[0],t),linear(e->startcol[1],e->endcol[1],t),linear(e->startcol[2],e->endcol[2],t),linear(e->startcol[3],e->endcol[3],t)); glEnable(GL_BLEND); glBlendFunc(e->blendfunc1,e->blendfunc2); glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,shots[e->texture].texture); glBegin(GL_QUADS); float xc,yc,xs,ys; xc=(shots[e->texture].x1+shots[e->texture].x2)/2.0f; yc=(shots[e->texture].y1+shots[e->texture].y2)/2.0f; xs=(shots[e->texture].x2-shots[e->texture].x1)/2.0f; ys=(shots[e->texture].y2-shots[e->texture].y1)/2.0f; for (int x=0; x<e->param1; x++) { float zoom=1.0f+(float)x/e->param1/e->param4; glColor4f(linear(e->startcol[0],e->endcol[0],t)*(float)(20-x)/20.0f,linear(e->startcol[1],e->endcol[1],t)*(float)(20-x)/20.0f,linear(e->startcol[2],e->endcol[2],t)*(float)(20-x)/20.0f,linear(e->startcol[3],e->endcol[3],t)*(float)(20-x)/20.0f); glTexCoord2f(xc-xs/zoom,yc-ys/zoom); glVertex2f(x1,y1); glTexCoord2f(xc+xs/zoom,yc-ys/zoom); glVertex2f(x2,y1); glTexCoord2f(xc+xs/zoom,yc+ys/zoom); glVertex2f(x2,y2); glTexCoord2f(xc-xs/zoom,yc+ys/zoom); glVertex2f(x1,y2); } glEnd(); } if (e->eventtype==grideffect) { glDepthMask(false); float time=linear(e->gridstart,e->gridend,t); glLoadIdentity(); gluOrtho2D (0, 640, 480,0); glViewport(0,0,xres,yres); glColor4f(linear(e->startcol[0],e->endcol[0],t),linear(e->startcol[1],e->endcol[1],t),linear(e->startcol[2],e->endcol[2],t),linear(e->startcol[3],e->endcol[3],t)); glEnable(GL_BLEND); glBlendFunc(e->blendfunc1,e->blendfunc2); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,shots[e->texture].texture); MakeEffect(e->effect,time,x1,y1,x2,y2, shots[e->texture].x1, shots[e->texture].y1, shots[e->texture].x2, shots[e->texture].y2, 0, 0, 0, 0, 0, 0, 0, 0); } switchto2d(); glPopAttrib(); }
void bulletBaseApp::renderme() { myinit(); updateCamera(); if (m_dynamicsWorld) { if(m_enableshadows) { glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_CULL_FACE); renderscene(0); glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); glDepthFunc(GL_LEQUAL); glEnable(GL_STENCIL_TEST); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL); glFrontFace(GL_CCW); glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); renderscene(1); glFrontFace(GL_CW); glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); renderscene(1); glFrontFace(GL_CCW); glPolygonMode(GL_FRONT,GL_FILL); glPolygonMode(GL_BACK,GL_FILL); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_LIGHTING); glDepthMask(GL_TRUE); glCullFace(GL_BACK); glFrontFace(GL_CCW); glEnable(GL_CULL_FACE); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glDepthFunc(GL_LEQUAL); glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL ); glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); glDisable(GL_LIGHTING); renderscene(2); glEnable(GL_LIGHTING); glDepthFunc(GL_LESS); glDisable(GL_STENCIL_TEST); glDisable(GL_CULL_FACE); } else { glDisable(GL_CULL_FACE); renderscene(0); } int xOffset = 10; int yStart = 20; int yIncr = 20; char buf[124]; glDisable(GL_LIGHTING); glColor3f(0, 0, 0); if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0) { setOrthographicProjection(); showProfileInfo(xOffset,yStart,yIncr); #ifdef USE_QUICKPROF if ( getDebugMode() & btIDebugDraw::DBG_ProfileTimings) { static int counter = 0; counter++; std::map<std::string, hidden::ProfileBlock*>::iterator iter; for (iter = btProfiler::mProfileBlocks.begin(); iter != btProfiler::mProfileBlocks.end(); ++iter) { char blockTime[128]; sprintf(blockTime, "%s: %lf",&((*iter).first[0]),btProfiler::getBlockTime((*iter).first, btProfiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT)); glRasterPos3f(xOffset,yStart,0); GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),blockTime); yStart += yIncr; } } #endif //USE_QUICKPROF sprintf(buf,"mouse to interact"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"ALT + mouse to move camera"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"space to reset"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"cursor keys and z,x to navigate"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"i to toggle simulation, s single step"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"q to quit"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,". to shoot box"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; // not yet hooked up again after refactoring... sprintf(buf,"d to toggle deactivation"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"g to toggle mesh animation (ConcaveDemo)"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"h to toggle help text"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"o to toggle orthogonal/perspective view"); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; //bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP); //bool useCCD = (getDebugMode() & btIDebugDraw::DBG_EnableCCD); //glRasterPos3f(xOffset,yStart,0); //sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD); //GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),buf); //yStart += yIncr; sprintf(buf,"+- shooting speed = %10.2f",m_ShootBoxInitialSpeed); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; #ifdef SHOW_NUM_DEEP_PENETRATIONS sprintf(buf,"gNumDeepPenetrationChecks = %d",gNumDeepPenetrationChecks); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"gNumGjkChecks= %d",gNumGjkChecks); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"gNumClampedCcdMotions = %d",gNumClampedCcdMotions); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"gNumSplitImpulseRecoveries= %d",gNumSplitImpulseRecoveries); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"gNumAlignedAllocs = %d",gNumAlignedAllocs); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"gNumAlignedFree= %d",gNumAlignedFree); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"# alloc-free = %d",gNumAlignedAllocs-gNumAlignedFree); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; //enable BT_DEBUG_MEMORY_ALLOCATIONS define in Bullet/src/LinearMath/btAlignedAllocator.h for memory leak detection #ifdef BT_DEBUG_MEMORY_ALLOCATIONS glRasterPos3f(xOffset,yStart,0); sprintf(buf,"gTotalBytesAlignedAllocs = %d",gTotalBytesAlignedAllocs); GLDebugDrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; #endif //BT_DEBUG_MEMORY_ALLOCATIONS if (getDynamicsWorld()) { glRasterPos3f(xOffset,yStart,0); sprintf(buf,"# objects = %d",getDynamicsWorld()->getNumCollisionObjects()); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"# pairs = %d",getDynamicsWorld()->getBroadphase()->getOverlappingPairCache()->getNumOverlappingPairs()); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; sprintf(buf,"# hitPos = %f,%f,%f",gHitPos.getX(),gHitPos.getY(),gHitPos.getZ()); GLDebugDrawString(xOffset,yStart,buf); yStart += yIncr; } #endif //SHOW_NUM_DEEP_PENETRATIONS resetPerspectiveProjection(); } glEnable(GL_LIGHTING); } updateCamera(); }