Jump to content
  • Advertisement
Sign in to follow this  
Chris-Faeria

[java] [JOGL] Is it a way to NOT use GLEventListener ?

This topic is 4063 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, I'm trying to do a simple game using JOGL but I can't find a way to do it without implementing GLEventListener. It's not like I don't want to do it, but how can I be sure that the GLEventListener.init (GLDrawable) is called before any update of the game. Here a sample of my game loop:
Frame mainFrame = new Frame ();
CGameEngine game = new CGameEngine ("testGame");
game.Init (mainFrame);    // I would like to do any JOGL init here
while (true)
{
    game.Update ();
    game.Render ();    // I would like to do every OGL call here
}

I tried to call init myself but every members of GL is null when I do that. Here the code that doesn't work:
GLCanvas canvas = new GLCanvas ();
GL device = canvas.getGL ();
System.err.println (device.glGetString(GL.GL_VERSION));    // Output null

If anyone can help me, your help will be really appreciate. [smile]

Share this post


Link to post
Share on other sites
Advertisement
I don't think so.

But that doesn't change anything. Your code simply becomes:

class Game implements GLEventListener {

public void setUpGame()
{
// initialize the game related stuff
}

public void update()
{
// do game stuff
}

public void render()
{
canvas.update();
}
private GLCanvas canvas;
}

Game game = ... // make game
game.setUpGame();
while (true) {
game.update();
game.render();
}





And you implement your rendering in appropriate GLEventListener.

Quote:
It's not like I don't want to do it, but how can I be sure that the GLEventListener.init (GLDrawable) is called before any update of the game.


You can't. That's the whole point of listener interface. It gets called when needed. Same for redrawing. That's how event driven approach works.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!