Browse Source

Added app::PrintAppInfo

Panagiotis Christopoulos Charitos 16 years ago
parent
commit
32ea344160
6 changed files with 55 additions and 33 deletions
  1. 4 5
      src/main.cpp
  2. 1 0
      src/resources/material.h
  3. 30 28
      src/scene/mesh_node.cpp
  4. 18 0
      src/utility/app.cpp
  5. 1 0
      src/utility/app.h
  6. 1 0
      src/utility/util.cpp

+ 4 - 5
src/main.cpp

@@ -44,11 +44,8 @@ spot_light_t* spot_lights[2];
 //=====================================================================================================================================
 //=====================================================================================================================================
 void Init()
 void Init()
 {
 {
-	#if defined( _DEBUG_ )
-		PRINT( "Engine initializing (Debug)..." );
-	#else
-		PRINT( "Engine initializing (Release)..." );
-	#endif
+	PRINT( "Engine initializing..." );
+
 	srand( unsigned(time(NULL)) );
 	srand( unsigned(time(NULL)) );
 	MathSanityChecks();
 	MathSanityChecks();
 
 
@@ -116,6 +113,8 @@ void Init()
 //=====================================================================================================================================
 //=====================================================================================================================================
 int main( int /*argc*/, char* /*argv*/[] )
 int main( int /*argc*/, char* /*argv*/[] )
 {
 {
+	app::PrintAppInfo();
+
 	Init();
 	Init();
 
 
 	PRINT( "Entering main loop" );
 	PRINT( "Entering main loop" );

+ 1 - 0
src/resources/material.h

@@ -101,6 +101,7 @@ class material_t: public resource_t
 				int alpha_testing_map;
 				int alpha_testing_map;
 			} uni_locs;
 			} uni_locs;
 		} dp;*/
 		} dp;*/
+		material_t* dp_material;
 
 
 	//===================================================================================================================================
 	//===================================================================================================================================
 	// funcs                                                                                                                            =
 	// funcs                                                                                                                            =

+ 30 - 28
src/scene/mesh_node.cpp

@@ -35,6 +35,8 @@ void mesh_node_t::Deinit()
 /// Called in material or blending stages
 /// Called in material or blending stages
 void mesh_node_t::Render()
 void mesh_node_t::Render()
 {
 {
+	const material_t* mtl = material;
+
 	glPushMatrix();
 	glPushMatrix();
 	r::MultMatrix( transformation_wspace );
 	r::MultMatrix( transformation_wspace );
 
 
@@ -42,49 +44,49 @@ void mesh_node_t::Render()
 	if( skel_controller )
 	if( skel_controller )
 	{
 	{
 		// first the uniforms
 		// first the uniforms
-		glUniformMatrix3fv( material->uni_locs.skinning_rotations, skel_controller->skel_node->skeleton->bones.size(), 1,
+		glUniformMatrix3fv( mtl->uni_locs.skinning_rotations, skel_controller->skel_node->skeleton->bones.size(), 1,
 		                    &(skel_controller->skel_node->skel_anim_controller->bone_rotations[0])[0] );
 		                    &(skel_controller->skel_node->skel_anim_controller->bone_rotations[0])[0] );
-		glUniform3fv( material->uni_locs.skinning_translations, skel_controller->skel_node->skeleton->bones.size(),
+		glUniform3fv( mtl->uni_locs.skinning_translations, skel_controller->skel_node->skeleton->bones.size(),
 		              &(skel_controller->skel_node->skel_anim_controller->bone_translations[0])[0] );
 		              &(skel_controller->skel_node->skel_anim_controller->bone_translations[0])[0] );
 
 
 		// then the attributes
 		// then the attributes
-		DEBUG_ERR( material->attrib_locs.vert_weight_bones_num == -1 );
+		DEBUG_ERR( mtl->attrib_locs.vert_weight_bones_num == -1 );
 
 
 		mesh->vbos.vert_weights.Bind();
 		mesh->vbos.vert_weights.Bind();
-		glEnableVertexAttribArray( material->attrib_locs.vert_weight_bones_num );
-		glVertexAttribPointer( material->attrib_locs.vert_weight_bones_num, 1, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(0) );
-		glEnableVertexAttribArray( material->attrib_locs.vert_weight_bone_ids );
-		glVertexAttribPointer( material->attrib_locs.vert_weight_bone_ids, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(4) );
-		glEnableVertexAttribArray( material->attrib_locs.vert_weight_weights );
-		glVertexAttribPointer( material->attrib_locs.vert_weight_weights, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(20) );
+		glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_bones_num );
+		glVertexAttribPointer( mtl->attrib_locs.vert_weight_bones_num, 1, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(0) );
+		glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_bone_ids );
+		glVertexAttribPointer( mtl->attrib_locs.vert_weight_bone_ids, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(4) );
+		glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_weights );
+		glVertexAttribPointer( mtl->attrib_locs.vert_weight_weights, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(20) );
 	}
 	}
 
 
