[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49665] branches/soc-2012-swiss_cheese/ source/gameengine: gpuMatrix clean up in GE: Removed glMatrix calls, removed unnecessary matrix commits, converted gluProject to gpuProject

Alexander Kuznetsov kuzsasha at gmail.com
Tue Aug 7 18:47:27 CEST 2012


Revision: 49665
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49665
Author:   alexk
Date:     2012-08-07 16:47:27 +0000 (Tue, 07 Aug 2012)
Log Message:
-----------
gpuMatrix clean up in GE: Removed glMatrix calls, removed unnecessary matrix commits, converted gluProject to gpuProject

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Camera.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Dome.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

Modified: branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp	2012-08-07 16:37:54 UTC (rev 49664)
+++ branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp	2012-08-07 16:47:27 UTC (rev 49665)
@@ -158,14 +158,12 @@
 	DisableForText();
 	glDisable(GL_DEPTH_TEST);
 
-	//glMatrixMode(GL_PROJECTION);
 	gpuMatrixMode(GL_PROJECTION);
 
 	gpuPushMatrix();
 
 	gpuLoadOrtho(0, (float)width, 0, (float)height, -100, 100); gpuMatrixCommit();
 
-	glMatrixMode(GL_MODELVIEW);
 	gpuMatrixMode(GL_MODELVIEW);
 
 	gpuPushMatrix();
@@ -175,11 +173,9 @@
 	gpuCurrentColor3x(CPACK_WHITE);
 	BLF_draw_default((float)xco, (float)(height-yco), 0.0f, (char *)text, 65535); /* XXX, use real len */
 
-	//glMatrixMode(GL_PROJECTION);
 	gpuMatrixMode(GL_PROJECTION);
 
-	gpuPopMatrix(); gpuMatrixCommit();
-	glMatrixMode(GL_MODELVIEW);
+	gpuPopMatrix();
 	gpuMatrixMode(GL_MODELVIEW);
 
 	gpuPopMatrix(); gpuMatrixCommit();
@@ -194,14 +190,12 @@
 	DisableForText();
 	glDisable(GL_DEPTH_TEST);
 
-	//glMatrixMode(GL_PROJECTION);
 	gpuMatrixMode(GL_PROJECTION);
 	
 	gpuPushMatrix();
 	
 	gpuLoadOrtho(0, (float)width, 0, (float)height, -100, 100); gpuMatrixCommit();
 	
-	glMatrixMode(GL_MODELVIEW);
 	gpuMatrixMode(GL_MODELVIEW);
 
 	gpuPushMatrix();
@@ -213,11 +207,9 @@
 	gpuCurrentColor3x(CPACK_WHITE);
 	BLF_draw_default((float)xco, (float)(height-yco), 0.0f, text, 65535); /* XXX, use real len */
 
-	//glMatrixMode(GL_PROJECTION);
 	gpuMatrixMode(GL_PROJECTION);
 
-	gpuPopMatrix(); gpuMatrixCommit();
-	glMatrixMode(GL_MODELVIEW);
+	gpuPopMatrix();
 	gpuMatrixMode(GL_MODELVIEW);
 
 	gpuPopMatrix(); gpuMatrixCommit();

Modified: branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp	2012-08-07 16:37:54 UTC (rev 49664)
+++ branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp	2012-08-07 16:47:27 UTC (rev 49665)
@@ -177,7 +177,6 @@
 		resultnormal[0],resultnormal[1],resultnormal[2], 0,
 				0,              0,              0, 1};
 	gpuTranslate(resultpoint[0],resultpoint[1],resultpoint[2]);
-	//glMultMatrixd(oglmatrix);
 	gpuMultMatrix(maat); gpuMatrixCommit();
 	return true;
 }
