Sfoglia il codice sorgente

Removing non GL 3.3 core functions

Panagiotis Christopoulos Charitos 15 anni fa
parent
commit
2ed6f3dce5
6 ha cambiato i file con 64 aggiunte e 87 eliminazioni
  1. 2 2
      src/Misc/skybox.cpp
  2. 3 23
      src/Renderer/Renderer.cpp
  3. 0 13
      src/Renderer/Renderer.h
  4. 32 20
      src/Resources/Mesh.cpp
  5. 17 21
      src/Resources/Mesh.h
  6. 10 8
      src/Ui/Ui.cpp

+ 2 - 2
src/Misc/skybox.cpp

@@ -54,7 +54,7 @@ render
 */
 void Skybox::Render(const Mat3& rotation)
 {
-	glDisable(GL_DEPTH_TEST);
+	/*glDisable(GL_DEPTH_TEST);
 	glDisable(GL_BLEND);
 
 	glPushMatrix();
@@ -93,5 +93,5 @@ void Skybox::Render(const Mat3& rotation)
 		glEnd();
 	}
 
-	glPopMatrix();
+	glPopMatrix();*/
 }

+ 3 - 23
src/Renderer/Renderer.cpp

@@ -259,26 +259,6 @@ void Renderer::setupMaterial(const Material& mtl, const SceneNode& sceneNode, co
 }
 
 
-//======================================================================================================================
-// setProjectionMatrix                                                                                                 =
-//======================================================================================================================
-void Renderer::setProjectionMatrix(const Camera& cam)
-{
-	glMatrixMode(GL_PROJECTION);
-	loadMatrix(cam.getProjectionMatrix());
-}
-
-
-//======================================================================================================================
-// setViewMatrix                                                                                                       =
-//======================================================================================================================
-void Renderer::setViewMatrix(const Camera& cam)
-{
-	glMatrixMode(GL_MODELVIEW);
-	loadMatrix(cam.getViewMatrix());
-}
-
-
 //======================================================================================================================
 // unproject                                                                                                           =
 //======================================================================================================================
@@ -290,9 +270,9 @@ Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat, con
 
 	// the vec is in NDC space meaning: -1<=vec.x<=1 -1<=vec.y<=1 -1<=vec.z<=1
 	Vec4 vec;
-	vec.x = (2.0*(windowCoords.x-view[0]))/view[2] - 1.0;
-	vec.y = (2.0*(windowCoords.y-view[1]))/view[3] - 1.0;
-	vec.z = 2.0*windowCoords.z - 1.0;
+	vec.x = (2.0 * (windowCoords.x - view[0])) / view[2] - 1.0;
+	vec.y = (2.0 * (windowCoords.y - view[1])) / view[3] - 1.0;
+	vec.z = 2.0 * windowCoords.z - 1.0;
 	vec.w = 1.0;
 
 	Vec4 final = invPm * vec;

+ 0 - 13
src/Renderer/Renderer.h

@@ -117,19 +117,6 @@ class Renderer: public Object
 	private:
 		static Vbo* quadPositionsVbo; ///< The VBO for quad positions
 		static Vao* globalVao; ///< This VAO is used everywhere
-
-	// to be removed
-	public:
-		static void color3(const Vec3& v) { glColor3fv(&((Vec3&)v)[0]); } ///< OpenGL wrapper
-		static void color4(const Vec4& v) { glColor4fv(&((Vec4&)v)[0]); } ///< OpenGL wrapper
-		static void setProjectionMatrix(const Camera& cam);
-		static void setViewMatrix(const Camera& cam);
-		static void noShaders() { ShaderProg::unbind(); } ///< unbind shaders @todo remove this. From now on there will be only shaders
-		static void setProjectionViewMatrices(const Camera& cam) { setProjectionMatrix(cam); setViewMatrix(cam); }
-		static void multMatrix(const Mat4& m4) { glMultMatrixf(&(m4.getTransposed())(0, 0)); } ///< OpenGL wrapper
-		static void multMatrix(const Transform& trf) { glMultMatrixf(&(Mat4(trf).getTransposed())(0, 0)); } ///< OpenGL wrapper
-		static void loadMatrix(const Mat4& m4) { glLoadMatrixf(&(m4.getTransposed())(0, 0)); } ///< OpenGL wrapper
-		static void loadMatrix(const Transform& trf) { glLoadMatrixf(&(Mat4(trf).getTransposed())(0, 0)); } ///< OpenGL wrapper
 };
 
 #endif

