Exemplo n.º 1
0
void Screens::Render()
{
    setOrthographicProjection();
    glColor3f (1.0, 1.0, 1.0);
    writeString("lives remaining: ", 100, 100, GLUT_BITMAP_TIMES_ROMAN_24);
    resetPerspectiveProjection();
}
Exemplo n.º 2
0
// Display func for sub window 1
void renderScenesw1() {

	glutSetWindow(subWindow1);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();
	gluLookAt(x, y, z,
		      x + lx,y + ly,z + lz,
			  0.0f,1.0f,0.0f);

	renderScene2();

	// display fps in the top window
 	frame++;

	time=glutGet(GLUT_ELAPSED_TIME);
	if (time - timebase > 1000) {
		sprintf(s,"Lighthouse3D - FPS:%4.2f",
			frame*1000.0/(time-timebase));
		timebase = time;
		frame = 0;
	}

	setOrthographicProjection();

	glPushMatrix();
	glLoadIdentity();
	renderBitmapString(5,30,0,GLUT_BITMAP_HELVETICA_12,s);
	glPopMatrix();
	restorePerspectiveProjection();

	glutSwapBuffers();
}
Exemplo n.º 3
0
void DialogBalloon::draw(int selection)
{
	if(textField){
		textField->x=x+8-(width/2);
		textField->y=y-height-footerHeight+8;
	}

	if(titleTextField){
		titleTextField->x=x+8-(width/2);
		titleTextField->y=y-height-footerHeight-headerHeight+8;
	}

	setOrthographicProjection(selection);
        glColor4f(red, green, blue, alpha);	
	//Draw body background
	Draw2D::Rectangle(x-(width/2), y-footerHeight-height, width, height);
	
	//Draw Header background
	Draw2D::Rectangle(x-(width/2), y-footerHeight-headerHeight+1-height, width, headerHeight);

	//Create triangle point
	glBegin(GL_POLYGON);
	glVertex2f(x, y);
	glVertex2f(x-20, y-footerHeight);
	glVertex2f(x+20, y-footerHeight);
	glEnd();

	glColor3f(255,255,255);
	restorePerspectiveProjection();
	
}
Exemplo n.º 4
0
void FractureDemo::showMessage()
{
	if((getDebugMode() & btIDebugDraw::DBG_DrawText))
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];

		int lineWidth=380;
		int xStart = m_glutScreenWidth - lineWidth;
		int yStart = 20;

		btFractureDynamicsWorld* world = (btFractureDynamicsWorld*)m_dynamicsWorld;
		if (world->getFractureMode())
		{
			sprintf(buf,"Fracture mode");
		} else
		{
			sprintf(buf,"Glue mode");
		}
		GLDebugDrawString(xStart,yStart,buf);
		sprintf(buf,"f to toggle fracture/glue mode");		
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		sprintf(buf,"space to restart, mouse to pick/shoot");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}

}
Exemplo n.º 5
0
	void renderPostProcess(FrameBufferObject* target, Shader* shader, bool clear)
	{
		if(clear)
		{
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
		}

		glEnable(GL_TEXTURE_RECTANGLE);
		setOrthographicProjection();
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_RECTANGLE, target->getColorBuffer());
	
		shader->bindShader();
		glBegin(GL_QUADS);
			glTexCoord2i(0,HEIGHT);
			glVertex2i(0,0);
			glTexCoord2i(WIDTH,HEIGHT);
			glVertex2i(WIDTH,0);
			glTexCoord2i(WIDTH,0);
			glVertex2i(WIDTH,HEIGHT);
			glTexCoord2i(0,0);
			glVertex2i(0,HEIGHT);
		glEnd();
		shader->unbindShader();
		
		glBindTexture(GL_TEXTURE_RECTANGLE, 0);
		glDisable(GL_TEXTURE_RECTANGLE);
		restorePerspectiveProjection();
	}
