[ODE] openGL_problem

López Víctor vilopri at yahoo.es
Fri Jan 26 04:22:49 MST 2007


Hello, 
I've got a OpenGL problem while compiling my ode source code with g++.
When I put this line from base directory (i.e., form "ode-0.5/"):

 g++ ode/test/Walker.cpp -L/usr/X11R6/lib64 -lode -ldrawstuff -lX11 -lGL -lGLU -lglut

I get this problem:

/usr/bin/ld: skipping incompatible /usr/X11R6/lib64/libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-mandriva-linux-gnu/4.0.1/../../../libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libglut.so when searching for -lglut
/usr/bin/ld: cannot find -lglut
collect2: ld returned 1 exit status

I've put the library "libglut.so.3.7.1" in "/usr/X11R6/lib64" directory, and I have also de header file "glut.h"
in "/usr/include/GL" directory.
I suppose that the problem comes from incompatibility between "gcc version" (4.0.1) and "libglut" version
(which is libglut.3.7.1).
I've already tried installing other versions of libglut from "RPM search" web page, and some of them coming
from "mesa" project, but the problem seems to remain.
Does anybody know how to solve this? 
Thanks a lot,
Victor

P.S.: here it is the main source code (ode/test/Walker.cpp):







// Walker.cpp : Defines the entry point for the console application.
//

/*********************Includes*******************************/
//#include <stdlib.h>
#include <iostream>
#include <assert.h>
#include <math.h>
#include <ode/ode.h>
//#include <odewalker/odewalker.h>
#include <odewalker/ODEObject.h>
//#include <math.h>
#include <odewalker/Base3DObject.h>
#include <odewalker/EvolutionController.h>
#include <odewalker/NeuralNet.h>
#include <odewalker/Neuron.h>
#include <odewalker/NNGeneString.h>
#include <odewalker/ODEBox.h>
#include <odewalker/ODEHuman.h>
#include <odewalker/ODEObject.h>
#include <odewalker/ODESphere.h>
#include <odewalker/ODEWorld.h>
#include <odewalker/Timer.h>
#include <string.h>
/************************************************************/

/*********************Prototypes*****************************/
void InitOpenGL();
void InitODE();
void Redraw();
void Idle();
void Reshape(int w, int h);
void MouseButtons(int button, int button_state, int x, int y);
void MouseMovement(int x, int y);
void KeyboardAction(unsigned char key, int x, int y);
void Setup3DObjects();
/************************************************************/

/*********************Defines********************************/
#define GRAVITY -9.81*5

typedef struct point2i
{
	int x, y;
} point2i;
/************************************************************/

/*********************Global Variables***********************/
int main_window;
float aspect_ratio;
int windowWidth = 640;
int windowHeight = 480;
ODEObject *pickedObject = NULL;
bool LeftMouseButton = false;
bool RightMouseButton = false;
point2i oldMousePos = {-1, -1};
double cameraRotAngle[2] = {0.0, 0.0};
//std::list<ODEObject*> objectList;
//std::list<ODEObject*>::iterator iter;
float cameraRotX=0;
float cameraRotY=0;
float cameraZoom=-30;
EvolutionController* evolutionController;
Timer timer;
//point3d initialPosition = {0, 6.11, 0};
point3d initialPosition = {0, 4.7*BODY_SIZE, 0};

//ODE objects
ODEObject* ground=NULL;
ODESphere* ball=NULL;
ODEWorld* world=NULL;
ODEHuman* humanPtr=NULL;
/************************************************************/

int main(int argc, char** argv)
{
	srand(time(NULL));

	//setting up the ODE world
	world = new ODEWorld(GRAVITY);

	evolutionController = new EvolutionController(world, &timer, initialPosition);
	evolutionController->GetUserInput();

	Setup3DObjects();

	//setting up GLUT
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(windowWidth, windowHeight);
	glutInitWindowPosition(350, 150);
	main_window = glutCreateWindow("Evolving People");
	glutDisplayFunc(Redraw);
	glutReshapeFunc(Reshape);
	glutMouseFunc(MouseButtons);
	glutMotionFunc(MouseMovement);
	glutKeyboardFunc(KeyboardAction);
	glutIdleFunc(Idle);

	//setting up OpenGL
	InitOpenGL();

	//refresh timer before starting
	timer.Reset();

	//starting the main loop
	glutMainLoop();
}

