Advertisement

Old OpenGL movement problem

Started by May 28, 2014 04:00 AM
0 comments, last by too_many_stars 10 years, 8 months ago

Hi Guys,

Having an issue with OpenGL.

Here's my update function


	void update(float dt){
		
		glLoadIdentity();
		
		glTranslatef(pos.x,pos.y,pos.z);

		pos.z+=vel.z*dt/1000.0f;
	
		glCallList(object);
	}

The idea is simple, move a ball, along the z axis with the help of a V3 class I created wich has float x,y,z with all the requisite operations such as addition, normailization etc.

The issue is, when I initialize vel.z=20.0f, the ball does not move, however when I do the following...


	void update(float dt){
		
		glLoadIdentity();
		
		glTranslatef(pos.x,pos.y,pos.z);

		pos.z+=20*dt/1000.0f;//change here
	
		glCallList(object);
	}

the ball does move. I am completely baffled as I have done this numerous times in SDL and the objects move just fine.

I think the issue has to do something with either glLoadIdentity() or glTranslatef().

If anyone has any ideas please let me know.

Thanks,

Mike

nm got the problem solved, stupid initialization on my part.

This topic is closed to new replies.

Advertisement