Exemplo n.º 6
0
//to be implemented by the demo
void ForkLiftDemo::renderme()
{
	
	updateCamera();

	btScalar m[16];
	int i;

	btVector3 wheelColor(1,0,0);

	btVector3	worldBoundsMin,worldBoundsMax;
	getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);



	for (i=0;i<m_vehicle->getNumWheels();i++)
	{
		//synchronize the wheels with the (interpolated) chassis worldtransform
		m_vehicle->updateWheelTransform(i,true);
		//draw wheels (cylinders)
		m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);
		m_shapeDrawer->drawOpenGL(m,m_wheelShape,wheelColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
	}


	int lineWidth=250;
	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = 20;

	if((getDebugMode() & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];
		
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"SHIFT+Cursor Left/Right - rotate lift");
		GLDebugDrawString(xStart,20,buf);
		yStart+=20;
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"SHIFT+Cursor UP/Down - move fork up/down");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"F5 - toggle camera mode");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
        sprintf(buf,"Click inside this window for keyboard focus");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);


		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}
	DemoApplication::renderme();
}
Exemplo n.º 7
0
void renderScene2(int currentWindow)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();
	glColor3f(1.0, 0.0, 0.0);
	glTranslatef(x, y, z);
	glRotatef(180 - angle*180.0 / 3.14, 0.0, 1.0, 0.0);
	glutSolidCone(0.2, 0.8f, 4, 4);
	glPopMatrix();

	// Draw ground
	glColor3f(0.9f, 0.9f, 0.9f);
	glBegin(GL_QUADS);
	glVertex3f(-100.0f, 0.0f, -100.0f);
	glVertex3f(-100.0f, 0.0f, 100.0f);
	glVertex3f(100.0f, 0.0f, 100.0f);
	glVertex3f(100.0f, 0.0f, -100.0f);
	glEnd();

	// Draw 36 SnowMen
	// call the function that contains the rendering commands
	for (int i = -3; i < 3; i++)
	{
		for (int j = -3; j < 3; j++)
		{
			glPushMatrix();
			glTranslatef(i*10.0, 0, j*10.0);
			drawSnowMan();
			glPopMatrix();
		}
	}

	if (currentWindow == subWindow1)
	{
		frame++;
		time = glutGet(GLUT_ELAPSED_TIME);
		if (time - timebase > 1000) {
			sprintf(s, "FPS: %4.2f", frame*1000.0 / (time - timebase));
			timebase = time;
			frame = 0;
		}

		glColor3f(0.0, 1.0, 1.0);
		setOrthographicProjection();
		glPushMatrix();
		glLoadIdentity();
		renderBitmapString(30, 15, (void *)font, "IPCA - EDJG - P3D");
		renderBitmapString(30, 35, (void *)font, s);
		renderBitmapString(30, 55, (void *)font, "Esc - Quit");
		glPopMatrix();
		resetPerspectiveProjection();
	}

	glutSwapBuffers();
}
Exemplo n.º 8
0
void Image2D::draw(int selection)
{
    setOrthographicProjection(selection);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBindTexture( GL_TEXTURE_2D, texture ); //bind the texture
    Draw2D::Rectangle(x, y, width, height);
    glBindTexture(GL_TEXTURE_2D, 0);
    restorePerspectiveProjection();

}
Exemplo n.º 9
0
void drawHUD()
{
  setOrthographicProjection();
  glColor3f(1.0-g_bgcolor.r,1.0-g_bgcolor.g,1.0-g_bgcolor.b);
  renderBitmapString( 4, g_display_controller.getWindowHeight()-20, 0.0, GLUT_BITMAP_HELVETICA_18, stringutils::convertToString(g_current_step*g_dt) ); 
  glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

  assert( renderingutils::checkGLErrors() );
}
Exemplo n.º 10
0
void CcdPhysicsDemo::displayText()
{
#ifndef __QNX__
	int lineWidth=440;
	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = 20;

	if((getDebugMode() & btIDebugDraw::DBG_DrawText)!=0)
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];
		
		glRasterPos3f(xStart, yStart, 0);
		switch (m_ccdMode)
		{
		case USE_CCD:
			{
				sprintf(buf,"Predictive contacts and motion clamping");
				break;
			}
		case USE_NO_CCD:
			{
				sprintf(buf,"CCD handling disabled");
				break;
			}
		default:
			{
				sprintf(buf,"unknown CCD setting");
			};
		};

		GLDebugDrawString(xStart,20,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"Press 'p' to change CCD mode");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"Press '.' or right mouse to shoot bullets");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		glRasterPos3f(xStart, yStart, 0);
		sprintf(buf,"space to restart, h(elp), t(ext), w(ire)");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);
		
		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}	