void Setup3DObjects()
{
	//creating the ground platform
	ground = new ODEBox(world, false, 0, -1, 0, 40, 2, 40);
	point3d startPoint = {0, -1, 0};
	ground->SetPosition(startPoint);

	//creating the human's body
	humanPtr = new ODEHuman(world, initialPosition.x, initialPosition.y, initialPosition.z, BODY_SIZE);
	humanPtr->SetBrain(evolutionController->GetFirstBrain());
}

void Idle()
{
	float deltaTime = timer.GetElapsedSeconds();

	if (humanPtr!=NULL)
	{
		humanPtr->UseBrain();
	}

	evolutionController->EvolutionLoop(humanPtr, deltaTime);

	world->ODELoop(deltaTime); // handle collisions and dynamics

	if (glutGetWindow() != main_window) 
		glutSetWindow(main_window);  

	glutPostRedisplay();
}

void Reshape(int w, int h)
{
	aspect_ratio = (float)w/(float)h;
	glViewport(0, 0, w, h);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(40.0, aspect_ratio, 1, 5000.0);
	glMatrixMode( GL_MODELVIEW );

	windowWidth = w;
	windowHeight = h;
	glutPostRedisplay();
}

void KeyboardAction(unsigned char key, int x, int y)
{
	switch(key)
	{
		case 'f':
			if (humanPtr != NULL)
			{
				dBodyAddForce(humanPtr->GetBodyID(), 2000, 0, 0);
			}
			break;
		case 'q':
		{
			// Clean up...
			delete evolutionController;
			delete ground;
			delete humanPtr;
			delete world; // always do this last
			exit(0);
			break;
		}

		default:
			break;
	}
}

void MouseButtons(int button, int button_state, int x, int y)
{
	y = windowHeight - y;

	if (button == GLUT_LEFT_BUTTON) 
	{
		if (button_state == GLUT_DOWN)
		{
			LeftMouseButton = true;
			oldMousePos.x = x;
			oldMousePos.y = y;
		}
		else
			LeftMouseButton = false;
	}
	if (button == GLUT_RIGHT_BUTTON) 
	{
		if (button_state == GLUT_DOWN)
		{
			RightMouseButton = true;
			oldMousePos.x = x;
			oldMousePos.y = y;
		}
		else
			RightMouseButton = false;
	}
}

void MouseMovement(int x, int y)
{
	y = windowHeight - y;

	point2i deltaMouse;
	deltaMouse.x = x - oldMousePos.x;
	deltaMouse.y = y - oldMousePos.y;

	oldMousePos.x = x;
	oldMousePos.y = y;

	if (LeftMouseButton == true)
	{
		cameraRotY += double(deltaMouse.x)/5.0;
		cameraRotX -= double(deltaMouse.y)/5.0;
	}
	if (RightMouseButton==true)
	{
 		cameraZoom -= double(deltaMouse.y)/5.0;
	}
}

void InitOpenGL()
{
	glClearColor(0.9, 0.9, 0.9, 1.0);
	glColor3f(0.0, 0.0, 0.0);
	glPointSize(4.0);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(40.0, aspect_ratio, 1, 5000.0);
	glMatrixMode( GL_MODELVIEW );

	glEnable(GL_DEPTH_TEST);

	float matAmbientAndDiffuse[4] = {.5, .5, .5, 1};
	float matSpecular[4] = {1, 1, 1, 1};
	float matShininess = 60;

	glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matAmbientAndDiffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, matSpecular);
	glMaterialf(GL_FRONT, GL_SHININESS, matShininess);

	GLfloat ambient[] =  {0.1f, 0.1f, 0.1f, 1.0f};
	GLfloat diffuse[] =  {.8f, .8f, 0.8f, 1.0f};
	GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat light_position[] = {20.0f, 20.0f, 30.0f, 0.0f};

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);
}

void Redraw()
{
	glClearColor(0.9, 0.9, 0.9, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();

	glTranslatef(0.0, -5, cameraZoom); // move camera back
	glRotatef(cameraRotX, 1, 0, 0);
	glRotatef(cameraRotY, 0, 1, 0);

	ground->Draw();
	humanPtr->Draw();

	glutSwapBuffers(); 
}






        
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com




	
	
		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com



More information about the ODE mailing list