@@ -270,7 +269,7 @@
 			if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
 			{
 				// couldn't find something to cast the shadow on...
-				glMultMatrixd(oglmatrix);
+				gpuMultMatrixd(oglmatrix);
 			}
 			else
 			{ // we found the "ground", but the cast matrix doesn't take

Modified: branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp	2012-08-07 16:37:54 UTC (rev 49664)
+++ branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp	2012-08-07 16:47:27 UTC (rev 49665)
@@ -76,12 +76,12 @@
 //  void GPC_Canvas::InitPostRenderingContext(void)
 //  {
 //  	glViewport(0, 0, m_width, m_height);
-//  	glMatrixMode(GL_PROJECTION);
+//  	gpuMatrixMode(GL_PROJECTION);
 //  	gpuLoadIdentity();
 	
 //  	gpuOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); gpuMatrixCommit();
 
-//  	glMatrixMode(GL_MODELVIEW);
+//  	gpuMatrixMode(GL_MODELVIEW);
 //  	gpuLoadIdentity(); gpuMatrixCommit();
 
 //  	glEnable(GL_DEPTH_TEST);
@@ -343,11 +343,11 @@
 ) {
 #if 0
 
-	::glMatrixMode(GL_PROJECTION);
+	::gpuMatrixMode(GL_PROJECTION);
 	::gpuPushMatrix();
-	::glMatrixMode(GL_MODELVIEW);
+	::gpuMatrixMode(GL_MODELVIEW);
 	::gpuPushMatrix();
-	::glMatrixMode(GL_TEXTURE);
+	::gpuMatrixMode(GL_TEXTURE);
 	::gpuPushMatrix();
 	// Save old OpenGL settings
 	::glGetIntegerv(GL_LIGHTING, (GLint*)&(render_state.oldLighting));
@@ -383,12 +383,12 @@
 
 	::gpuCurrentColor4fv(render_state.oldColor);
 	// Restore OpenGL matrices
-	::glMatrixMode(GL_TEXTURE);
+	::gpuMatrixMode(GL_TEXTURE);
+	::gpuPopMatrix();
+	::gpuMatrixMode(GL_PROJECTION);
+	::gpuPopMatrix();
+	::gpuMatrixMode(GL_MODELVIEW);
 	::gpuPopMatrix(); gpuMatrixCommit();
-	::glMatrixMode(GL_PROJECTION);
-	::gpuPopMatrix(); gpuMatrixCommit();
-	::glMatrixMode(GL_MODELVIEW);
-	::gpuPopMatrix(); gpuMatrixCommit();
 
 #else
 
@@ -403,16 +403,14 @@
 	// Set up OpenGL matrices 
 	::glViewport(0, 0, m_width, m_height);
 	::glScissor(0, 0, m_width, m_height);
-	//::glMatrixMode(GL_PROJECTION);
 	gpuMatrixMode(GL_PROJECTION);
 
 	::gpuLoadOrtho(0, m_width, 0, m_height, -1, 1); gpuMatrixCommit();
-	//::glMatrixMode(GL_MODELVIEW);
 	gpuMatrixMode(GL_MODELVIEW);
 
+	::gpuLoadIdentity();
+	::gpuMatrixMode(GL_TEXTURE);
 	::gpuLoadIdentity(); gpuMatrixCommit();
-	::glMatrixMode(GL_TEXTURE);
-	::gpuLoadIdentity(); gpuMatrixCommit();
 }
 
 	void

Modified: branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp	2012-08-07 16:37:54 UTC (rev 49664)
+++ branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp	2012-08-07 16:47:27 UTC (rev 49665)
@@ -180,7 +180,6 @@
 		resultnormal[0],resultnormal[1],resultnormal[2], 0,
 				0,              0,              0, 1};
 	gpuTranslate(resultpoint[0],resultpoint[1],resultpoint[2]);
-	//glMultMatrixd(oglmatrix);
 	gpuMultMatrix(maat); gpuMatrixCommit();
 
 	gpuMatrixCommit();