+ 32 - 20
src/Resources/Mesh.cpp

@@ -64,29 +64,41 @@ void Mesh::load(const char* filename)
 //======================================================================================================================
 void Mesh::createVbos(const MeshData& meshData)
 {
-	vbos.vertIndeces = new Vbo(GL_ELEMENT_ARRAY_BUFFER, meshData.getVertIndeces().getSizeInBytes(),
-	                           &meshData.getVertIndeces()[0], GL_STATIC_DRAW, this);
-	vbos.vertCoords = new Vbo(GL_ARRAY_BUFFER, meshData.getVertCoords().getSizeInBytes(),
-	                          &meshData.getVertCoords()[0], GL_STATIC_DRAW, this);
-	vbos.vertNormals = new Vbo(GL_ARRAY_BUFFER, meshData.getVertNormals().getSizeInBytes(),
-	                           &meshData.getVertNormals()[0], GL_STATIC_DRAW, this);
+	vbos[VBO_VERT_INDECES] = new Vbo(GL_ELEMENT_ARRAY_BUFFER, meshData.getVertIndeces().getSizeInBytes(),
+	                                 &meshData.getVertIndeces()[0], GL_STATIC_DRAW, this);
+	vbos[VBO_VERT_POSITIONS] = new Vbo(GL_ARRAY_BUFFER, meshData.getVertCoords().getSizeInBytes(),
+	                                   &meshData.getVertCoords()[0], GL_STATIC_DRAW, this);
+	vbos[VBO_VERT_NORMALS] = new Vbo(GL_ARRAY_BUFFER, meshData.getVertNormals().getSizeInBytes(),
+	                                 &meshData.getVertNormals()[0], GL_STATIC_DRAW, this);
 
 	if(meshData.getVertTangents().size() > 1)
 	{
-		vbos.vertTangents = new Vbo(GL_ARRAY_BUFFER, meshData.getVertTangents().getSizeInBytes(),
-		                            &meshData.getVertTangents()[0], GL_STATIC_DRAW, this);
+		vbos[VBO_VERT_TANGENTS] = new Vbo(GL_ARRAY_BUFFER, meshData.getVertTangents().getSizeInBytes(),
+		                                  &meshData.getVertTangents()[0], GL_STATIC_DRAW, this);
+	}
+	else
+	{
+		vbos[VBO_VERT_TANGENTS] = NULL;
 	}
 
 	if(meshData.getTexCoords().size() > 1)
 	{
-		vbos.texCoords = new Vbo(GL_ARRAY_BUFFER, meshData.getTexCoords().getSizeInBytes(),
-		                         &meshData.getTexCoords()[0], GL_STATIC_DRAW, this);
+		vbos[VBO_TEX_COORDS] = new Vbo(GL_ARRAY_BUFFER, meshData.getTexCoords().getSizeInBytes(),
+		                               &meshData.getTexCoords()[0], GL_STATIC_DRAW, this);
+	}
+	else
+	{
+		vbos[VBO_TEX_COORDS] = NULL;
 	}
 
 	if(meshData.getVertWeights().size() > 1)
 	{
-		vbos.vertWeights = new Vbo(GL_ARRAY_BUFFER, meshData.getVertWeights().getSizeInBytes(),
-		                           &meshData.getVertWeights()[0], GL_STATIC_DRAW, this);
+		vbos[VBO_VERT_WEIGHTS] = new Vbo(GL_ARRAY_BUFFER, meshData.getVertWeights().getSizeInBytes(),
+		                                 &meshData.getVertWeights()[0], GL_STATIC_DRAW, this);
+	}
+	else
+	{
+		vbos[VBO_VERT_WEIGHTS] = NULL;
 	}
 }
 