#endif
}
Exemplo n.º 11
0
void drawDescription() {
    setOrthographicProjection();
    glColor3d(1.0-g_simulation_ensemble->getBackgroundColor().r(),1.0-g_simulation_ensemble->getBackgroundColor().g(),1.0-g_simulation_ensemble->getBackgroundColor().b());
    
    std::string str(g_description);
    renderBitmapString( 20, 20, 0.0, GLUT_BITMAP_HELVETICA_18, str );
    
    glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
    
    assert( renderingutils::checkGLErrors() );
}
void KomposeGLFullscreenWidget::initializeGL()
{
    // Set up the rendering context, define display lists etc.:
    if( !format().hasOpenGL() )
    {
        qWarning( "KomposeGLFullscreenWidget::initializeGL() - OpenGL not supported!" );
        return;
    }

    if ( !format().doubleBuffer() )
    {
        qWarning( "KomposeGLFullscreenWidget::initializeGL() - Direct rendering enabled !" );
    }
//   glShadeModel(GL_SMOOTH);
//
//   format().setDirectRendering( true );
//   format().setDoubleBuffer( true );
//   format().setRgba( true );
//   format().setDepth ( false );
//   format().setAccum( false );
//   format().setStencil( false );
//   format().setAlpha( true );

    // Alpha blend
//   glEnable( GL_BLEND );
//   glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    // All smoothing stuff
//   glEnable( GL_POLYGON_SMOOTH );
//   glHint( GL_POLYGON_SMOOTH_HINT, GL_FASTEST );
//   glEnable( GL_POINT_SMOOTH );
//   glHint( GL_POINT_SMOOTH_HINT, GL_FASTEST );
//   glEnable( GL_LINE_SMOOTH );
//   glHint( GL_LINE_SMOOTH_HINT, GL_FASTEST );

    // Lighting and Depth Test
    glDisable( GL_LIGHTING );
//   glDisable( GL_DEPTH_TEST );
//   glDisable( GL_NORMALIZE );

    glClearColor( 0.0, 0.0, 0.0, 0.0 );
    glClear( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT );

    /*! Setup sizes */
//   glLineWidth( 1.0 );
//   glPointSize( 2.0 );

    setOrthographicProjection();
}
Exemplo n.º 13
0
void player_position (void)
{
	char position[50];
	
	sprintf(position,"X = %f, Y = %f, Z = %f", xpos, ypos, zpos);
	
	setOrthographicProjection();
	//glDisable (GL_LIGHTING);
	glPushMatrix();
	glLoadIdentity();
	renderBitmapString(5,50,0,GLUT_BITMAP_HELVETICA_18, position);
	glPopMatrix();
	//glEnable (GL_LIGHTING);
	restorePerspectiveProjection();
	
}
Exemplo n.º 14
0
void drawFPS() {
    setOrthographicProjection();
    glColor3d(1.0-g_simulation_ensemble->getBackgroundColor().r(),1.0-g_simulation_ensemble->getBackgroundColor().g(),1.0-g_simulation_ensemble->getBackgroundColor().b());
    
    std::string fpsStr;
    if (g_paused)
        fpsStr = "Paused";
    else
        fpsStr = stringutils::convertToString(g_fps,2) + " fps";
    renderBitmapString( 20, 20, 0.0, GLUT_BITMAP_HELVETICA_18, fpsStr );
    
    glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
    
    assert( renderingutils::checkGLErrors() );
}
Exemplo n.º 15
0
void renderDisplayStart(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    gluLookAt(	0.0f, 0.0f, 10.0f,
			0.0f, 0.0f,  0.0f,
			0.0f, 1.0f,  0.0f);

    drawStart(0.0f);
    setOrthographicProjection();
    glPushMatrix();
    glLoadIdentity();
    glColor3f(0.0f, 0.0f, 1.0f);
    renderBitmapString(315,250,1,fontBitmap,(char *)"START");
    glPopMatrix();
    restorePerspectiveProjection();
    glutSwapBuffers();
}
Exemplo n.º 16
0
/// override the default display just so we can overlay a bit more text
void TerrainDemo::renderme(void)
{
	// give base class a shot
	DemoApplication::renderme();

	// overlay any debug information
	if (m_dynamicsWorld)
		m_dynamicsWorld->debugDrawWorld();

	// switch to orthographic
	setOrthographicProjection();

	// we'll draw on the right top of the screen
	const int lineWidth = 200;
	const int lineHeight = 16;
	char buffer[256];

	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = lineHeight;

	sprintf(buffer, "Terrain Type: %s", getTerrainTypeName(m_model));
	doPrint(xStart, yStart, lineHeight, buffer);
	doPrint(xStart, yStart, lineHeight, "Press ',' to cycle terrain types");
	doPrint(xStart, yStart, lineHeight, "");

	sprintf(buffer, "Data Type: %s", getDataTypeName(m_type));
	doPrint(xStart, yStart, lineHeight, buffer);
	doPrint(xStart, yStart, lineHeight, "Press '/' to cycle data types");
	doPrint(xStart, yStart, lineHeight, "");

	sprintf(buffer, "'up' axis: %s", getUpAxisName(m_upAxis));
	doPrint(xStart, yStart, lineHeight, buffer);
	doPrint(xStart, yStart, lineHeight, "Press '\\' to cycle 'up' axes");
	doPrint(xStart, yStart, lineHeight, "");

	if (eRadial == m_model) {
		sprintf(buffer, "Dynamic: %s", m_isDynamic ? "yes" : "no");
		doPrint(xStart, yStart, lineHeight, buffer);
		doPrint(xStart, yStart, lineHeight, "Press '[' to toggle dynamics");
	}
}
Exemplo n.º 17
0
void fps (void)
{
	frame++;

	timez = glutGet(GLUT_ELAPSED_TIME);
	if ((timez - timebase) > 1000) 
	{
		sprintf(s,"FPS:%4.2f", frame*1000.0/(timez-timebase));
		timebase = timez;
		frame = 0;
	}

	setOrthographicProjection();
//	glDisable (GL_LIGHTING);
	glPushMatrix();
	glLoadIdentity();
	renderBitmapString(5,30,0,GLUT_BITMAP_HELVETICA_18,s);
	glPopMatrix();
	//glEnable (GL_LIGHTING);
	restorePerspectiveProjection();
}
Exemplo n.º 18
0
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();
	}
}
Exemplo n.º 19
0
void calcFPS(){
	// Code to compute frames per second
	frame++;

	time=glutGet(GLUT_ELAPSED_TIME);
	if (time - timebase > 1000) {
		sprintf(s,"FPS:%4.2f",
			frame*1000.0/(time-timebase));
		timebase = time;
		frame = 0;
	}

	// Code to display a string (fps) with bitmap fonts
	setOrthographicProjection();

	glPushMatrix();
	glLoadIdentity();
	renderBitmapString(5,30,0,GLUT_BITMAP_TIMES_ROMAN_24,s);
	glPopMatrix();
	restorePerspectiveProjection();
}
Exemplo n.º 20
0
	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);
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;

		glRasterPos3f(xOffset,yStart,0);
		sprintf(buf,"gNumAlignedFree= %d",gNumAlignedFree);
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;

		glRasterPos3f(xOffset,yStart,0);
		sprintf(buf,"# alloc-free = %d",gNumAlignedAllocs-gNumAlignedFree);
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
		glRasterPos3f(xOffset,yStart,0);
		sprintf(buf,"gTotalBytesAlignedAllocs = %d",gTotalBytesAlignedAllocs);
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;
#endif //BT_DEBUG_MEMORY_ALLOCATIONS

	glFlush();
	glutSwapBuffers();
			
	}
