static void loggerwindow_do_draw(LoggerWindow *lw) { int i, ndisplines, startline; int sb_rect[2][2], sb_thumb[2][2]; GHOST_ActivateWindowDrawingContext(lw->win); glClearColor(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.8, 0.8, 0.8); rect_bevel_smooth(lw->textarea, 4); scrollbar_get_rect(lw->scroll, sb_rect); scrollbar_get_thumb(lw->scroll, sb_thumb); glColor3f(0.6, 0.6, 0.6); rect_bevel_smooth(sb_rect, 1); if (scrollbar_is_scrolling(lw->scroll)) { glColor3f(0.6, 0.7, 0.5); } else { glColor3f(0.9, 0.9, 0.92); } rect_bevel_smooth(sb_thumb, 1); startline= scrollbar_get_thumbpos(lw->scroll)*(lw->nloglines-1); ndisplines= min_i(lw->ndisplines, lw->nloglines-startline); if (lw->fonttexid!=-1) { glBindTexture(GL_TEXTURE_2D, lw->fonttexid); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); } glColor3f(0, 0, 0); for (i=0; i<ndisplines; i++) { /* stored in reverse order */ char *line= lw->loglines[(lw->nloglines-1)-(i+startline)]; int x_pos= lw->textarea[0][0] + 4; int y_pos= lw->textarea[0][1] + 4 + i*lw->fontheight; if (lw->fonttexid==-1) { glRasterPos2i(x_pos, y_pos); BMF_DrawString(lw->font, line); } else { BMF_DrawStringTexture(lw->font, line, x_pos, y_pos, 0.0); } } if (lw->fonttexid!=-1) { glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); } GHOST_SwapWindowBuffers(lw->win); }
virtual void clientMoveAndDisplay() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); float xOffset = 10.f; float yStart = 20.f; float yIncr = 20.f; char buf[124]; glColor3f(0, 0, 0); setOrthographicProjection(); glRasterPos3f(xOffset,yStart,0); sprintf(buf,"gNumAlignedAllocs= %d",gNumAlignedAllocs); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"gNumAlignedFree= %d",gNumAlignedFree); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"# alloc-free = %d",gNumAlignedAllocs-gNumAlignedFree); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; #ifdef BT_DEBUG_MEMORY_ALLOCATIONS glRasterPos3f(xOffset,yStart,0); sprintf(buf,"gTotalBytesAlignedAllocs = %d",gTotalBytesAlignedAllocs); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; #endif //BT_DEBUG_MEMORY_ALLOCATIONS glFlush(); glutSwapBuffers(); }
static void doPrint ( int x, int& y, int dy, const char * text ) { glRasterPos3f(x, y, 0); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10), text); y += dy; }
void GLDebugDrawer::DrawContactPoint(const SimdVector3& pointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color) { if (m_debugMode & IDebugDraw::DBG_DrawContactPoints) { SimdVector3 to=pointOnB+normalOnB*distance; const SimdVector3&from = pointOnB; glBegin(GL_LINES); glColor3f(color.getX(), color.getY(), color.getZ()); glVertex3d(from.getX(), from.getY(), from.getZ()); glVertex3d(to.getX(), to.getY(), to.getZ()); glEnd(); glRasterPos3f(from.x(), from.y(), from.z()); char buf[12]; sprintf(buf," %d",lifeTime); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); } }
int BMF_DrawCharacter(BMF_Font* font, char c) { char str[2] = {c, '\0'}; return BMF_DrawString(font, str); }
void ParticleRenderer::displayProfileString(int xOffset,int yStart,char* message) { glRasterPos3f(xOffset,yStart,0); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),message); }
//to be implemented by the demo void renderme() { debugDrawer.SetDebugMode(getDebugMode()); //render the hinge axis if (createConstraint) { SimdVector3 color(1,0,0); SimdVector3 dirLocal(0,1,0); SimdVector3 pivotInA(CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS); SimdVector3 pivotInB(-CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS); SimdVector3 from = physObjects[1]->GetRigidBody()->getCenterOfMassTransform()(pivotInA); SimdVector3 fromB = physObjects[2]->GetRigidBody()->getCenterOfMassTransform()(pivotInB); SimdVector3 dirWorldA = physObjects[1]->GetRigidBody()->getCenterOfMassTransform().getBasis() * dirLocal ; SimdVector3 dirWorldB = physObjects[2]->GetRigidBody()->getCenterOfMassTransform().getBasis() * dirLocal ; debugDrawer.DrawLine(from,from+dirWorldA,color); debugDrawer.DrawLine(fromB,fromB+dirWorldB,color); } float m[16]; int i; if (getDebugMode() & IDebugDraw::DBG_DisableBulletLCP) { //don't use Bullet, use quickstep physicsEnvironmentPtr->setSolverType(0); } else { //Bullet LCP solver physicsEnvironmentPtr->setSolverType(1); } if (getDebugMode() & IDebugDraw::DBG_EnableCCD) { physicsEnvironmentPtr->setCcdMode(3); } else { physicsEnvironmentPtr->setCcdMode(0); } bool isSatEnabled = (getDebugMode() & IDebugDraw::DBG_EnableSatComparison); physicsEnvironmentPtr->EnableSatCollisionDetection(isSatEnabled); #ifdef USE_HULL //some testing code for SAT if (isSatEnabled) { for (int s=0;s<numShapes;s++) { CollisionShape* shape = shapePtr[s]; if (shape->IsPolyhedral()) { PolyhedralConvexShape* polyhedron = static_cast<PolyhedralConvexShape*>(shape); if (!polyhedron->m_optionalHull) { //first convert vertices in 'Point3' format int numPoints = polyhedron->GetNumVertices(); Point3* points = new Point3[numPoints+1]; //first 4 points should not be co-planar, so add central point to satisfy MakeHull points[0] = Point3(0.f,0.f,0.f); SimdVector3 vertex; for (int p=0;p<numPoints;p++) { polyhedron->GetVertex(p,vertex); points[p+1] = Point3(vertex.getX(),vertex.getY(),vertex.getZ()); } Hull* hull = Hull::MakeHull(numPoints+1,points); polyhedron->m_optionalHull = hull; } } } } #endif //USE_HULL for (i=0;i<numObjects;i++) { SimdTransform transA; transA.setIdentity(); float pos[3]; float rot[4]; ms[i].getWorldPosition(pos[0],pos[1],pos[2]); ms[i].getWorldOrientation(rot[0],rot[1],rot[2],rot[3]); SimdQuaternion q(rot[0],rot[1],rot[2],rot[3]); transA.setRotation(q); SimdPoint3 dpos; dpos.setValue(pos[0],pos[1],pos[2]); transA.setOrigin( dpos ); transA.getOpenGLMatrix( m ); SimdVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation if (i & 1) { wireColor = SimdVector3(0.f,0.0f,1.f); } ///color differently for active, sleeping, wantsdeactivation states if (physObjects[i]->GetRigidBody()->GetActivationState() == 1) //active { if (i & 1) { wireColor += SimdVector3 (1.f,0.f,0.f); } else { wireColor += SimdVector3 (.5f,0.f,0.f); } } if (physObjects[i]->GetRigidBody()->GetActivationState() == 2) //ISLAND_SLEEPING { if (i & 1) { wireColor += SimdVector3 (0.f,1.f, 0.f); } else { wireColor += SimdVector3 (0.f,0.5f,0.f); } } char extraDebug[125]; sprintf(extraDebug,"islId, Body=%i , %i",physObjects[i]->GetRigidBody()->m_islandTag1,physObjects[i]->GetRigidBody()->m_debugBodyId); physObjects[i]->GetRigidBody()->GetCollisionShape()->SetExtraDebugInfo(extraDebug); GL_ShapeDrawer::DrawOpenGL(m,physObjects[i]->GetRigidBody()->GetCollisionShape(),wireColor,getDebugMode()); ///this block is just experimental code to show some internal issues with replacing shapes on the fly. if (getDebugMode()!=0 && (i>0)) { if (physObjects[i]->GetRigidBody()->GetCollisionShape()->GetShapeType() == EMPTY_SHAPE_PROXYTYPE) { physObjects[i]->GetRigidBody()->SetCollisionShape(shapePtr[1]); //remove the persistent collision pairs that were created based on the previous shape BroadphaseProxy* bpproxy = physObjects[i]->GetRigidBody()->m_broadphaseHandle; physicsEnvironmentPtr->GetBroadphase()->CleanProxyFromPairs(bpproxy); SimdVector3 newinertia; SimdScalar newmass = 10.f; physObjects[i]->GetRigidBody()->GetCollisionShape()->CalculateLocalInertia(newmass,newinertia); physObjects[i]->GetRigidBody()->setMassProps(newmass,newinertia); physObjects[i]->GetRigidBody()->updateInertiaTensor(); } } } if (!(getDebugMode() & IDebugDraw::DBG_NoHelpText)) { float xOffset = 10.f; float yStart = 20.f; float yIncr = -2.f; char buf[124]; glColor3f(0, 0, 0); #ifdef USE_QUICKPROF if ( getDebugMode() & IDebugDraw::DBG_ProfileTimings) { static int counter = 0; counter++; std::map<std::string, hidden::ProfileBlock*>::iterator iter; for (iter = Profiler::mProfileBlocks.begin(); iter != Profiler::mProfileBlocks.end(); ++iter) { char blockTime[128]; sprintf(blockTime, "%s: %lf",&((*iter).first[0]),Profiler::getBlockTime((*iter).first, Profiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT)); glRasterPos3f(xOffset,yStart,0); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),blockTime); yStart += yIncr; } } #endif //USE_QUICKPROF //profiling << Profiler::createStatsString(Profiler::BLOCK_TOTAL_PERCENT); //<< std::endl; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"mouse to interact"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"space to reset"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"cursor keys and z,x to navigate"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"i to toggle simulation, s single step"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"q to quit"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"d to toggle deactivation"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"a to draw temporal AABBs"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"h to toggle help text"); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; bool useBulletLCP = !(getDebugMode() & IDebugDraw::DBG_DisableBulletLCP); bool useCCD = (getDebugMode() & IDebugDraw::DBG_EnableCCD); glRasterPos3f(xOffset,yStart,0); sprintf(buf,"m Bullet GJK = %i",!isSatEnabled); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"n Bullet LCP = %i",useBulletLCP); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"+- shooting speed = %10.2f",bulletSpeed); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; } }
static void RenderCallback() { // Clear buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Setup camera glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0f, ((float)glutGet(GLUT_WINDOW_WIDTH))/((float)glutGet(GLUT_WINDOW_HEIGHT)), 1.0f, 10000.0f); gluLookAt(Eye.x(), Eye.y(), Eye.z(), Eye.x() + Dir.x(), Eye.y() + Dir.y(), Eye.z() + Dir.z(), 0.0f, 1.0f, 0.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_LIGHTING); //clear previous frames result gNormal.setValue(10,0,0); gPoint.setValue(0,0,0); gDepth = 999.999; gLastUsedMethod = -1; gNumGjkIterations = -1; TestEPA(gConvex0, gConvex1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); btVector3 RefSep(btScalar(0.), btScalar(0.), btScalar(0.)); float RefDMin=0.f; bool RefResult = false; if(gRefMode) RefResult = ReferenceCode(gConvex0, gConvex1, RefDMin, RefSep); // DrawLine(gPoint, gPoint + gNormal*20.0f, btVector3(1,0,0), 2.0f); // printf("%f: %f %f %f\n", gDepth, gNormal.x(), gNormal.y(), gNormal.z()); #ifdef VERBOSE_TEXT_ONSCREEN glColor3f(255.f, 255.f, 255.f); setOrthographicProjection(); float xOffset = 10.f; float yStart = 20.f; float yIncr = 20.f; char buf[124]; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"gDepth=%f: gNormal=(%f %f %f)\n", gDepth, gNormal.x(), gNormal.y(), gNormal.z()); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"num GJK iterations =%d\n", gNumGjkIterations); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"gLastUsedMethod=%d\n", gLastUsedMethod); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; if (gLastUsedMethod >= 3) { switch ( gMethod) { case 0: sprintf(buf,"Bullet GjkEpa Penetration depth solver (zlib free\n" ); break; case 1: sprintf(buf,"Bullet Minkowski sampling Penetration depth solver\n" ); break; case 2: sprintf(buf,"Solid35 EPA Penetration depth solver\n" ); break; case 3: sprintf(buf,"EPA Penetration depth solver (Experimental/WorkInProgress, zlib free\n" ); break; default: sprintf(buf,"Unknown Penetration Depth\n" ); } glRasterPos3f(xOffset,yStart,0); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; } else { glRasterPos3f(xOffset,yStart,0); sprintf(buf,"Hybrid GJK method %d\n", gLastUsedMethod); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; } if (gLastDegenerateSimplex) { glRasterPos3f(xOffset,yStart,0); sprintf(buf,"DegenerateSimplex %d\n", gLastDegenerateSimplex); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; } resetPerspectiveProjection(); #endif //VERBOSE_TEXT_ONSCREEN btVector3 color(0,0,0); gConvex0.Render(false, color); gConvex1.Render(false, color); if(gDepth<0.0f) { btTransform Saved = gConvex0.mTransform; gConvex0.mTransform.setOrigin(gConvex0.mTransform.getOrigin() - btVector3(gNormal*gDepth)); gConvex0.Render(true, btVector3(1.0f, 0.5f, 0.0f)); gConvex0.mTransform = Saved; } else { DrawLine(gPoint, gPoint + gNormal, btVector3(0,1,0), 2.0f); } if(RefResult & gRefMode) { btTransform Saved = gConvex0.mTransform; gConvex0.mTransform.setOrigin(gConvex0.mTransform.getOrigin() + btVector3(RefSep*RefDMin)); gConvex0.Render(true, btVector3(0.0f, 0.5f, 1.0f)); gConvex0.mTransform = Saved; } glutSwapBuffers(); }