Jump to content
  • Advertisement
Sign in to follow this  
gyula

OpenGL linux X11 opengl

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, In windows to keep the FPS alive the 'one' uses the classy Message Loop 'loop' (simplified version)
while(1)
{
  if(PickMessage()) // not GetMessage();
  {
     Dispatch();
  }
  else // eventually, or allways
     OpenGL.Render();
}
In linux, classy open GL app, uses XNextEvent(display, &event); (see here: http://gpwiki.org/index.php/OpenGL:Tutorials:Setting_up_OpenGL_on_X11
while (XPending(display) > 0)        
{                                    
       XNextEvent(display, &event);     
       switch (event.type)              
       ...
and the problem I have is that <code> XNextEvent(display, &event); </code> acts as GetMessage@Windows and blocks the call until there is a message to pick blocking the app to render in a FPS-type-of loop. How this is solved. Posting a message in X11 queue, Is there a Pick-kind-of message, Thank you. [Edited by - gyula on April 13, 2010 10:39:08 PM]

Share this post


Link to post
Share on other sites
Advertisement
If I understand correctly, XNextEvent() should only be called if there is something in the message queue ( XPending() checks how many messages are in the queue ). If there isn't anything in the queue then it should just do a render, i.e:


while(1)
{
while (XPending(display) > 0)
{
XNextEvent(display, &event);
//Handle messages
...
}

//Message handling finished or there were no messages, draw opengl stuff
OpenGL.Render();
}



Is this not the case? I apologise if this is incorrect, I haven't worked with X11 in a little while and this is all from memory.

Share this post


Link to post
Share on other sites
Hi,

Yes, just working OK. Thank you. I just realized..

The generated scheleton code from code blocks was wrong.

They generate:

while(1)
{
do{
XNextEvent(dpy, &event); // XNextEvent IS called if no pending...
switch(event.type)
{
....
}
}while(XPending(dpy));
render();
}



causing to hang in XNextEvent(dpy, &event);

instead:

while(1)
{
while(XPending(dpy)) // XNextEvent! called if no pending
{
XNextEvent(dpy, &event);
switch(event.type)
{
....
}
};
render();
}



Problem solved.
Thank you again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!