void d3d_set_projection_ortho(gs_scalar x, gs_scalar y, gs_scalar width, gs_scalar height, gs_scalar angle)
{
    // This fixes font glyph edge artifacting and vertical scroll gaps
    // seen by mostly NVIDIA GPU users.  Rounds x and y and adds +0.01 offset.
    // This will prevent the fix from being negated through moving projections
    // and fractional coordinates.
    x = round(x) + 0.01f; y = round(y) + 0.01f;
	if (angle!=0){
		enigma::projection_matrix.InitTranslationTransform(-x-width/2.0, -y-height/2.0, 0);
		enigma::projection_matrix.rotateZ(-angle);
		enigma::projection_matrix.translate(x+width/2.0, y+height/2.0, 0);
	}else{
		enigma::projection_matrix.InitIdentity();
	}

    enigma::Matrix4 ortho;
    ortho.InitOrthoProjTransform(x,x + width,y + height,y,32000,-32000);

    enigma::projection_matrix = ortho * enigma::projection_matrix;
    enigma::view_matrix.InitIdentity();

    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;

    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(enigma::projection_matrix);

    glMatrixMode(GL_MODELVIEW);
    glLoadMatrix(enigma::mv_matrix);

    enigma::d3d_light_update_positions();
}
void d3d_transform_set_rotation_axis(gs_scalar x, gs_scalar y, gs_scalar z, gs_scalar angle)
{
    enigma::model_matrix.InitIdentity();
    enigma::model_matrix.rotate(-angle, x, y, z);
    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;
    glLoadMatrix(enigma::mv_matrix);
}
void d3d_set_projection(gs_scalar xfrom, gs_scalar yfrom, gs_scalar zfrom, gs_scalar xto, gs_scalar yto, gs_scalar zto, gs_scalar xup, gs_scalar yup, gs_scalar zup)
{
    (enigma::d3dHidden?glEnable:glDisable)(GL_DEPTH_TEST);
    enigma::projection_matrix.InitPersProjTransform(45, -view_wview[view_current] / (gs_scalar)view_hview[view_current], 1, 32000);
    enigma::view_matrix.InitCameraTransform(enigma::Vector3(xfrom,yfrom,zfrom),enigma::Vector3(xto,yto,zto),enigma::Vector3(xup,yup,zup));

    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;

    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(enigma::projection_matrix);

    glMatrixMode(GL_MODELVIEW);
    glLoadMatrix(enigma::mv_matrix);

    enigma::d3d_light_update_positions();
}
void CalibrationCheckTool::display(GLContextData& contextData) const
	{
	if(haveDepthPoint)
		{
		glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT);
		glDisable(GL_LIGHTING);
		glLineWidth(1.0f);
		
		/* Go to navigation coordinates: */
		glPushMatrix();
		const Vrui::DisplayState& displayState=Vrui::getDisplayState(contextData);
		glLoadMatrix(displayState.modelviewNavigational);
		
		glBegin(GL_LINES);
		glColor3f(0.0f,0.333f,0.0f);
		
		/* Draw the depth-image point: */
		glVertex3d(depthPoint[0],0.0,0.01);
		glVertex3d(depthPoint[0],480.0,0.01);
		glVertex3d(-640.0,depthPoint[1],0.01);
		glVertex3d(0.0,depthPoint[1],0.01);
		
		/* Draw the color-image point: */
		glVertex3d(colorPoint[0],0.0,0.01);
		glVertex3d(colorPoint[0],480.0,0.01);
		glVertex3d(0.0,colorPoint[1],0.01);
		glVertex3d(640.0,colorPoint[1],0.01);
		glEnd();
		
		glPopMatrix();
		
		glPopAttrib();
		}
	}
Exemple #5
0
	virtual void display() {
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				
		glMatrixMode(GL_MODELVIEW);
		
		matrix4x4 transform = matrix4x4::translation(matrix3x1(0, 0, -5));
		glLoadMatrix(transform);
		glMultMatrix(matrix4x4::rotationY(rotation._3));
		
		texture->bind(0);
		
		if (glGetError() != GL_NO_ERROR) {
			std::cout << "TestTexture::display() - error 5: " << glGetError() << std::endl;
			running = false;
		}
		
		glBegin(GL_QUADS);
		glTexCoord2f(0, 0);
		glVertex3f(-1, 1, 0);
		glTexCoord2f(1, 0);
		glVertex3f(1, 1, 0);
		glTexCoord2f(1,1);
		glVertex3f(1,-1, 0);
		glTexCoord2f(0, 1);
		glVertex3f(-1,-1,0);
		glEnd();
	}