Exemplo n.º 21
0
/* http://www.lighthouse3d.com/tutorials/glut-tutorial/bitmap-fonts-and-orthogonal-projections/ */
static void drawInfo()
{
    char buf[1024];

    setOrthographicProjection();
    glPushMatrix();
    glLoadIdentity();

    glColor3f(1.0f, 1.0f, 1.0f);
    glRasterPos2i(20, 20);

    snprintf(buf, sizeof(buf),
             "Time: %4.3f / %4.3f Gyr (%4.3f %%)\n",
             scene->info.currentTime,
             scene->info.timeEvolve,
             100.0f * scene->info.currentTime / scene->info.timeEvolve
        );
    nbody_glutBitmapStringHelvetica(buf);

    glPopMatrix();
    restorePerspectiveProjection();
}
Exemplo n.º 22
0
    void testTextOverlay() {
    
        // text overlay
        glColor3ub(220,220,220);
        setOrthographicProjection(width,height);

        glPushMatrix();
        glLoadIdentity();

        glScalef(1,-1,1);

        font.preDrawString();
        real lineFeed = 0;
        for (unsigned i=0;i<console.size();i++) {
            font.drawString(console[i],0,lineFeed-=font.lineHeight());
        }
        font.posDrawString();

        glPopMatrix();

        resetPerspectiveProjection();
    }
