[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47850] branches/soc-2012-swiss_cheese/ source/gameengine: Convirting GE to the new matrix stack manager.
Alexander Kuznetsov
kuzsasha at gmail.com
Wed Jun 13 21:51:36 CEST 2012
Revision: 47850
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47850
Author: alexk
Date: 2012-06-13 19:51:31 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
Convirting GE to the new matrix stack manager.
Still, there is some clean up to do like remove glMatrixMode (because stack needs to be in correct matrix mode for old stack code)
Also, most gpuOrtho must be replaced with gpuLoadOrtho
This commit also contains GLES code for shaders, which later will be better integrated.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
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/Converter/BL_BlenderDataConversion.cpp
branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.h
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_Dome.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Scene.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/CMakeLists.txt
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/SConscript
Modified: branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp 2012-06-13 19:43:09 UTC (rev 47849)
+++ branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp 2012-06-13 19:51:31 UTC (rev 47850)
@@ -40,7 +40,12 @@
#pragma warning (disable:4786)
#endif
+#ifdef GLES
+#include <GLES2/gl2.h>
+#include FAKE_GL_MODE
+#endif
#include <GL/glew.h>
+#include <stdio.h>
#include "KX_BlenderGL.h"
#include "KX_BlenderCanvas.h"
Modified: branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp 2012-06-13 19:43:09 UTC (rev 47849)
+++ branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp 2012-06-13 19:51:31 UTC (rev 47850)
@@ -43,6 +43,8 @@
#include <stdlib.h>
#include <string.h>
+
+#include "GPU_matrix.h"
#include <GL/glew.h>
#include "MEM_guardedalloc.h"
@@ -158,24 +160,31 @@
DisableForText();
glDisable(GL_DEPTH_TEST);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
+ //glMatrixMode(GL_PROJECTION);
+ gpuMatrixMode(GPU_PROJECTION);
- glOrtho(0, width, 0, height, -100, 100);
+ gpuPushMatrix();
+ gpuLoadOrtho(0, width, 0, height, -100, 100); gpuMatrixCommit();
+
glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ gpuMatrixMode(GPU_MODELVIEW);
+ gpuPushMatrix();
+ gpuLoadIdentity(); gpuMatrixCommit();
+
/* the actual drawing */
glColor3ub(255, 255, 255);
BLF_draw_default((float)xco, (float)(height-yco), 0.0f, (char *)text, 65535); /* XXX, use real len */
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
+ //glMatrixMode(GL_PROJECTION);
+ gpuMatrixMode(GPU_PROJECTION);
+
+ gpuPopMatrix(); gpuMatrixCommit();
glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GPU_MODELVIEW);
+
+ gpuPopMatrix(); gpuMatrixCommit();
glEnable(GL_DEPTH_TEST);
}
@@ -187,26 +196,33 @@
DisableForText();
glDisable(GL_DEPTH_TEST);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
+ //glMatrixMode(GL_PROJECTION);
+ gpuMatrixMode(GPU_PROJECTION);
+
+ gpuPushMatrix();
- glOrtho(0, width, 0, height, -100, 100);
+ gpuLoadOrtho(0, width, 0, height, -100, 100); gpuMatrixCommit();
glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ gpuMatrixMode(GPU_MODELVIEW);
+ gpuPushMatrix();
+ gpuLoadIdentity(); gpuMatrixCommit();
+
/* draw in black first*/
glColor3ub(0, 0, 0);
BLF_draw_default((float)(xco+2), (float)(height-yco-2), 0.0f, text, 65535); /* XXX, use real len */
glColor3ub(255, 255, 255);
BLF_draw_default((float)xco, (float)(height-yco), 0.0f, text, 65535); /* XXX, use real len */
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
+ //glMatrixMode(GL_PROJECTION);
+ gpuMatrixMode(GPU_PROJECTION);
+
+ gpuPopMatrix(); gpuMatrixCommit();
glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GPU_MODELVIEW);
+
+ gpuPopMatrix(); gpuMatrixCommit();
glEnable(GL_DEPTH_TEST);
}
Modified: branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp 2012-06-13 19:43:09 UTC (rev 47849)
+++ branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp 2012-06-13 19:51:31 UTC (rev 47850)
@@ -29,8 +29,12 @@
* \ingroup blroutines
*/
-
+#ifdef GLES
+#include <GLES2/gl2.h>
+#include FAKE_GL_MODE
+#endif
#include <GL/glew.h>
+#include <stdio.h>
#include "RAS_IRenderTools.h"
#include "RAS_IRasterizer.h"
@@ -50,6 +54,7 @@
#include "STR_String.h"
#include "GPU_draw.h"
+#include "GPU_matrix.h"
#include "KX_BlenderGL.h" // for text printing
#include "KX_BlenderRenderTools.h"
@@ -58,6 +63,11 @@
KX_BlenderRenderTools::KX_BlenderRenderTools()
{
+#include REAL_GL_MODE
+//glClearColor(1.0f,1.0f,1.0f,0.0f);
+//glClear(GL_COLOR_BUFFER_BIT);
+#include FAKE_GL_MODE
+ printf("Done\n");
glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights);
if (m_numgllights < 8)
m_numgllights = 8;
@@ -74,6 +84,8 @@
m_lastauxinfo = NULL;
m_lastlighting = true; /* force disable in DisableOpenGLLights() */
DisableOpenGLLights();
+
+
}
void KX_BlenderRenderTools::EndFrame(RAS_IRasterizer* rasty)
@@ -164,14 +176,14 @@
left = (dir.cross(resultnormal)).safe_normalized();
// for the up vector, we take the 'resultnormal' returned by the physics
- double maat[16]={
+ float maat[16]={
left[0], left[1], left[2], 0,
dir[0], dir[1], dir[2], 0,
resultnormal[0],resultnormal[1],resultnormal[2], 0,
0, 0, 0, 1};
- glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
+ gpuTranslate(resultpoint[0],resultpoint[1],resultpoint[2]);
//glMultMatrixd(oglmatrix);
- glMultMatrixd(maat);
+ gpuMultMatrix(maat); gpuMatrixCommit();
return true;
}
@@ -227,13 +239,13 @@
left *= size[0];
dir *= size[1];
up *= size[2];
- double maat[16]={
+ float maat[16]={
left[0], left[1],left[2], 0,
dir[0], dir[1],dir[2],0,
up[0],up[1],up[2],0,
0,0,0,1};
- glTranslated(objpos[0],objpos[1],objpos[2]);
- glMultMatrixd(maat);
+ gpuTranslate(objpos[0],objpos[1],objpos[2]);
+ gpuMultMatrix(maat); gpuMatrixCommit();
} else
{
@@ -269,15 +281,20 @@
{ // we found the "ground", but the cast matrix doesn't take
// scaling in consideration, so we must apply the object scale
MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
- glScalef(size[0], size[1], size[2]);
+ gpuScale(size[0], size[1], size[2]);
}
} else
{
-
+ float fm[16];
// 'normal' object
- glMultMatrixd(oglmatrix);
+ for(int i =0; i<16;i++)
+ fm[i]=oglmatrix[i];
+ // 'normal' object
+ gpuMultMatrix(fm);
+ gpuMatrixCommit();
}
}
+ gpuMatrixCommit();
}
void KX_BlenderRenderTools::RenderText3D(int fontid,
const char* text,
@@ -333,12 +350,12 @@
void KX_BlenderRenderTools::PushMatrix()
{
- glPushMatrix();
+ gpuPushMatrix();
}
void KX_BlenderRenderTools::PopMatrix()
{
- glPopMatrix();
+ gpuPopMatrix(); gpuMatrixCommit();
}
@@ -355,8 +372,8 @@
viewmat.getValue(glviewmat);
- glPushMatrix();
- glLoadMatrixf(glviewmat);
+ gpuPushMatrix();
+ gpuLoadMatrix(glviewmat); gpuMatrixCommit();
for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
{
RAS_LightObject* lightdata = (*lit);
@@ -365,7 +382,7 @@
if (kxlight->ApplyLight(kxscene, objectlayer, count))
count++;
}
- glPopMatrix();
+ gpuPopMatrix(); gpuMatrixCommit();
return count;
}
Modified: branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp 2012-06-13 19:43:09 UTC (rev 47849)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp 2012-06-13 19:51:31 UTC (rev 47850)
@@ -1021,6 +1021,10 @@
/* first is the BL_Material */
if (!bl_mat)
bl_mat = new BL_Material();
+
+ /* XXX fix me. Temp work around*/
+ if(!ma)
+ ma= &defmaterial;
ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol,
layers, converter->GetGLSLMaterials());
@@ -1204,7 +1208,11 @@
}
int nverts = (mface->v4)? 4: 3;
+#ifdef GLES
+ RAS_Polygon *poly = meshobj->AddPolygon(bucket, 3);
+#else
RAS_Polygon *poly = meshobj->AddPolygon(bucket, nverts);
+#endif
poly->SetVisible(visible);
poly->SetCollider(collider);
@@ -1216,7 +1224,25 @@
meshobj->AddVertex(poly,2,pt2,uvs[2],tan2,rgb2,no2,flat,mface->v3);
if (nverts==4)
+ #ifndef GLES
meshobj->AddVertex(poly,3,pt3,uvs[3],tan3,rgb3,no3,flat,mface->v4);
+ #else
+ {
+ RAS_Polygon *poly = meshobj->AddPolygon(bucket, 3);
+
+ poly->SetVisible(visible);
+ poly->SetCollider(collider);
+ poly->SetTwoside(twoside);
+
+ meshobj->AddVertex(poly,0,pt2,uvs[2],tan2,rgb2,no2,flat,mface->v3);
+
+ meshobj->AddVertex(poly,1,pt3,uvs[3],tan3,rgb3,no3,flat,mface->v4);
+ meshobj->AddVertex(poly,2,pt0,uvs[0],tan0,rgb0,no0,flat,mface->v1);
+
+
+ }
+ #endif
+
}
if (tface)
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-06-13 19:43:09 UTC (rev 47849)
+++ branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp 2012-06-13 19:51:31 UTC (rev 47850)
@@ -29,6 +29,9 @@
* \ingroup player
*/
+#ifdef GLES
+#include <GLES2/gl2.h>
+#endif
#ifndef NOPNG
#ifdef WIN32
@@ -70,12 +73,12 @@
// {
// glViewport(0, 0, m_width, m_height);
// glMatrixMode(GL_PROJECTION);
-// glLoadIdentity();
+// gpuLoadIdentity();
-// glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
+// gpuOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); gpuMatrixCommit();
// glMatrixMode(GL_MODELVIEW);
-// glLoadIdentity();
+// gpuLoadIdentity(); gpuMatrixCommit();
// glEnable(GL_DEPTH_TEST);
@@ -105,7 +108,9 @@
void GPC_Canvas::ClearColor(float r, float g, float b, float a)
{
+#include REAL_GL_MODE
::glClearColor(r,g,b,a);
+#include FAKE_GL_MODE
}
void GPC_Canvas::SetViewPort(int x1, int y1, int x2, int y2)
@@ -120,10 +125,12 @@
* but where... definitely need to clean up this
* whole canvas/rendertools mess.
*/
+#include REAL_GL_MODE
glEnable(GL_SCISSOR_TEST);
glViewport(x1,y1,x2-x1 + 1,y2-y1 + 1);
glScissor(x1,y1,x2-x1 + 1,y2-y1 + 1);
+#include FAKE_GL_MODE
};
@@ -136,8 +143,9 @@
ogltype |= GL_COLOR_BUFFER_BIT;
if (type & RAS_ICanvas::DEPTH_BUFFER )
ogltype |= GL_DEPTH_BUFFER_BIT;
-
+#include REAL_GL_MODE
::glClear(ogltype);
+#include FAKE_GL_MODE
}
@@ -322,11 +330,11 @@
#if 0
::glMatrixMode(GL_PROJECTION);
- ::glPushMatrix();
+ ::gpuPushMatrix();
::glMatrixMode(GL_MODELVIEW);
- ::glPushMatrix();
+ ::gpuPushMatrix();
::glMatrixMode(GL_TEXTURE);
- ::glPushMatrix();
+ ::gpuPushMatrix();
// Save old OpenGL settings
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list