bool d3d_transform_stack_top()
{
    if (trans_stack_size == 0) return false;
    enigma::model_matrix = trans_stack.top();
    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;
    glLoadMatrix(enigma::mv_matrix);
    return true;
}
void d3d_transform_stack_clear()
{
    trans_stack = std::stack<enigma::Matrix4>();
    trans_stack_size = 0;
    enigma::model_matrix.InitIdentity();
    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;
    glLoadMatrix(enigma::mv_matrix);
}
bool d3d_projection_stack_top()
{
    if (proj_stack_size == 0) return false;
    enigma::projection_matrix = proj_stack.top();
    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(enigma::projection_matrix);
    glMatrixMode(GL_MODELVIEW);
    return true;
}
void d3d_projection_stack_clear()
{
    proj_stack = std::stack<enigma::Matrix4>();
    proj_stack_size = 0;
    enigma::projection_matrix.InitIdentity();
    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(enigma::projection_matrix);
    glMatrixMode(GL_MODELVIEW);
}
void d3d_set_projection_ext(gs_scalar xfrom, gs_scalar yfrom, gs_scalar zfrom, gs_scalar xto, gs_scalar yto, gs_scalar zto, gs_scalar xup, gs_scalar yup, gs_scalar zup, gs_scalar angle, gs_scalar aspect, gs_scalar znear, gs_scalar zfar)
{
    if (angle == 0 || znear == 0) return; //THEY CANNOT BE 0!!!
    (enigma::d3dHidden?glEnable:glDisable)(GL_DEPTH_TEST);

    enigma::projection_matrix.InitPersProjTransform(angle, -aspect, znear, zfar);

    enigma::view_matrix.InitCameraTransform(enigma::Vector3(xfrom,yfrom,zfrom),enigma::Vector3(xto,yto,zto),enigma::Vector3(xup,yup,zup));

    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;

    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(enigma::projection_matrix);

    glMatrixMode(GL_MODELVIEW);
    glLoadMatrix(enigma::mv_matrix);

    enigma::d3d_light_update_positions();
}
void glLoadMatrix(const Geometry::ProjectiveTransformation<ScalarParam,3>& t)
{
    /* Copy the transformation coefficients into a temporary array: */
    ScalarParam temp[16];
    const typename Geometry::ProjectiveTransformation<ScalarParam,3>::Matrix& m=t.getMatrix();
    ScalarParam* tPtr=temp;
    for(int j=0;j<4;++j)
        for(int i=0;i<4;++i,++tPtr)
            *tPtr=m(i,j);
    
    /* Upload the temporary array: */
    glLoadMatrix(temp);
}
void Minigun::draw2Self()
{
	glPushMatrix();
	glLoadMatrix( world()->modelViewMatrix() );

	// particles on impact
	glEnable( GL_TEXTURE_2D );
	mImpactParticleMaterial->bind();
	mImpactParticles->draw( world()->modelViewMatrix() );
	mImpactParticleMaterial->release();

	glPopMatrix();
}
Exemple #13
0
void Eye::applyGL()
{
	mProjectionMatrix.setToIdentity();
	mProjectionMatrix.translate( -mPerspectiveOffset );
	mProjectionMatrix.perspective( mFOV, mAspect, mNearPlane, mFarPlane );

	mViewMatrixInverse.setToIdentity();
	mViewMatrixInverse.translate( mPosition );
	mViewMatrixInverse.rotate( mRotation );
	mViewMatrixInverse.rotate( 180.0f, QVector3D( 0, 1, 0 ) );
	mViewMatrixInverse.translate( mViewOffset );
	mViewMatrixInverse.scale( mScale );
	mViewMatrix = mViewMatrixInverse.inverted();

	glMatrixMode( GL_PROJECTION );
	glLoadMatrix( mProjectionMatrix );

	glMatrixMode( GL_MODELVIEW );
	glLoadMatrix( mViewMatrix );

	applyClippingPlanes();
}
void d3d_set_perspective(bool enable)
{
    if (enable) {
      enigma::projection_matrix.InitPersProjTransform(45, -view_wview[view_current] / (gs_scalar)view_hview[view_current], 1, 32000);
    } else {
      //projection_matrix.InitPersProjTransform(0, 1, 0, 1); //they cannot be zeroes!
    }
    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(enigma::projection_matrix);
    glMatrixMode(GL_MODELVIEW);
  // Unverified note: Perspective not the same as in GM when turning off perspective and using d3d projection
  // Unverified note: GM has some sort of dodgy behaviour where this function doesn't affect anything when calling after d3d_set_projection_ext
  // See also OpenGL3/GL3d3d.cpp Direct3D9/DX9d3d.cpp OpenGL1/GLd3d.cpp
}
	void render() {

		matrix4x4 model = rigidBody.transform();
		matrix4x4 view = matrix4x4::translation(0, 0, 5.0f);
		
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		matrix4x4 modelView = view * model;
		glLoadMatrix(modelView.transpose());
		
		renderCube();
	}
Exemple #16
0
//
// Main drawing function. Renders a completed scene to the screen.
//
void Renderer::drawScene(Scene& scene, Camera& camera)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | 
      GL_STENCIL_BUFFER_BIT);

  // Load the viewing translations.
  resize(global.winWidth, global.winHeight);
  glLoadMatrix(camera.getWorldToCamMatrix());

  // Unlit scene + Depth Buffer info.
  ambientPass(scene, camera);

  // Only enter this loop if ambient only is not enabled.
  if (!global.drawAmbientOnly)
  {
    // The rest of the rendering is done on a 'per-light' basis, shadows are
    // determined for each light and the scene is additively illuminated.
  	for (int i = 0; i < scene.lights.size(); ++i)
  	{
  	  if (i >= global.maxVisibleLights) break;

  	  Light& light = scene.lights[i];
  	  
      // Setup the light for drawing and draw it.
      setupLight(light);
      if (global.drawPointLights)
        drawLight(light);

      // Determine shadows and light the scene.
      if (global.drawShadows)
      {
        determineShadows(scene.casters, light, camera);
      }
      
      // Iluminate the scene fro this light.
      illuminationPass(scene, camera);

	glClear(GL_STENCIL_BUFFER_BIT);
  	}
  	
    scene.dirtyAllCasters();
	}

	// Check for OpenGL errors.
	int er = glGetError();
	if (er) printf("%s\n", gluErrorString(er));
}
void d3d_set_projection_perspective(gs_scalar x, gs_scalar y, gs_scalar width, gs_scalar height, gs_scalar angle)
{
    enigma::projection_matrix.InitRotateZTransform(angle);

    enigma::Matrix4 persp, ortho;
    persp.InitPersProjTransform(60, 1, 0.1,32000);
    ortho.InitOrthoProjTransform(x,x + width,y,y + height,0.1,32000);

    enigma::projection_matrix = enigma::projection_matrix * persp * ortho;

    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(enigma::projection_matrix);

    glMatrixMode(GL_MODELVIEW);

    enigma::d3d_light_update_positions();
}
METHODPREFIX
void
glLoadMatrix(
	const Geometry::AffineTransformation<ScalarParam,3>& t)
	{
	/* Copy the transformation coefficients into a temporary array: */
	ScalarParam temp[16];
	const typename Geometry::AffineTransformation<ScalarParam,3>::Matrix& m=t.getMatrix();
	ScalarParam* tPtr=temp;
	for(int j=0;j<4;++j)
		{
		for(int i=0;i<3;++i,++tPtr)
			*tPtr=m(i,j);
		*tPtr=ScalarParam(0);
		++tPtr;
		}
	temp[15]=ScalarParam(1);
	
	/* Upload the temporary array: */
	glLoadMatrix(temp);
	}