Exemplo n.º 23
0
void drawStart(float zz)
{
    glColor3f(0.9f, 0.9f, 0.9f);

    glBegin(GL_POLYGON);
		glVertex3f(0.0f, -1.0f, zz);
        glVertex3f(1.0f, -1.0f, zz);
		glVertex3f(1.5f, -0.5f, zz);
		glVertex3f(1.5f, 0.5f, zz);
		glVertex3f(1.0f, 1.0f, zz);
        glVertex3f(-1.0f, 1.0f, zz);
		glVertex3f(-1.5f, 0.5f, zz);
		glVertex3f(-1.5f, -0.5f, zz);
		glVertex3f(-1.0f, -1.0f, zz);
        glVertex3f(0.0f, -1.0f, zz);

	glEnd();

    setOrthographicProjection();
	renderBitmapString(-1.0f, 0.0f, 0.5f,fontBitmap,(char *)"START");
	restorePerspectiveProjection();
}
Exemplo n.º 24
0
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();
	}
}
Exemplo n.º 25
0
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];

	sprintf(buf,"gDepth=%f:  gNormal=(%f  %f  %f)\n", gDepth, gNormal.x(), gNormal.y(), gNormal.z());
	GLDebugDrawString(xOffset,yStart,buf);
	yStart += yIncr;

	sprintf(buf,"num GJK iterations =%d\n", gNumGjkIterations);
	GLDebugDrawString(xOffset,yStart,buf);
	yStart += yIncr;

	sprintf(buf,"gLastUsedMethod=%d\n", gLastUsedMethod);
	GLDebugDrawString(xOffset,yStart,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" );
		}
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;

	} else
	{
		sprintf(buf,"Hybrid GJK method %d\n", gLastUsedMethod);
		GLDebugDrawString(xOffset,yStart,buf);
		yStart += yIncr;
	}

	if (gLastDegenerateSimplex)
	{
		sprintf(buf,"DegenerateSimplex %d\n", gLastDegenerateSimplex);
		GLDebugDrawString(xOffset,yStart,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();	
}
Exemplo n.º 26
0
	void LensFlareSunDemo::renderHud()
	{
		setOrthographicProjection();
		restorePerspectiveProjection();
	}
Exemplo n.º 27
0
	void LensFlareSunDemo::renderSky()
	{
		skyShader.bindShader();
		renderSkyPlane(&camera);
		skyShader.unbindShader();

		setOrthographicProjection();
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		
		renderSun(-64.0f,-64.0f);

		GLfloat center_x = WIDTH * 0.5f;
		GLfloat center_y = HEIGHT * 0.5f;

		GLfloat screenPos_x = -64.0f;
		GLfloat screenPos_y = -64.0f;

		// screenPos is the onscreen position of the sun
		// mind that the pixel coordinates have been scaled
		// to fit our viewport
		GLfloat dx = center_x - screenPos_x;
		GLfloat dy = center_y - screenPos_y;
		GLfloat len = sqrt(dx * dx + dy * dy);

		// normalize the vector
		GLfloat vx = dx / len;
		GLfloat vy = dy / len;
		// choose a spacing between elements
		dx = vx * len * 0.4f;
		dy = vy * len * 0.4f;

		// note that we already are in 2D (orthogonal)
		// mode here

		glPushMatrix();
		glTranslatef(screenPos_x, screenPos_y, 0);

		// travel down the line and draw the elements
		int numElements = 4;

		glBindTexture(GL_TEXTURE_2D,streaks4.texture);
		glTranslatef(dx, dy, 0);
		renderFlare();

		glBindTexture(GL_TEXTURE_2D,halo3.texture);
		glTranslatef(dx, dy, 0);
		renderFlare();

		glBindTexture(GL_TEXTURE_2D,bigGlow3.texture);
		glTranslatef(dx, dy, 0);
		renderFlare();

		glBindTexture(GL_TEXTURE_2D,hardGlow2.texture);
		glTranslatef(dx, dy, 0);
		renderFlare();


		glPopMatrix();

		glDisable(GL_BLEND);
		restorePerspectiveProjection();
	}
Exemplo n.º 28
0
//to be implemented by the demo
void Hinge2Vehicle::renderScene()
{
	m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld);
#if 0
	for (int i=0;i<m_vehicle->getNumWheels();i++)
	{
		//synchronize the wheels with the (interpolated) chassis worldtransform
		m_vehicle->updateWheelTransform(i,true);

		CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
		if (renderer)
		{
			btTransform tr = m_vehicle->getWheelInfo(i).m_worldTransform;
			btVector3 pos=tr.getOrigin();
			btQuaternion orn = tr.getRotation();
			renderer->writeSingleInstanceTransformToCPU(pos,orn,m_wheelInstances[i]);
		}
	}
#endif
	
	m_guiHelper->render(m_dynamicsWorld);

	btVector3 wheelColor(1,0,0);

	btVector3	worldBoundsMin,worldBoundsMax;
	getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);