@@ -275,7 +274,7 @@
 			if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
 			{
 				// couldn't find something to cast the shadow on...
-				glMultMatrixd(oglmatrix);
+				gpuMultMatrixd(oglmatrix);
 			}
 		} else
 		{
@@ -366,12 +365,10 @@
 
 	
 	// Set up viewing settings
-	//glMatrixMode(GL_PROJECTION);
 	gpuMatrixMode(GL_PROJECTION);
 
 	gpuPushMatrix();
-	gpuLoadOrtho(0, width, 0, height, -1, 1); gpuMatrixCommit();
-	glMatrixMode(GL_MODELVIEW);
+	gpuLoadOrtho(0, width, 0, height, -1, 1);
 	gpuMatrixMode(GL_MODELVIEW);
 
 	gpuPushMatrix();
@@ -387,12 +384,10 @@
 	gpuCurrentColor3x(CPACK_WHITE);
 	BLF_draw_default(xco, height-yco, 0.f, text, 65536);
 
-	// Restore view settings
-	//glMatrixMode(GL_PROJECTION);
+	// Restore view settings;
 	gpuMatrixMode(GL_PROJECTION);
 
-	gpuPopMatrix(); gpuMatrixCommit();
-	glMatrixMode(GL_MODELVIEW);
+	gpuPopMatrix();
 	gpuMatrixMode(GL_MODELVIEW);
 
 	gpuPopMatrix(); gpuMatrixCommit();

Modified: branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp	2012-08-07 16:37:54 UTC (rev 49664)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp	2012-08-07 16:47:27 UTC (rev 49665)
@@ -403,11 +403,10 @@
 	if (GLEW_ARB_multitexture)
 		glActiveTextureARB(GL_TEXTURE0_ARB+mUnit);
 
-	//glMatrixMode(GL_TEXTURE);
 	gpuMatrixMode(GL_TEXTURE);
-	gpuLoadIdentity(); gpuMatrixCommit();
-	glMatrixMode(GL_MODELVIEW);
+	gpuLoadIdentity();
 	gpuMatrixMode(GL_MODELVIEW);
+	gpuMatrixCommit();
 
 
 	if (GLEW_ARB_texture_cube_map && glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
@@ -432,12 +431,11 @@
 		if (GLEW_ARB_multitexture)
 			glActiveTextureARB(GL_TEXTURE0_ARB+i);
 
-		//glMatrixMode(GL_TEXTURE);
 		gpuMatrixMode(GL_TEXTURE);
 
-		gpuLoadIdentity(); gpuMatrixCommit();
-		glMatrixMode(GL_MODELVIEW);
+		gpuLoadIdentity();
 		gpuMatrixMode(GL_MODELVIEW);
+		gpuMatrixCommit();
 
 		glDisable(GL_TEXTURE_2D);	
 		glDisable(GL_TEXTURE_GEN_S);

Modified: branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp	2012-08-07 16:37:54 UTC (rev 49664)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp	2012-08-07 16:47:27 UTC (rev 49665)
@@ -660,10 +660,9 @@
 
 void KX_BlenderMaterial::setTexMatrixData(int i)
 {
-	glMatrixMode(GL_TEXTURE);
 	gpuMatrixMode(GL_TEXTURE);
 
-	gpuLoadIdentity(); gpuMatrixCommit();
+	gpuLoadIdentity();
 
 	if ( GLEW_ARB_texture_cube_map && 
 		mTextures[i].GetTextureType() == GL_TEXTURE_CUBE_MAP_ARB && 
@@ -688,9 +687,8 @@
 		mMaterial->mapping[i].offsets[2]
 	);
 
-	gpuMatrixCommit();
-	glMatrixMode(GL_MODELVIEW);
 	gpuMatrixMode(GL_MODELVIEW);
+	gpuMatrixCommit();
 
 
 }
@@ -737,10 +735,9 @@
 
 	const MT_Matrix4x4& mvmat = ras->GetViewMatrix();
 
-	glMatrixMode(GL_TEXTURE);
 	gpuMatrixMode(GL_TEXTURE);
 
-	gpuLoadIdentity(); gpuMatrixCommit();
+	gpuLoadIdentity();
 	gpuScale(
 		mMaterial->mapping[i].scale[0], 
 		mMaterial->mapping[i].scale[1], 
@@ -754,7 +751,6 @@
 	gpuTranslate( (float)(-t[0]), (float)(-t[1]), (float)(-t[2]) );
 
 	gpuMatrixCommit();
-	glMatrixMode(GL_MODELVIEW);
 	gpuMatrixMode(GL_MODELVIEW);
 
 

Modified: branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Camera.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Camera.cpp	2012-08-07 16:37:54 UTC (rev 49664)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Camera.cpp	2012-08-07 16:47:27 UTC (rev 49665)
@@ -31,7 +31,7 @@
  */
 
  
-#include <GL/glew.h>
+#include "GPU_compatibility.h"
 #include "KX_Camera.h"
 #include "KX_Scene.h"
 #include "KX_PythonInit.h"
@@ -957,10 +957,12 @@
 	}
 
 	const GLint *viewport;
-	GLdouble win[3];
-	GLdouble modelmatrix[16];
-	GLdouble projmatrix[16];
+	GLfloat win[3];
+	GLfloat modelmatrix[16];
+	GLfloat projmatrix[16];
+	GLfloat vectf[3] = {vect[0], vect[1], vect[2]};
 
+
 	MT_Matrix4x4 m_modelmatrix = this->GetModelviewMatrix();
 	MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
 
@@ -969,7 +971,7 @@
 
 	viewport = KX_GetActiveEngine()->GetCanvas()->GetViewPort();
 
-	gluProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]);
+	gpuProject(vectf, (GLfloat (*)[4])modelmatrix, (GLfloat (*)[4])projmatrix, viewport, win);
 
 	vect[0] =  (win[0] - viewport[0]) / viewport[2];
 	vect[1] =  (win[1] - viewport[1]) / viewport[3];
@@ -1000,9 +1002,9 @@
 	MT_Point3 campos, screenpos;
 
 	const GLint *viewport;
-	GLdouble win[3];
-	GLdouble modelmatrix[16];

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list