Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  ...jogl.GLException: Unable to lock surface  (Read 2491 times)
0 Members and 1 Guest are viewing this topic.
Offline karmaGfa

Junior Devvie




Miaow


« Posted 2004-04-25 06:13:24 »

I made a class which extends a Frame, where I put an instance of the GLCanvas.

When I create an instance of this class from the main function (i.e. from the main thread), there is no problem.

When I create an instance of this class from the event thread (i.e. when the use push a button or something like that), the instruction "canvas.setSize(320, 200);" in the constructor of my class throws an exeption.

When I comment out the "setSize(320, 200);", there is no problem but my frame is zero sized and the user need to resize it manually :-(

The setSize() function cause a reshape() call on the canvas object, which cause this execption to be thrown. Since I don't call the reshape function myself, the propagation of this exception to the level of the setSize() function is a bug.


Here is the trace of the exception :

net.java.games.jogl.GLException: Unable to lock surface

     at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.lockSurface(WindowsOnscreenGLContext.java:155)

     at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:107)

     at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:162)

     at net.java.games.jogl.GLCanvas.reshape(GLCanvas.java:105)

     at java.awt.Component.setBounds(Component.java:1664)

     at java.awt.Component.resize(Component.java:1601)

     at java.awt.Component.setSize(Component.java:1593)

     at jardin.scene.OpenGLFrame.<init>(OpenGLFrame.java:22)

     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

     at java.lang.reflect.Constructor.newInstance(Constructor.java:274)

     at java.lang.Class.newInstance0(Class.java:308)

     at java.lang.Class.newInstance(Class.java:261)

     at jardinier.classBrowserPanel.ClassBrowserPanel.instantiateSelectedTreeNode(ClassBrowserPanel.java:280)

....




Here is the source of the constructor of my Frame class :


public class OpenGLFrame
       extends Frame
{

   protected GLCanvas canvas;
   protected Scene currentScene = new Scene();

   public OpenGLFrame()
   {
       GLCapabilities capabilities = new GLCapabilities();
       canvas = GLDrawableFactory.getFactory().createGLCanvas(capabilities);
       canvas.addGLEventListener(currentScene);
       add(canvas);
       canvas.setSize(320, 200);

       pack();
       show();
   }

...
}





Vincent Cantin

<a href="http://www.le-moulin-studio.com">Le Moulin Studio</a> - MMO Technologies and Services.
Offline karmaGfa

Junior Devvie




Miaow


« Reply #1 - Posted 2004-04-25 06:50:13 »

I just tried with the nightly build, and the problem is still there.


<a href="http://www.le-moulin-studio.com">Le Moulin Studio</a> - MMO Technologies and Services.
Offline milvich

Senior Newbie




Java games rock!


« Reply #2 - Posted 2004-04-25 13:09:02 »

My guess is that the GL Context hasn't been set up yet. I believe that JOGL delays the actual creation of the context until first display. So the reshape is happening before the context is created.

Why don't you try setting the size before adding the GLCanvas?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #3 - Posted 2004-04-26 01:08:24 »

Could you boil this down into a test case and file an issue on the Issue Tracker page linked off the JOGL web page?
Offline karmaGfa

Junior Devvie




Miaow


« Reply #4 - Posted 2004-04-26 14:25:32 »

Could you boil this down into a test case and file an issue on the Issue Tracker page linked off the JOGL web page?

Yes, I will do that soon.

<a href="http://www.le-moulin-studio.com">Le Moulin Studio</a> - MMO Technologies and Services.
Offline robdarich

Senior Newbie




Java games rock!


« Reply #5 - Posted 2004-06-21 17:31:17 »

I am having a similar problem and was wondering if anyone has come up with a solution to this.  I have updated with the nightly build and that didn't help.  The exception only occurs on my windows box.  The same application runs fine on the mac.  here is part of the exception trace:

net.java.games.jogl.GLException: Unable to lock surface
net.java.games.jogl.GLException: Unable to lock surface
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.lockSurface(WindowsOnscreenGLContext.java:155)
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:107)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:232)
at net.java.games.jogl.GLCanvas.reshape(GLCanvas.java:97)
at java.awt.Component.setBounds(Component.java:1664)


this comes as the result of a user pressing a button which creates a new instance of a Jwindow extended class which than adds a jogl canvas to its content pane.  the excetion occurs at this line:

canvas.setBounds(0,0,width,height);

thanks for any help
-rob
Offline cgunn

Senior Newbie





« Reply #6 - Posted 2004-06-22 09:26:12 »

├čI am also currently struggling with an exception of this type.  The JOGL User's Guide indicates that it has to do the with multi-threaded environment of Java interacting with the C-origins of OpenGL:
(the User's Guide is available at https://jogl.dev.java.net/nonav/source/browse/*checkout*/jogl/doc/userguide/index.html?rev=HEAD&content-type=text/html).  Here's a relevant quote:

"Both of these models (repaint-on-demand and repaint continually) still require the user to think about which thread keyboard and mouse events are coming in on, and which thread is performing the OpenGL rendering. OpenGL rendering may not occur directly inside the mouse or keyboard handlers, because the OpenGL context for the drawable is not current at this point (hence the warning about storing a GL object in a field, where it can be fetched and accidentally used by another thread). However, a mouse or keyboard listener may invoke GLDrawable.display().

"It is generally recommended that applications perform as little work as possible inside their mouse and keyboard handlers to keep the GUI responsive. However, since OpenGL commands can not be run from directly within the mouse or keyboard event listener, the best practice is to store off state when the listener is entered and retrieve this state during the next call to GLEventListener.display()."

So, the problem referred to in this thread might be avoided by following the advice given here.  That is, store off state in the keyboard and mouse listeners, but don't do anything that will directly cause display of a GLDrawable on the event-handling thread.

Unfortunately, there are still situations where it is hard to avoid having display called from the wrong thread (for example, an IDE that instantiates instances of Java objects: when that Java object contains a GLDrawable, the wrong thread may inadvertantly be called to display it -- at least that what seems to be causing the exceptions I'm encountering).  

Hope this helps.

Thanks to whoever wrote the User's Guide.  And, if you're reading this, what about updating it with any new and useful developments in the themes it deals with?
Offline GKW

Senior Devvie




Revenge is mine!


« Reply #7 - Posted 2004-06-22 14:14:41 »

Make sure your window is visible before you call setBounds.  The canvas needs to be attached to the screen before you can work with it.
Offline robdarich

Senior Newbie




Java games rock!


« Reply #8 - Posted 2004-06-22 14:26:11 »

Make sure your window is visible before you call setBounds.  The canvas needs to be attached to the screen before you can work with it.

yes, that seems to work, although it is odd that this is not the case when the code is run on the mac.
thanks
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (35 views)
2014-12-15 09:26:44

Mr.CodeIt (26 views)
2014-12-14 19:50:38

BurntPizza (53 views)
2014-12-09 22:41:13

BurntPizza (86 views)
2014-12-08 04:46:31

JscottyBieshaar (48 views)
2014-12-05 12:39:02

SHC (62 views)
2014-12-03 16:27:13

CopyableCougar4 (65 views)
2014-11-29 21:32:03

toopeicgaming1999 (126 views)
2014-11-26 15:22:04

toopeicgaming1999 (117 views)
2014-11-26 15:20:36

toopeicgaming1999 (34 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!