#if 0
	int lineWidth=400;
	int xStart = m_glutScreenWidth - lineWidth;
	int yStart = 20;

	if((getDebugMode() & btIDebugDraw::DBG_NoHelpText)==0)
	{
		setOrthographicProjection();
		glDisable(GL_LIGHTING);
		glColor3f(0, 0, 0);
		char buf[124];
		
		sprintf(buf,"SHIFT+Cursor Left/Right - rotate lift");
		GLDebugDrawString(xStart,20,buf);
		yStart+=20;
		sprintf(buf,"SHIFT+Cursor UP/Down - fork up/down");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		if (m_useDefaultCamera)
		{
			sprintf(buf,"F5 - camera mode (free)");
		} else
		{
			sprintf(buf,"F5 - camera mode (follow)");
		}
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		yStart+=20;
		if (m_dynamicsWorld->getConstraintSolver()->getSolverType()==BT_MLCP_SOLVER)
		{
			sprintf(buf,"F6 - solver (direct MLCP)");
		} else
		{
			sprintf(buf,"F6 - solver (sequential impulse)");
		}
		GLDebugDrawString(xStart,yStart,buf);
		btDiscreteDynamicsWorld* world = (btDiscreteDynamicsWorld*) m_dynamicsWorld;
		if (world->getLatencyMotionStateInterpolation())
		{
			sprintf(buf,"F7 - motionstate interpolation (on)");
		} else
		{
			sprintf(buf,"F7 - motionstate interpolation (off)");
		}
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);

		sprintf(buf,"Click window for keyboard focus");
		yStart+=20;
		GLDebugDrawString(xStart,yStart,buf);


		resetPerspectiveProjection();
		glEnable(GL_LIGHTING);
	}