@@ -100,47 +112,47 @@ void Mesh::createVao(Vao* vao, Material& mtl)
 
 	if(mtl.stdAttribVars[Material::SAV_POSITION] != NULL)
 	{
-		vao->attachArrayBufferVbo(*vbos.vertCoords, *mtl.stdAttribVars[Material::SAV_POSITION], 3, GL_FLOAT,
+		vao->attachArrayBufferVbo(*vbos[VBO_VERT_POSITIONS], *mtl.stdAttribVars[Material::SAV_POSITION], 3, GL_FLOAT,
 		                          GL_FALSE, 0, NULL);
 	}
 
 	if(mtl.stdAttribVars[Material::SAV_NORMAL] != NULL)
 	{
-		vao->attachArrayBufferVbo(*vbos.vertNormals, *mtl.stdAttribVars[Material::SAV_NORMAL], 3, GL_FLOAT,
+		vao->attachArrayBufferVbo(*vbos[VBO_VERT_NORMALS], *mtl.stdAttribVars[Material::SAV_NORMAL], 3, GL_FLOAT,
 		                          GL_FALSE, 0, NULL);
 	}
 
 	if(mtl.stdAttribVars[Material::SAV_TANGENT] != NULL)
 	{
-		vao->attachArrayBufferVbo(*vbos.vertTangents, *mtl.stdAttribVars[Material::SAV_TANGENT], 4, GL_FLOAT,
+		vao->attachArrayBufferVbo(*vbos[VBO_VERT_TANGENTS], *mtl.stdAttribVars[Material::SAV_TANGENT], 4, GL_FLOAT,
 		                          GL_FALSE, 0, NULL);
 	}
 
 	if(mtl.stdAttribVars[Material::SAV_TEX_COORDS] != NULL)
 	{
-		vao->attachArrayBufferVbo(*vbos.texCoords, *mtl.stdAttribVars[Material::SAV_TEX_COORDS], 2, GL_FLOAT,
+		vao->attachArrayBufferVbo(*vbos[VBO_TEX_COORDS], *mtl.stdAttribVars[Material::SAV_TEX_COORDS], 2, GL_FLOAT,
 		                          GL_FALSE, 0, NULL);
 	}
 
 	if(mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_BONES_NUM] != NULL)
 	{
-		vao->attachArrayBufferVbo(*vbos.vertWeights, *mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_BONES_NUM], 1,
+		vao->attachArrayBufferVbo(*vbos[VBO_VERT_WEIGHTS], *mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_BONES_NUM], 1,
 		                          GL_FLOAT, GL_FALSE, sizeof(MeshData::VertexWeight), BUFFER_OFFSET(0));
 	}
 
 	if(mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_BONE_IDS] != NULL)
 	{
-		vao->attachArrayBufferVbo(*vbos.vertWeights, *mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_BONE_IDS], 4,
+		vao->attachArrayBufferVbo(*vbos[VBO_VERT_WEIGHTS], *mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_BONE_IDS], 4,
 		                          GL_FLOAT, GL_FALSE, sizeof(MeshData::VertexWeight), BUFFER_OFFSET(4));
 	}
 
 	if(mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_WEIGHTS] != NULL)
 	{
-		vao->attachArrayBufferVbo(*vbos.vertWeights, *mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_WEIGHTS], 4,
+		vao->attachArrayBufferVbo(*vbos[VBO_VERT_WEIGHTS], *mtl.stdAttribVars[Material::SAV_VERT_WEIGHT_WEIGHTS], 4,
 		                          GL_FLOAT, GL_FALSE, sizeof(MeshData::VertexWeight), BUFFER_OFFSET(20));
 	}
 