-	if( material->attrib_locs.position != -1 )
+	if( mtl->attrib_locs.position != -1 )
 	{
 	{
 		mesh->vbos.vert_coords.Bind();
 		mesh->vbos.vert_coords.Bind();
-		glVertexAttribPointer( material->attrib_locs.position, 3, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( material->attrib_locs.position );
+		glVertexAttribPointer( mtl->attrib_locs.position, 3, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attrib_locs.position );
 	}
 	}
 
 
-	if( material->attrib_locs.normal != -1 )
+	if( mtl->attrib_locs.normal != -1 )
 	{
 	{
 		mesh->vbos.vert_normals.Bind();
 		mesh->vbos.vert_normals.Bind();
-		glVertexAttribPointer( material->attrib_locs.normal, 3, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( material->attrib_locs.normal );
+		glVertexAttribPointer( mtl->attrib_locs.normal, 3, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attrib_locs.normal );
 	}
 	}
 
 
-	if( material->attrib_locs.tex_coords != -1 )
+	if( mtl->attrib_locs.tex_coords != -1 )
 	{
 	{
 		mesh->vbos.tex_coords.Bind();
 		mesh->vbos.tex_coords.Bind();
-		glVertexAttribPointer( material->attrib_locs.tex_coords, 2, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( material->attrib_locs.tex_coords );
+		glVertexAttribPointer( mtl->attrib_locs.tex_coords, 2, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attrib_locs.tex_coords );
 	}
 	}
 
 
-	if( material->attrib_locs.tanget != -1 )
+	if( mtl->attrib_locs.tanget != -1 )
 	{
 	{
 		mesh->vbos.vert_tangents.Bind();
 		mesh->vbos.vert_tangents.Bind();
-		glVertexAttribPointer( material->attrib_locs.tanget, 4, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( material->attrib_locs.tanget );
+		glVertexAttribPointer( mtl->attrib_locs.tanget, 4, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attrib_locs.tanget );
 	}
 	}
 
 
 	mesh->vbos.vert_indeces.Bind();
 	mesh->vbos.vert_indeces.Bind();
@@ -92,16 +94,16 @@ void mesh_node_t::Render()
 	glDrawElements( GL_TRIANGLES, mesh->vert_indeces.size(), GL_UNSIGNED_SHORT, 0 );
 	glDrawElements( GL_TRIANGLES, mesh->vert_indeces.size(), GL_UNSIGNED_SHORT, 0 );
 
 
 	// disable
 	// disable
-	if( material->attrib_locs.position != -1 ) glDisableVertexAttribArray( material->attrib_locs.position );
-	if( material->attrib_locs.normal != -1 ) glDisableVertexAttribArray( material->attrib_locs.normal );
-	if( material->attrib_locs.tex_coords != -1 ) glDisableVertexAttribArray( material->attrib_locs.tex_coords );
-	if( material->attrib_locs.tanget != -1 ) glDisableVertexAttribArray( material->attrib_locs.tanget );
+	if( mtl->attrib_locs.position != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.position );
+	if( mtl->attrib_locs.normal != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.normal );
+	if( mtl->attrib_locs.tex_coords != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.tex_coords );
+	if( mtl->attrib_locs.tanget != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.tanget );
 
 
 	if( skel_controller )
 	if( skel_controller )
 	{
 	{
-		glDisableVertexAttribArray( material->attrib_locs.vert_weight_bones_num );
-		glDisableVertexAttribArray( material->attrib_locs.vert_weight_bone_ids );
-		glDisableVertexAttribArray( material->attrib_locs.vert_weight_weights );
+		glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_bones_num );
+		glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_bone_ids );
+		glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_weights );
 	}
 	}
 
 
 	vbo_t::UnbindAllTargets();
 	vbo_t::UnbindAllTargets();

+ 18 - 0
src/utility/app.cpp

@@ -1,3 +1,4 @@
+#include <GL/glew.h>
 #include "app.h"
 #include "app.h"
 
 
 namespace app { // begin of namespace
 namespace app { // begin of namespace
@@ -112,4 +113,21 @@ void WaitForNextFrame()
 }
 }
 
 
 
 
+//=====================================================================================================================================
+// PrintAppInfo                                                                                                                       =
+//=====================================================================================================================================
+void PrintAppInfo()
+{
+	cout << "App info: ";
+	#if defined( _DEBUG_ )
+		cout << "Debug ";
+	#else
+		cout << "Release ";
+	#endif
+	cout << "GLEW_" << glewGetString(GLEW_VERSION) << " ";
+	const SDL_version* v = SDL_Linked_Version();
+	cout << "SDL_" << int(v->major) << '.' << int(v->minor) << '.' <<  int(v->patch) << endl;
+}
+
+
 } // end of namespace
 } // end of namespace

+ 1 - 0
src/utility/app.h

@@ -16,6 +16,7 @@ extern void InitWindow( int w, int h, const char* window_caption  );
 extern void QuitApp( int code );
 extern void QuitApp( int code );
 extern void WaitForNextFrame();
 extern void WaitForNextFrame();
 extern void TogleFullScreen();
 extern void TogleFullScreen();
+extern void PrintAppInfo();
 
 
 inline uint GetTicks()
 inline uint GetTicks()
 {
 {

+ 1 - 0
src/utility/util.cpp

@@ -144,4 +144,5 @@ char* GetFileExtension( const char* path )
 	return str+1;
 	return str+1;
 }
 }
 
 
+
 }
 }