#endif
}
Exemplo n.º 29
0
void renderScene(void) {
    
    //Set up Viewport 1 scene
    
    // Use the Projection Matrix
    glMatrixMode(GL_PROJECTION);
    
    // Reset Matrix
    glLoadIdentity();
    
    
    glScissor(0, 0, (GLsizei) windowWidth, (GLsizei) windowHeight*0.9);
    glEnable(GL_SCISSOR_TEST);
    glClearDepth(1.0);
    
    glClearColor(0.49f, 0.75f, 0.93f, 1.0f);
    
    // Set the viewport to be the entire window
    glViewport (0, 0, (GLsizei) windowWidth, (GLsizei) windowHeight*0.9);
    
    // Set the correct perspective.
    
    if (viewMode == PERSPECTIVE)
        gluPerspective(45.0f*zoom, ratio, 1.0f, 1000.0f);
    else if (viewMode == ORTHOGRAPHIC)
        glOrtho((-windowWidth/50)*zoom, (windowWidth/50)*zoom, (-windowHeight/50)*zoom, (windowHeight/50)*zoom, 1.0f, 1000);
    
    // Get Back to the Modelview
    glMatrixMode(GL_MODELVIEW);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    //Decide if wire frame or shaded
    if (polygonMode == WIREFRAME)
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    else if (polygonMode == SHADED)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    
    glLoadIdentity();

    moveCamera();
    
    lx = (sin(heliRot+PI));
    lz = (cos(heliRot+PI));
    
    float camX = curX + lx * 10.0f;
    float camZ = curZ + lz * 10.0f;
    
    //Set camera
    if (viewPerson == THIRD) {
        gluLookAt(eyeX+curX, eyeY, eyeZ+curZ,
                  curX, 0.0f, curZ,
                  upX, upY, upZ);
    }

    else if (viewPerson == FIRST) {
        
        gluLookAt(camX, 1.5f, camZ,
                  camX+lx, 1.5f, camZ+lz,
                  0.0f, 1.0f, 0.0f);
        
    }
    
    glEnable(GL_DEPTH_TEST);
    
    glShadeModel(GL_SMOOTH); // smooth out lighting
    glEnable(GL_NORMALIZE);  // normalize lighting
    
    GLfloat mat_specular[] = {0.3, 0.3, 0.3, 1.0};
    GLfloat mat_shininess[] = { 10.0 };
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);
    
    if (lightingEnabled) {
        
        glEnable(GL_LIGHTING);
    
        if (sunlight) {

            setSunlight();
    
        }
    
        else {
            glDisable(GL_LIGHT0);
        }
        
        
        if (thirdPersonLight) {
            setThirdPersonLight();
        }
        
        else {
            glDisable(GL_LIGHT3);
        }
        
        
    }
    
    else {
        glDisable(GL_LIGHTING);
    }

    glPushMatrix();
    glTranslatef(0.0f, -10, 0.0f);
    drawGround(250, 100);
    glPopMatrix();
    
    glPushMatrix();
    glTranslatef(0.0f, -9.9, 0.0f);
    drawTrack(100.0, 100.0);
    glPopMatrix();
    
    glPushMatrix();
    moveHelicopter();
    glRotatef(heliRot/PI*180, 0.0f, 1.0f, 0.0f);
    drawHelicopter();
    
    
    if (lightingEnabled) {
    
        if (circleLight) {
    moveLight();
    setCircularLight();
        }
        
        else {
            glDisable(GL_LIGHT2);
        }
    
    }
    
    glPopMatrix();
    
    //Set up Viewport 2 scene
    
    // Use the Projection Matrix
    glMatrixMode(GL_PROJECTION);
    
    // Reset Matrix
    glLoadIdentity();
    
    glScissor(0, windowHeight*0.9, (GLsizei) windowWidth, (GLsizei) windowHeight*0.1);
    glEnable(GL_SCISSOR_TEST);
    glClearDepth(1.0);
    glClearColor(1, 1, 1, 1);

    
    // Set the viewport to be the entire window
    glViewport (0, windowHeight*0.9, (GLsizei) windowWidth, (GLsizei) windowHeight*0.1);
    
    // Set the correct perspective.
    
    // Get Back to the Modelview
    glMatrixMode(GL_MODELVIEW);
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glEnable(GL_DEPTH_TEST);
    
    frame++;
    time=glutGet(GLUT_ELAPSED_TIME);
    if (time - timebase > 1000) {
        sprintf(s,"FPS:%4.2f",
                frame*1000.0/(time-timebase));
        timebase = time;
        frame = 0;
    }
    
    glColor3f(0.0f,0.0f,0.0f);
    
    glPushMatrix();
    glLoadIdentity();
    setOrthographicProjection();
    glTranslatef(100.0f, 150, 0.0f);
    renderBitmapString(5,30,0,GLUT_BITMAP_HELVETICA_18,s);
    glPopMatrix();
    restorePerspectiveProjection();
    
    glutSwapBuffers();
    
}
Exemplo n.º 30
0
//------------------------------------------------------------------------------
void GimpactConcaveDemo::renderme()
{
	updateCamera();


	btScalar m[16];

	if (m_dynamicsWorld)
	{
		btVector3	worldBoundsMin,worldBoundsMax;
		getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);


		int numObjects = m_dynamicsWorld->getNumCollisionObjects();
		btVector3 wireColor(1,0,0);
		for (int i=0;i<numObjects;i++)
		{
			btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
			btRigidBody* body = btRigidBody::upcast(colObj);

			if (body && body->getMotionState())
			{
				btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
				myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
			} else
			{
				colObj->getWorldTransform().getOpenGLMatrix(m);
			}

			btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation
			if (i & 1)
			{
				wireColor = btVector3(0.f,0.0f,1.f);
			}
			///color differently for active, sleeping, wantsdeactivation states
			if (colObj->getActivationState() == 1) //active
			{
				if (i & 1)
				{
					wireColor += btVector3 (0.8f,0.1f,0.1f);
				} else
				{
					wireColor += btVector3 (0.5f,0.f,0.f);
				}
			}
			if (colObj->getActivationState() == 2) //ISLAND_SLEEPING
			{
				if (i & 1)
				{
					wireColor += btVector3 (0.5f,0.8f, 0.5f);
				} else
				{
					wireColor += btVector3 (0.f,0.5f,0.f);
				}
			}

			m_shapeDrawer->drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
		}


			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,"mouse to interact");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

		/*	glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"space to reset");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
		*/
			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"cursor keys and z,x to navigate");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"i to toggle simulation, s single step");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"q to quit");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,". to shoot TRIMESH (dot)");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			// not yet hooked up again after refactoring...

/*			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"d to toggle deactivation");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
*/

		/*
			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"a to draw temporal AABBs");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;
		*/

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"h to toggle help text");
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			//bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP);

			bool useCCD = ((getDebugMode() & btIDebugDraw::DBG_EnableCCD) != 0);

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			glRasterPos3f(xOffset,yStart,0);
			sprintf(buf,"+- shooting speed = %10.2f",m_ShootBoxInitialSpeed);
			GLDebugDrawString(xOffset,yStart,buf);
			yStart += yIncr;

			#ifdef SHOW_NUM_DEEP_PENETRATIONS
				
				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"gNumDeepPenetrationChecks = %d",gNumDeepPenetrationChecks);
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;

				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"gNumSplitImpulseRecoveries= %d",gNumSplitImpulseRecoveries);
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;

				


				glRasterPos3f(xOffset,yStart,0);
				sprintf(buf,"gNumGjkChecks= %d",gNumGjkChecks);
				GLDebugDrawString(xOffset,yStart,buf);
				yStart += yIncr;

			#endif //SHOW_NUM_DEEP_PENETRATIONS


			resetPerspectiveProjection();


	}

}