void KinectViewer::display(GLContextData& contextData) const
	{
	if(!enabled)
		return;
	
	if(navigational)
		{
		/* Go to navigational coordinates: */
		glPushMatrix();
		glLoadMatrix(Vrui::getDisplayState(contextData).modelviewNavigational);
		}
	
	/* Draw the current 3D video facades of all renderers: */
	for(std::vector<Renderer*>::const_iterator rIt=renderers.begin();rIt!=renderers.end();++rIt)
		(*rIt)->glRenderAction(contextData);
	
	if(navigational)
		{
		/* Go back to physical coordinates: */
		glPopMatrix();
		}
	}
void DemoEntityManager::RenderFrame ()
{
	dTimeTrackerEvent(__FUNCTION__);

	// Make context current
	if (m_mainWindow->m_suspendVisualUpdates) {
		return;
	}

	dFloat timestep = dGetElapsedSeconds();	
	m_mainWindow->CalculateFPS(timestep);

	// update the the state of all bodies in the scene
	unsigned64 time0 = dGetTimeInMicrosenconds ();
	UpdatePhysics(timestep);
	unsigned64 time1 = dGetTimeInMicrosenconds ();
	m_mainThreadPhysicsTime = dFloat ((time1 - time0) / 1000.0f);

	// Get the interpolated location of each body in the scene
	m_cameraManager->InterpolateMatrices (this, CalculateInteplationParam());

	// Our shading model--Goraud (smooth). 
	glShadeModel (GL_SMOOTH);

	// Culling. 
	glCullFace (GL_BACK);
	glFrontFace (GL_CCW);
	glEnable (GL_CULL_FACE);

	//	glEnable(GL_DITHER);

	// z buffer test
	glEnable(GL_DEPTH_TEST);
	glDepthFunc (GL_LEQUAL);

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);

	glClearColor (0.5f, 0.5f, 0.5f, 0.0f );
	//glClear( GL_COLOR_BUFFER_BIT );
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


	// set default lightning
	//	glDisable(GL_BLEND);
	glEnable (GL_LIGHTING);

	// make sure the model view matrix is set to identity before setting world space ligh sources
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	dFloat cubeColor[] = { 1.0f, 1.0f, 1.0f, 1.0 };
	glMaterialParam(GL_FRONT, GL_SPECULAR, cubeColor);
	glMaterialParam(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cubeColor);
	glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	// one light form the Camera eye point
	GLfloat lightDiffuse0[] = { 0.5f, 0.5f, 0.5f, 0.0 };
	GLfloat lightAmbient0[] = { 0.0f, 0.0f, 0.0f, 0.0 };
	dVector camPosition (m_cameraManager->GetCamera()->m_matrix.m_posit);
	GLfloat lightPosition0[] = {camPosition.m_x, camPosition.m_y, camPosition.m_z};

	glLightfv(GL_LIGHT0, GL_POSITION, lightPosition0);
	glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient0);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse0);
	glLightfv(GL_LIGHT0, GL_SPECULAR, lightDiffuse0);
	glEnable(GL_LIGHT0);


	// set just one directional light
	GLfloat lightDiffuse1[] = { 0.7f, 0.7f, 0.7f, 0.0 };
	GLfloat lightAmbient1[] = { 0.2f, 0.2f, 0.2f, 0.0 };
	GLfloat lightPosition1[] = { -500.0f, 200.0f, 500.0f, 0.0 };

	glLightfv(GL_LIGHT1, GL_POSITION, lightPosition1);
	glLightfv(GL_LIGHT1, GL_AMBIENT, lightAmbient1);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse1);
	glLightfv(GL_LIGHT1, GL_SPECULAR, lightDiffuse1);
	glEnable(GL_LIGHT1);

	// update Camera
	m_cameraManager->GetCamera()->SetViewMatrix(GetWidth(), GetHeight());

	// render all entities
	if (m_mainWindow->m_hideVisualMeshes) {
		if (m_sky) {
			glPushMatrix();	
			m_sky->Render(timestep, this);
			glPopMatrix();
		}

	} else {
		for (dListNode* node = dList<DemoEntity*>::GetFirst(); node; node = node->GetNext()) {
			DemoEntity* const entity = node->GetInfo();
			glPushMatrix();	
			entity->Render(timestep, this);
			glPopMatrix();
		}
	}

	if (m_tranparentHeap.GetCount()) {
		dMatrix modelView;
		glGetFloat (GL_MODELVIEW_MATRIX, &modelView[0][0]);
		while (m_tranparentHeap.GetCount()) {
			const TransparentMesh& transparentMesh = m_tranparentHeap[0];
			glLoadIdentity();
			glLoadMatrix(&transparentMesh.m_matrix[0][0]);
			transparentMesh.m_mesh->RenderTransparency();
			m_tranparentHeap.Pop();
		}
		glLoadMatrix(&modelView[0][0]);
	}


	m_cameraManager->RenderPickedTarget ();

	if (m_mainWindow->m_showContactPoints) {
		RenderContactPoints (GetNewton());
	}

	if (m_mainWindow->m_showNormalForces) {
		RenderNormalForces (GetNewton());
	}

	if (m_mainWindow->m_showNormalForces) {
//	if (1) {
		// see if there is a vehicle controller and 
		void* const vehListerNode = NewtonWorldGetPreListener(GetNewton(), VEHICLE_PLUGIN_NAME);
		if (vehListerNode) {
			CustomVehicleControllerManager* const manager = (CustomVehicleControllerManager*)NewtonWorldGetListenerUserData(GetNewton(), vehListerNode);
			manager->Debug();
		}

		void* const characterListerNode = NewtonWorldGetPreListener(GetNewton(), PLAYER_PLUGIN_NAME);
		if (characterListerNode) {
			CustomPlayerControllerManager* const manager = (CustomPlayerControllerManager*)NewtonWorldGetListenerUserData(GetNewton(), characterListerNode);
			manager->Debug();
		}
	}



	if (m_mainWindow->m_showAABB) {
		RenderAABB (GetNewton());
	}

	if (m_mainWindow->m_showCenterOfMass) {
		RenderCenterOfMass (GetNewton());
	}

	if (m_mainWindow->m_showJoints) {
		RenderJointsDebugInfo (GetNewton(), 0.5f);
	}


   DEBUG_DRAW_MODE mode = m_solid;
   if (m_mainWindow->m_debugDisplayMode) {
      mode = (m_mainWindow->m_debugDisplayMode == 1) ? m_solid : m_lines;
      DebugRenderWorldCollision (GetNewton(), mode);
   }

	if (m_mainWindow->m_showStatistics) {
		dVector color (1.0f, 1.0f, 1.0f, 0.0f);
		Print (color, 10,  20, "render fps: %7.2f", m_mainWindow->m_fps);
		Print (color, 10,  42, "physics time on main thread: %7.2f ms", GetPhysicsTime() * 1000.0f);
		Print (color, 10,  64, "total memory: %d kbytes", NewtonGetMemoryUsed() / (1024));
		Print (color, 10,  86, "number of bodies: %d", NewtonWorldGetBodyCount(GetNewton()));
		Print (color, 10, 108, "number of threads: %d", NewtonGetThreadsCount(GetNewton()));
		Print (color, 10, 130, "auto sleep: %s", m_mainWindow->m_autoSleepState ? "on" : "off");
	}

	int lineNumber = 130 + 22;

	if (m_renderHood) {

		// set display for 2d render mode

		dFloat width = GetWidth();
		dFloat height = GetHeight();

		glColor3f(1.0, 1.0, 1.0);

		glPushMatrix();
		glMatrixMode(GL_PROJECTION);

		glLoadIdentity();
		gluOrtho2D(0, width, 0, height);
		
			glPushMatrix();
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();

			glDisable(GL_LIGHTING);
			glDisable(GL_DEPTH_TEST);
			glEnable(GL_TEXTURE_2D);	

			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

			// render 2d display
			m_renderHood (this, m_renderHoodContext, lineNumber);

			// restore display mode
			glMatrixMode(GL_PROJECTION);
			glPopMatrix();


		glMatrixMode(GL_MODELVIEW);
		glPopMatrix();
	}


	// draw everything and swap the display buffer
	glFlush();

	// Swap
	SwapBuffers();
}
Exemple #21
0
void GLView::paintEvent( QPaintEvent * event )
{
	makeCurrent();

	QPainter painter;
	painter.begin( this );
	painter.setRenderHint( QPainter::TextAntialiasing );
#else
void GLView::paintGL()
{
#endif
	

	// Save GL state
	glPushAttrib( GL_ALL_ATTRIB_BITS );
	glMatrixMode( GL_PROJECTION );
	glPushMatrix();
	glMatrixMode( GL_MODELVIEW );
	glPushMatrix();

	// Clear Viewport
	if ( scene->visMode & Scene::VisSilhouette ) {
		qglClearColor( QColor( 255, 255, 255, 255 ) );
	}
	//glViewport( 0, 0, width(), height() );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
	
	
	// Compile the model
	if ( doCompile ) {
		textures->setNifFolder( model->getFolder() );
		scene->make( model );
		scene->transform( Transform(), scene->timeMin() );
		axis = (scene->bounds().radius <= 0) ? 1024.0 : scene->bounds().radius;

		if ( scene->timeMin() != scene->timeMax() ) {
			if ( time < scene->timeMin() || time > scene->timeMax() )
				time = scene->timeMin();

			emit sequencesUpdated();

		} else if ( scene->timeMax() == 0 ) {
			// No Animations in this NIF
			emit sequencesDisabled( true );
		}
		emit sceneTimeChanged( time, scene->timeMin(), scene->timeMax() );
		doCompile = false;
	}

	// Center the model
	if ( doCenter ) {
		setCenter();
		doCenter = false;
	}

	// Transform the scene
	Matrix ap;

	// TODO: Redo for new Settings class
	//if ( Options::upAxis() == Options::YAxis ) {
	//	ap( 0, 0 ) = 0; ap( 0, 1 ) = 0; ap( 0, 2 ) = 1;
	//	ap( 1, 0 ) = 1; ap( 1, 1 ) = 0; ap( 1, 2 ) = 0;
	//	ap( 2, 0 ) = 0; ap( 2, 1 ) = 1; ap( 2, 2 ) = 0;
	//} else if ( Options::upAxis() == Options::XAxis ) {
	//	ap( 0, 0 ) = 0; ap( 0, 1 ) = 1; ap( 0, 2 ) = 0;
	//	ap( 1, 0 ) = 0; ap( 1, 1 ) = 0; ap( 1, 2 ) = 1;
	//	ap( 2, 0 ) = 1; ap( 2, 1 ) = 0; ap( 2, 2 ) = 0;
	//}

	Transform viewTrans;
	viewTrans.rotation.fromEuler( Rot[0] / 180.0 * PI, Rot[1] / 180.0 * PI, Rot[2] / 180.0 * PI );
	viewTrans.rotation = viewTrans.rotation * ap;
	viewTrans.translation = viewTrans.rotation * Pos;

	if ( view != ViewWalk )
		viewTrans.translation[2] -= Dist * 2;

	scene->transform( viewTrans, time );

	// Setup projection mode
	glProjection();
	glLoadIdentity();

	// Draw the grid
	if ( scene->options & Scene::ShowAxes ) {
		glDisable( GL_ALPHA_TEST );
		glDisable( GL_BLEND );
		glDisable( GL_LIGHTING );
		glDisable( GL_COLOR_MATERIAL );
		glEnable( GL_DEPTH_TEST );
		glDepthMask( GL_TRUE );
		glDepthFunc( GL_LESS );
		glDisable( GL_TEXTURE_2D );
		glDisable( GL_NORMALIZE );
		glLineWidth( 2.0f );

		glPushMatrix();
		glLoadMatrix( viewTrans );

		// TODO: Configurable grid in Settings
		// 1024 game units, major lines every 128, minor lines every 64
		drawGrid( 1024, 128, 2 );

		glPopMatrix();
	}

#ifndef QT_NO_DEBUG
	// Debug scene bounds
	glEnable( GL_DEPTH_TEST );
	glDepthMask( GL_TRUE );
	glDepthFunc( GL_LESS );
	glPushMatrix();
	glLoadMatrix( viewTrans );
	if ( debugMode == DbgBounds ) {
		BoundSphere bs = scene->bounds();
		bs |= BoundSphere( Vector3(), axis );
		drawSphere( bs.center, bs.radius );
	}
	glPopMatrix();
#endif

	GLfloat mat_spec[] = { 0.0f, 0.0f, 0.0f, 1.0f };

	if ( scene->options & Scene::DoLighting ) {
		// Setup light
		Vector4 lightDir( 0.0, 0.0, 1.0, 0.0 );

		if ( !frontalLight ) {
			float decl = declination / 180.0 * PI;
			Vector3 v( sin( decl ), 0, cos( decl ) );
			Matrix m; m.fromEuler( 0, 0, planarAngle / 180.0 * PI );
			v = m * v;
			lightDir = Vector4( viewTrans.rotation * v, 0.0 );

			if ( scene->visMode & Scene::VisLightPos ) {
				glEnable( GL_BLEND );
				glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
				glEnable( GL_DEPTH_TEST );
				glDepthMask( GL_TRUE );
				glDepthFunc( GL_LESS );

				glPushMatrix();
				glLoadMatrix( viewTrans );

				glLineWidth( 2.0f );
				glColor4f( 1.0f, 1.0f, 1.0f, 0.5f );

				// Scale the distance a bit
				float l = axis + 64.0;
				l = (l < 128) ? axis * 1.5 : l;
				l = (l > 2048) ? axis * 0.66 : l;
				l = (l > 1024) ? axis * 0.75 : l;

				drawDashLine( Vector3( 0, 0, 0 ), v * l, 30 );
				drawSphere( v * l, axis / 10 );
				glPopMatrix();
				glDisable( GL_BLEND );
			}
		}

		float amb = ambient;
		if ( (scene->visMode & Scene::VisNormalsOnly)
			&& (scene->options & Scene::DoTexturing)
			&& !(scene->options & Scene::DisableShaders) )
		{
			amb = 0.1f;
		}
		
		GLfloat mat_amb[] = { amb, amb, amb, 1.0f };
		GLfloat mat_diff[] = { brightness, brightness, brightness, 1.0f };
		

		glShadeModel( GL_SMOOTH );
		glEnable( GL_LIGHTING );
		glEnable( GL_LIGHT0 );
		glLightfv( GL_LIGHT0, GL_AMBIENT, mat_amb );
		glLightfv( GL_LIGHT0, GL_DIFFUSE, mat_diff );
		glLightfv( GL_LIGHT0, GL_SPECULAR, mat_diff );
		glLightfv( GL_LIGHT0, GL_POSITION, lightDir.data() );

		// Necessary?
		glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
	} else {
		float amb = 0.5f;
		if ( scene->options & Scene::DisableShaders ) {
			amb = 0.0f;
		}

		GLfloat mat_amb[] = { amb, amb, amb, 1.0f };
		GLfloat mat_diff[] = { 1.0f, 1.0f, 1.0f, 1.0f };
		

		glShadeModel( GL_SMOOTH );
		glEnable( GL_LIGHTING );
		glEnable( GL_LIGHT0 );
		glLightfv( GL_LIGHT0, GL_AMBIENT, mat_amb );
		glLightfv( GL_LIGHT0, GL_DIFFUSE, mat_diff );
		glLightfv( GL_LIGHT0, GL_SPECULAR, mat_spec );
	}

	if ( scene->visMode & Scene::VisSilhouette ) {
		GLfloat mat_diff[] = { 0.0f, 0.0f, 0.0f, 1.0f };
		GLfloat mat_amb[] = { 0.0f, 0.0f, 0.0f, 1.0f };

		glShadeModel( GL_FLAT );
		glEnable( GL_LIGHTING );
		glEnable( GL_LIGHT0 );
		glLightModelfv( GL_LIGHT_MODEL_AMBIENT, mat_diff );
		glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_diff );
		glLightfv( GL_LIGHT0, GL_AMBIENT, mat_amb );
		glLightfv( GL_LIGHT0, GL_DIFFUSE, mat_diff );
		glLightfv( GL_LIGHT0, GL_SPECULAR, mat_spec );
	}

	if ( scene->options & Scene::DoMultisampling )
		glEnable( GL_MULTISAMPLE_ARB );

#ifndef QT_NO_DEBUG
	// Color Key debug
	if ( debugMode == DbgColorPicker ) {
		glDisable( GL_MULTISAMPLE );
		glDisable( GL_LINE_SMOOTH );
		glDisable( GL_TEXTURE_2D );
		glDisable( GL_BLEND );
		glDisable( GL_DITHER );
		glDisable( GL_LIGHTING );
		glShadeModel( GL_FLAT );
		glDisable( GL_FOG );
		glDisable( GL_MULTISAMPLE_ARB );
		glEnable( GL_DEPTH_TEST );
		glDepthFunc( GL_LEQUAL );
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
		Node::SELECTING = 1;
	} else {
		Node::SELECTING = 0;
	}
#endif

	// Draw the model
	scene->draw();

	if ( scene->options & Scene::ShowAxes ) {
		// Resize viewport to small corner of screen
		int axesSize = std::min( width() / 10, 125 );
		glViewport( 0, 0, axesSize, axesSize );

		// Reset matrices
		glMatrixMode( GL_PROJECTION );
		glLoadIdentity();

		// Square frustum
		auto nr = 1.0;
		auto fr = 250.0;
		GLdouble h2 = tan( FOV / 360 * M_PI ) * nr;
		GLdouble w2 = h2;
		glFrustum( -w2, +w2, -h2, +h2, nr, fr );

		// Reset matrices
		glMatrixMode( GL_MODELVIEW );
		glLoadIdentity();

		glPushMatrix();

		// Store and reset viewTrans translation
		auto viewTransOrig = viewTrans.translation;

		// Zoom out slightly
		viewTrans.translation = { 0, 0, -150.0 };

		// Load modified viewTrans
		glLoadMatrix( viewTrans );

		// Restore original viewTrans translation
		viewTrans.translation = viewTransOrig;

		// Find direction of axes
		auto vtr = viewTrans.rotation;
		QVector<float> axesDots = { vtr( 2, 0 ), vtr( 2, 1 ), vtr( 2, 2 ) };

		drawAxesOverlay( { 0, 0, 0 }, 50.0, sortAxes( axesDots ) );

		glPopMatrix();

		// Restore viewport size
		glViewport( 0, 0, width(), height() );
		// Restore matrices
		glProjection();
	}

	// Restore GL state
	glPopAttrib();
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();
	glMatrixMode( GL_PROJECTION );
	glPopMatrix();

	// Check for errors
	GLenum err;
	while ( ( err = glGetError() ) != GL_NO_ERROR )
		qDebug() << tr( "glview.cpp - GL ERROR (paint): " ) << (const char *)gluErrorString( err );

	emit paintUpdate();

	// Manually handle the buffer swap
	swapBuffers();

#ifdef USE_GL_QPAINTER
	painter.end();
#endif
}
Exemple #22
0
void DepthBuffer::renderMeshGL()
{
    uint W = _pCamera->W();
    uint H = _pCamera->H();
    ncv::GlXOffscreenContextPtr context(new ncv::GlXOffscreenContext(W, H));

    context->makeActive();
    // Should be able to use openGL here..

    glViewport(0,0,W,H);
    glDisable(GL_LIGHTING);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glLoadMatrix(_pCamera->getProjectionMatrix(_zMin, _zMax));

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glLoadMatrix(_pCamera->getModelViewMatrix());

    glEnable(GL_DEPTH_TEST);

    glClearDepth(1.0f);
    glDepthFunc(GL_LEQUAL);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Draw mesh..
    drawMeshGL();

    glFlush();

    double P[16];
    glGetDoublev(GL_PROJECTION_MATRIX, P);
    
    float a = - Map<Matrix4d>(P)(2,2);
    float b = - Map<Matrix4d>(P)(2,3);
    
    MatrixXfRow depthBuffer(H,W);
    MatrixXfRow depthBufferReverse(H,W);
    //    MatrixXfRow depthBufferReverseTest(H,W);
    glReadPixels(0, 0, W, H, GL_DEPTH_COMPONENT, GL_FLOAT, depthBuffer.data());
    depthBufferReverse = depthBuffer.colwise().reverse();
    
    for_each(depthBufferReverse.data(), depthBufferReverse.data() + W*H, DepthConverter(a,b));
    _depthBufferMin = depthBufferReverse;

    // output depth data to txt file
    // std::ofstream depthBufferFile;
    // depthBufferFile.open("/cs/research/vision/humanis3/Rui/data/newsequence_3_19/photo_metric/depthBuffer.txt",
    //     std::ofstream::trunc);
    // depthBufferFile << _depthBufferMin << endl;

    // // render again to get the maximum depth
    // glClearDepth(0.0f);
    // glDepthFunc(GL_GEQUAL);
    // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // drawMeshGL();

    // glFlush();

    // glReadPixels(0, 0, W, H, GL_DEPTH_COMPONENT, GL_FLOAT, depthBuffer.data());
    // depthBufferReverse = depthBuffer.colwise().reverse();
    // for_each(depthBufferReverse.data(), depthBufferReverse.data() + W*H, DepthConverter(a,b));
    // _depthBufferMax = depthBufferReverse;
    
}
	bool initialize() {

		// setup projection
		matrix4x4 projection = matrix4x4::projection(1.0f, 1000.0f, math::halfPif(), math::halfPif());
		glMatrixMode(GL_PROJECTION);
		glLoadMatrix(projection.transpose());

		// setup lights
		GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
		GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };;
		GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
		GLfloat mat_shininess[] = { 5.0 };
		
		glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
		glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
		glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
		
		glClearColor (0.0, 0.0, 0.0, 0.0);
		glClearDepth(1.0f);
		glShadeModel (GL_SMOOTH);
		
		glEnable(GL_LIGHTING);
		glEnable(GL_LIGHT0);
		glEnable(GL_LIGHT1);
		glEnable(GL_LIGHT2);

		GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
		GLfloat light0_diffuse[] = { 0.0, 0.0, 1.0, 1.0 };
		GLfloat light1_diffuse[] = { 0.0, 1.0, 0.0, 1.0 };
		GLfloat light2_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };

		GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
		GLfloat light0_position[] = { 3.0, -1.0, -5.0, 0.0 };
		GLfloat light1_position[] = {-3.0, 1.0, -5.0, 0.0 };
		GLfloat light2_position[] = { 0.0, 0.0, -5.0, 0.0 };
		
		glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
		glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
		glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
		glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
		
		glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
		glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
		glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
		glLightfv(GL_LIGHT1, GL_POSITION, light1_position);

		glLightfv(GL_LIGHT2, GL_AMBIENT, light_ambient);
		glLightfv(GL_LIGHT2, GL_DIFFUSE, light2_diffuse);
		glLightfv(GL_LIGHT2, GL_SPECULAR, light_specular);
		glLightfv(GL_LIGHT2, GL_POSITION, light2_position);

		glEnable(GL_DEPTH_TEST);

		glDisable(GL_CULL_FACE);

		// initialize textures
		glEnable(GL_TEXTURE_2D);
		try {
			render::Texture *texture = textureLibrary.load("../../media/textures/surfaces/bricks-high-res.jpg");
			if (texture && texture->good()) {
				texture->bind();
			}
		}
		catch (std::runtime_error &e) {
			std::cout << "Failed to load texture - no textures will be used. Error: " << e.what() << std::endl;
		}
		return true;
	}
