Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 11:54 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Dec 04, 2010 6:52 am 
Offline

Joined: Wed Sep 17, 2008 1:06 am
Posts: 96
Full of questions lately. Messing around with multiple Graphics contexts, I wrote this:

Code:
   public void render(GameContainer container, Graphics gfx)
   {
      gfx.scale(0.25f, 0.25f);
      gfx.setColor(Color.red);
      gfx.fillRect(32, 32, 512, 512);
      gfx.flush();
      
      Graphics gfx2 = new Graphics(512, 512);
      Graphics.setCurrent(gfx2);
      
      gfx2.scale(4f, 4f); //This produces a crash
      gfx2.setColor(Color.orange);
      gfx2.drawRect(0, 0, 512, 512);
      gfx2.fillRect(32, 32, 64, 64);
      gfx2.fillRect(512-32, 512-32, 64, 64);
      gfx2.flush();
   }


and got this:
Code:
Exception in thread "main" org.lwjgl.opengl.OpenGLException: Stack overflow (1283)
   at org.lwjgl.opengl.Util.checkGLError(Util.java:54)
   at org.lwjgl.opengl.Display.swapBuffers(Display.java:693)
   at org.lwjgl.opengl.Display.update(Display.java:712)
   at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:418)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:318)
   at test.GraphicsContext.main(GraphicsContext.java:71)



Why does scaling a second graphics context result in a crash? Also, I'm not completely sure what flush() does -- can anyone explain this to me? setCurrent doesn't seem to do a whole lot either.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 04, 2010 8:33 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
You shouldn't call setCurrent manually.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 04, 2010 8:57 pm 
Offline

Joined: Wed Sep 17, 2008 1:06 am
Posts: 96
Ok, well... I commented out setCurrent and I still get the crash.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 04, 2010 9:04 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Ok, can you raise a bug.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 05, 2010 6:31 am 
Offline

Joined: Wed Sep 17, 2008 1:06 am
Posts: 96
Done. Still don't know what exactly flush() does, though. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 25, 2010 4:19 am 
Offline

Joined: Wed Sep 17, 2008 1:06 am
Posts: 96
Bump because I have more questions.

Creating the second Graphics object in the init method instead of render got rid of the crash, but the two objects don't seem to be working independently. Scaling one also scales the other, for instance. Why?

Also, can someone explain flush()?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group