OpenGL I need help from all of you!

This topic is 4394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

First off, give us some time! You've been stuck on this for 2 months now, you say, so surely you could wait more than 2 hours before bumping your post (say, until it is actually push off the front page?).

Secondly, no one really wants to sort through your entire code base and find the function/section that you are talking about. Can you post that code here directly yourself? You can just copy-and-paste it into a post, and put it between [source] and [/source] tags. Try to give us as little as possible; one or two functions should be enough.

Share on other sites
Thank you for the reply very much. I am sorry for my bad behaviour.

I believe this section of the code needs to be fixed:

bool Cylinder::ProcessMessage(U32 msg, MsgParam param1, MsgParam param2)
{
bool bHandled = false;

switch (msg)
{
case MSG_TRANSLATE_ALONG_LENGTH:
glTranslatef(0.0f, 0.0f, param1.f * m_lfHeight);
bHandled = true;
break;

case MSG_GET_LENGTH:
*(param1.plf) = m_lfHeight;
bHandled = true;
break;

case MSG_ROTATE_CURRENT_STATE:
if (param1.f > 0)
{
glRotatef(m_rotx, param1.f, 0.0f, 0.0f);
glRotatef(m_roty, 0.0f, param1.f, 0.0f);
glRotatef(m_rotz, 0.0f, 0.0f, param1.f);
}
else
{
glRotatef(m_rotz, 0.0f, 0.0f, param1.f);
glRotatef(m_roty, 0.0f, param1.f, 0.0f);
glRotatef(m_rotx, param1.f, 0.0f, 0.0f);
}
bHandled = true;
break;

case MSG_INCR_LENGTH: m_lfHeight++; bHandled = true; break;
case MSG_ACCUM_LENGTH: m_lfHeight += param1.f; bHandled = true; break;
}

if (!bHandled)
bHandled = GLuObj::ProcessMessage(msg, param1, param2);

return bHandled;
}

i want to remove the if statement that checks if rotation is positive

Share on other sites
your archive ( OGL ) is broken

Share on other sites
Quote:
 Original post by skiritisyour archive ( OGL ) is broken

thank you very much Skirtis; it appears that u are the only one who bothered to check the source so far... :) i really appreciate it.

I fixed the problem, please try again :)

Share on other sites
I think the solution to the real problem is Cylert (pemoline), Dexedrine (dextroamphetamine), or Ritalin (methylphenidate).

..

any help guys?

Share on other sites
Here is a simplified (pseudo code) version of my own drawing function in a flight sim that I am writing. Notice how there is a camera to define how all other objects will be rotated/translated.

int DrawGLScene(GLvoid){	glViewport(0, 0, xres, yres);	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluPerspective(45.0f, x_res/y_res, 1, 10000);	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();	gluLookAt(	camera_position[0],	camera_position[1],	camera_position[2],	camera_direction[0],	camera_direction[1],	camera_direction[2],	0, 1, 0);	glLightfv(GL_LIGHT1, GL_POSITION, your_light);	//Draw all objects here.	draw_world();	return TRUE;}

Share on other sites
Hey kid [smile] skiritis asked me to help out, so here I am. I can't really understand what your problem is, your explanation is lacking in the question/information respect. However, there are a few things I can point out which may help.

The function ChangeSize, there is no indication as to when that function gets called (apart from the name implying some order), the issue here that it changes the OpenGL state and your rendering function is state sensitive (see below). One option would be to not register ChangeSize with GLUT and manually call it at the beginning of the RenderScene function.

The RenderScene function is state sensitive, that is, the resulting state of OpenGL of the next call to RenderScene is dependent on state just after the current RenderScene call, this is not necessarily a bad thing, but in your case, it looks accidental (because you seem to be tracking absolute rotations using the global variables xRot, yRot and the Visual object's local state variables etc.).

You can make RenderScene self-contained by calling glMatrixMode(GL_MODELVIEW) followed by glLoadIdentity() just before your first call to glPushMatrix in the RenderScene function. After you have done this, try removing the negative check and see if that is the behavior you require.

Hope this helps, I will take another look later tonight.

Share on other sites
Hello everybody & silvermance

Look at www.albayoung.com/kosta/OGL2.zip . If you run it, you will see that as the one cylinder moves around, it almost never intersects the other cylinder. This is the wrong behavior. If you run the project from the original post (without your suggested changes, www.albayoung.com/kosta/OGL.zip ) the two cylinders always intersect. This is the correct behavior.

Let me know if you need more details

Once again, thank you all

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633661
• Total Posts
3013226
×