void QueryBenchmarks::internalInit( unsigned int contextID, osg::RenderInfo* ri )
{
    double width, height;
    if( ( ri != NULL ) && ( ri->getCurrentCamera() != NULL ) )
    {
        const osg::Viewport* vp = ri->getCurrentCamera()->getViewport();
        width = vp->width();
        height = vp->height();
    }
    else
    {
        width = 1024.;
        height = 768.;
    }

    // This is the only state setup we do:
    glMatrixMode( GL_PROJECTION );
    glLoadMatrix( osg::Matrixf::ortho( 0., width, 0., height, -1., 1. ).ptr() );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    osg::ref_ptr< osg::Geometry > geom = new osg::Geometry;
    osg::Vec3Array* v = new osg::Vec3Array;
    osg::DrawElementsUInt* deui = new osg::DrawElementsUInt( GL_TRIANGLE_STRIP, width * 2. );

    geom->setUseDisplayList( false );
    geom->setUseVertexBufferObjects( true );
    geom->setVertexArray( v );
    geom->addPrimitiveSet( deui );

    //
    // Measure setup time for normal rendering.

    unsigned int numVerts = 4;
    v->resize( numVerts );
    osg::Vec3* vert = &( (*v)[0] );
    unsigned int* index = &( (*deui)[0] );
    unsigned int idx;
    for( idx=0; idx<(numVerts / 2); idx++ )
    {
        vert->set( idx, 3., 0. );
        vert++;
        *index++ = idx * 2;
        vert->set( idx, 1., 0. );
        vert++;
        *index++ = idx * 2 + 1;
    }


    time( geom.get(), *ri );
    double t = time( geom.get(), *ri );
    _trSetup = t;

    //
    // Measure setup time for occlusion queries.

    osgwQuery::QueryAPI* qapi = osgwQuery::getQueryAPI( contextID );

    time( geom.get(), *ri, qapi );
    t = time( geom.get(), *ri, qapi );
    _toSetup = t;


    //
    // Measure triangle time for normal rendering.

    geom = new osg::Geometry;
    v = new osg::Vec3Array;
    deui = new osg::DrawElementsUInt( GL_TRIANGLE_STRIP, width * 2. );

    geom->setUseDisplayList( false );
    geom->setUseVertexBufferObjects( true );
    geom->setVertexArray( v );
    geom->addPrimitiveSet( deui );

    numVerts = (unsigned int)( width ) * 2;
    v->resize( numVerts );
    vert = &( (*v)[0] );
    index = &( (*deui)[0] );
    for( idx=0; idx<(numVerts / 2); idx++ )
    {
        vert->set( idx, 3., 0. );
        vert++;
        *index++ = idx * 2;
        vert->set( idx, 1., 0. );
        vert++;
        *index++ = idx * 2 + 1;
    }

    time( geom.get(), *ri );
    t = time( geom.get(), *ri );
    if( t < _trSetup )
    {
        osg::notify( osg::WARN ) << "QueryBenchmarks: Suspicious timing result for _trTriangle." << std::endl;
        _trTriangle = ( _trSetup ) / (double)( numVerts - 2 );
    }
    else
        _trTriangle = ( t - _trSetup ) / (double)( numVerts - 2 );


    //
    // Measure fragment time for normal rendering.

    geom = new osg::Geometry;
    v = new osg::Vec3Array;
    deui = new osg::DrawElementsUInt( GL_TRIANGLE_STRIP, width * 2. );

    geom->setUseDisplayList( false );
    geom->setUseVertexBufferObjects( true );
    geom->setVertexArray( v );
    geom->addPrimitiveSet( deui );

    numVerts = 4;
    v->resize( numVerts );
    vert = &( (*v)[0] );
    index = &( (*deui)[0] );
    {
        vert->set( 0., 0., 0. );
        vert++;
        *index++ = 0;
        vert->set( width, 0., 0. );
        vert++;
        *index++ = 1;
        vert->set( 0., height, 0. );
        vert++;
        *index++ = 2;
        vert->set( width, height, 0. );
        vert++;
        *index++ = 3;
    }

    time( geom.get(), *ri );
    t = time( geom.get(), *ri );
    if( t < _trSetup )
    {
        osg::notify( osg::WARN ) << "QueryBenchmarks: Suspicious timing result for _trFragment." << std::endl;
        _trFragment = ( _trSetup ) / ( width * height );
    }
    else
        _trFragment = ( t - _trSetup ) / ( width * height );

    //
    // Measure fragment time for occlusion queries.

    time( geom.get(), *ri, qapi );
    t = time( geom.get(), *ri, qapi );
    if( t < _toSetup )
    {
        osg::notify( osg::WARN ) << "QueryBenchmarks: Suspicious timing result for _toFragment." << std::endl;
        _toFragment = ( _toSetup ) / ( width * height );
    }
    else
        _toFragment = ( t - _toSetup ) / ( width * height );


    // TBD
    _toLatency = 1.; // Used to determine if Group children should be inserted. Not possible in OSG.
    _toOverhead = 1.; // Guthe doesn't appear to describe how to measure this, or how it is used in his algorithm.
}
	inline void begin( const QMatrix4x4 & modelView )
		{ glPushMatrix(); glLoadMatrix( matrix( modelView ) ); }