-	vao->attachElementArrayBufferVbo(*vbos.vertIndeces);
+	vao->attachElementArrayBufferVbo(*vbos[VBO_VERT_INDECES]);
 }
 
 

+ 17 - 21
src/Resources/Mesh.h

@@ -17,28 +17,29 @@ class MeshData;
 class Mesh: public Resource, public Object
 {
 	public:
-		/// The VBOs in a structure
-		struct Vbos
+		/// Used in @ref vao array
+		enum Vbos
 		{
-			Vbo* vertCoords;
-			Vbo* vertNormals;
-			Vbo* vertTangents;
-			Vbo* texCoords;
-			Vbo* vertIndeces;
-			Vbo* vertWeights;
-
-			Vbos();
+			VBO_VERT_POSITIONS,
+			VBO_VERT_NORMALS,
+			VBO_VERT_TANGENTS,
+			VBO_TEX_COORDS,
+			VBO_VERT_INDECES,
+			VBO_VERT_WEIGHTS,
+			VBOS_NUM
 		};
 
 	PROPERTY_R(uint, vertIdsNum, getVertIdsNum)
 
 	public:
 		RsrcPtr<Material> material; ///< Required. If empty then mesh not renderable
-		Vbos vbos; ///< The vertex buffer objects
 		Vao* vao; ///< Vertex array object
 		Vao* depthVao; ///< Vertex array object for the depth material
 
+		/// Default constructor
 		Mesh(): Resource(RT_MESH), Object(NULL) {}
+
+		/// Does nothing
 		~Mesh() {}
 
 		/// Implements @ref Resource::load
@@ -48,19 +49,14 @@ class Mesh: public Resource, public Object
 		bool isRenderable() const;
 
 	private:
+		Vbo* vbos[VBOS_NUM]; ///< The vertex buffer objects
+
+		/// Create the VBOs
 		void createVbos(const MeshData& meshData);
+
+		/// Create a VAO. Called more than one
 		void createVao(Vao* vao, Material& mtl);
 };
 
 
-inline Mesh::Vbos::Vbos():
-	vertCoords(NULL),
-	vertNormals(NULL),
-	vertTangents(NULL),
-	texCoords(NULL),
-	vertIndeces(NULL),
-	vertWeights(NULL)
-{}
-
-
 #endif

+ 10 - 8
src/Ui/Ui.cpp

@@ -1,3 +1,4 @@
+/*
 #include <stdio.h>
 #include <stdarg.h>
 #include "Ui.h"
@@ -11,11 +12,11 @@
 namespace Ui {
 
 
-/*
+
 =======================================================================================================================================
 data members                                                                                                           =
 =======================================================================================================================================
-*/
+
 static RsrcPtr<Texture> fontMap;
 
 static RsrcPtr<ShaderProg> shader;
@@ -30,11 +31,11 @@ static float  crntY;
 
 
 
-/*
+
 =======================================================================================================================================
 static funcs                                                                                                           =
 =======================================================================================================================================
-*/
+
 
 
 // SetGL
@@ -133,7 +134,7 @@ static void drawChar(char c)
 	glEnd();
 
 	// draw outline
-	/*if(1)
+	if(1)
 	glDisable(GL_TEXTURE_2D);
 	glColor3f(0.0, 0.0, 1.0);
 	glBegin(GL_LINES);
@@ -142,7 +143,7 @@ static void drawChar(char c)
 		glVertex2fv(coords[2]);
 		glVertex2fv(coords[3]);
 	glEnd();
-	glEnable(GL_TEXTURE_2D);*/
+	glEnable(GL_TEXTURE_2D);
 	// end draw outline
 
 	crntX += fontW*0.8;
@@ -150,11 +151,11 @@ static void drawChar(char c)
 }
 
 
-/*
+
 =======================================================================================================================================
 non static funcs                                                                                                       =
 =======================================================================================================================================
-*/
+
 
 
 // init
@@ -228,3 +229,4 @@ void print(const char* text)
 
 
 } // end namespace
+*/