Commits

dbacchet committed e44e75e

split init routine for the renderer

Comments (0)

Files changed (3)

sources/tools/mesh_importer/main.cpp

 //
 // ----------------------------------------------------------------------------
 
+#include <iostream>
+
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 
 void makeTransforms( void *unused )
 {
-	usleep(2000000);
+	// usleep(2000000);
 	aiVector3D center = getCenter();
 	printf("center: %f %f %f\n",center.x,center.y,center.z);
 
-	usleep(2000000);
+	// usleep(2000000);
 	aiVector3D asize = getSize();
 	printf("size: %f %f %f\n",asize.x,asize.y,asize.z);
 
-	usleep(2000000);
+	// usleep(2000000);
 	translate(-center.x,-center.y,-center.z);
 
 	usleep(2000000);
 
 int main(int argc, char **argv)
 {
-
+    std::cout << "INSERT ANYTHING TO CONTINUE";
+    std::string ciccio;
+    std::cin >> ciccio;
+    
 	struct aiLogStream stream;
 
 	// get a handle to the predefined STDOUT log stream and attach
 		return -1;
 	}
 
+	printf("init renderer\n");
+	initRenderer(scene);
 
     // sync mutex
+    printf("create threads\n");
     amp_mutex_create(&mutex,AMP_DEFAULT_ALLOCATOR);
     
     //create threads

sources/tools/mesh_importer/renderer.cpp

 //
 // ----------------------------------------------------------------------------
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <iostream>
+
+#include <cstdio>
+#include <cstdlib>
 
 // Bring in OpenGL 
 #include "glfw_utils.h"
 
 
 // ----------------------------------------------------------------------------
-void startRenderer( void *params )
+bool initRenderer( const aiScene *scene )
 {
-	if (!params)
-		return;
+	if (!scene)
+		return false;
 
-	myscene = (aiScene*)params;
-
-	timer.start();
+	myscene = scene;
 
 	if (!glfw_Init(900,600))
 	{
 		printf("error initializing renderer. exit.\n");
-		return;
+		return false;
 	}
+	return true;
+}
 
 
+// ----------------------------------------------------------------------------
+void startRenderer( void *params )
+{
 	glClearColor(0.1f,0.1f,0.1f,1.f);
 
 	glEnable(GL_LIGHTING);
 
 	glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
 
+	timer.start();
+
 	bool running = true;
     while( running ) 
     {

sources/tools/mesh_importer/renderer.h

 
 // ----------------------------------------------------------------------------
 //int startRenderer( int argc, char **argv, const aiScene *scene );
+bool initRenderer( const aiScene *scene );
 
 void startRenderer( void *params );