Exemple #26
0
void MapTool::
display(GLContextData& contextData) const
{
    Shape*& curShape = crusta->getMapManager()->getActiveShape(toolId);
    if (curShape==NULL || curShape->getControlPoints().size()<1)
        return;

    GLint activeTexture;
    glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture);
    GLdouble depthRange[2];
    glGetDoublev(GL_DEPTH_RANGE, depthRange);

    glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POINT_BIT);

    glDisable(GL_LIGHTING);
    glActiveTexture(GL_TEXTURE0);
    glDisable(GL_TEXTURE_2D);
    glDepthRange(0.0, 0.0);

    //compute the centroids
    Geometry::Point<double,3> centroid(0);
    const Shape::ControlPointList& controlPoints = curShape->getControlPoints();
    std::vector<Geometry::Point<double,3> > cps;
    for (Shape::ControlPointList::const_iterator it=controlPoints.begin();
         it!=controlPoints.end(); ++it)
    {
        cps.push_back(crusta->mapToScaledGlobe(it->pos));
        const Geometry::Point<double,3>& cp = cps.back();
        for (int i=0; i<3; ++i)
            centroid[i] += cp[i];
    }
    int numPoints = static_cast<int>(cps.size());
    double norm = 1.0 / numPoints;
    for (int i=0; i<3; ++i)
        centroid[i] *= norm;

    glPushMatrix();

    Vrui::Vector centroidTranslation(centroid[0], centroid[1],
                                     centroid[2]);
    Vrui::NavTransform nav =
        Vrui::getDisplayState(contextData).modelviewNavigational;
    nav *= Vrui::NavTransform::translate(centroidTranslation);
    glLoadMatrix(nav);

    //draw the control points of the current shape
    glPointSize(4.0f);
    glColor3f(0.3f, 0.5f, 1.0f);
    glBegin(GL_POINTS);
    for (int i=0; i<numPoints; ++i)
    {
        glVertex3f(cps[i][0] - centroid[0],
                   cps[i][1] - centroid[1],
                   cps[i][2] - centroid[2]);
    }
    glEnd();

    //draw the current control element
    glLineWidth(5.0);
    glPointSize(6.0);

    if (curControl != Shape::BAD_ID)
    {
        switch (curControl.type)
        {
            case Shape::CONTROL_POINT:
            {
                Geometry::Point<double,3> p = curControl.handle->pos;
                p        = crusta->mapToScaledGlobe(p);

                glColor3f(0.3f, 0.9f, 0.5f);
                glBegin(GL_POINTS);
                glVertex3f(p[0]-centroid[0],p[1]-centroid[1],p[2]-centroid[2]);
                glEnd();

                break;
            }

            case Shape::CONTROL_SEGMENT:
            {
                Shape::ControlId si = curShape->previousControl(curControl);
                Geometry::Point<double,3> s            = si.handle->pos;
                s                   = crusta->mapToScaledGlobe(s);
                Shape::ControlId ei = curShape->nextControl(curControl);
                Geometry::Point<double,3> e            = ei.handle->pos;
                e                   = crusta->mapToScaledGlobe(e);

                glColor3f(0.3f, 0.9f, 0.5f);
                glBegin(GL_LINES);
                glVertex3f(s[0]-centroid[0],s[1]-centroid[1],s[2]-centroid[2]);
                glVertex3f(e[0]-centroid[0],e[1]-centroid[1],e[2]-centroid[2]);
                glEnd();

                break;
            }

            default:
                break;
        }
    }

    glPopMatrix();
    glPopAttrib();
    glDepthRange(depthRange[0], depthRange[1]);
    glActiveTexture(activeTexture);
}
inline void glLoadMatrix( const QMatrix4x4 & m )	{ glLoadMatrix( m.constData() ); }
void d3d_transform_set_translation(gs_scalar xt, gs_scalar yt, gs_scalar zt)
{
    enigma::model_matrix.InitTranslationTransform(xt, yt, zt);
    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;
    glLoadMatrix(enigma::mv_matrix);
}
void d3d_transform_set_scaling(gs_scalar xs, gs_scalar ys, gs_scalar zs)
{
    enigma::model_matrix.InitScaleTransform(xs, ys, zs);
    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;
    glLoadMatrix(enigma::mv_matrix);
}
void d3d_transform_set_rotation_z(gs_scalar angle)
{
    enigma::model_matrix.InitRotateZTransform(-angle);
    enigma::mv_matrix = enigma::view_matrix * enigma::model_matrix;
    glLoadMatrix(enigma::mv_matrix);
}