Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
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  
  display called before init  (Read 1543 times)
0 Members and 1 Guest are viewing this topic.
Offline zero

Junior Member





« Posted 2005-07-03 16:25:49 »

Hi,

I noticed that using the follwing initialization sequence, the display method of the GLEventListener is called either before the init method, or the init method is not called at all.


        GLCapabilities caps = new GLCapabilities();
        caps.setHardwareAccelerated(true);
        caps.setDoubleBuffered(true);
        //caps.setDepthBits(24);
        //caps.setStencilBits(Cool;
               
        GLCanvas glCanvas = GLDrawableFactory.getFactory().createGLCanvas(caps);
        glCanvas.setSize(640, 480);
         this.getContentPane().add(glCanvas);         
     
        glCanvas.addGLEventListener(new MyGLEventListener());       
        initComponents(); // swing stuff with pack()


         versus


        initComponents(); // swing stuff with pack()
        glCanvas.addGLEventListener(new MyGLEventListener());



which works fine.

IMHO this behavior is a usage bug and should be fixed.

best regards
 - Michael

(P.S. using jogl 1.1 final on a linux box)
Offline Soulfly32

Senior Newbie





« Reply #1 - Posted 2005-07-03 16:43:08 »

Thats not a bug, its a fact.

The normal way of initialisation of components is:

create Component
init       Component
show  Component




_____________________________________
www.soulfly-design.de
www.soulflyhome.com
Offline zero

Junior Member





« Reply #2 - Posted 2005-07-03 17:12:55 »

setVisible (show) is called after all code listed and the initialisation (create + init) sequence also doens't change. The only thing swapped was adding the listener and the initialization of other swing componets (nothing with GLCanvas).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Soulfly32

Senior Newbie





« Reply #3 - Posted 2005-07-03 18:55:39 »

I tested this on my Machine WinXP SP2,JDK 1.5 Jogl 1.1 final

I don't have that problem. Maybe a Linux problem?
Ken what do you say?

_____________________________________
www.soulfly-design.de
www.soulflyhome.com
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #4 - Posted 2005-07-11 22:21:09 »

Without seeing all of the code it's hard to say. You might try putting in a call to Thread.dumpStack() at the beginning ot your display() and init() methods to see what's going on. In general you should add your GLEventListener immediately after constructing the GLCanvas, before adding it to the component hierarchy.
Offline zero

Junior Member





« Reply #5 - Posted 2005-07-13 16:42:36 »

Thanks for answering Ken,

dumping the stack is a good idea, I will do that next time I get my hands on jogl. But I'm still wondering why the idiom, you mentioned:

In general you should add your GLEventListener immediately after constructing the GLCanvas, before adding it to the component hierarchy.

is needed - are there any technical issues ?
If yes, these should be emphasized, because many awt and swing programmers probably are used to add/change/remove the needed event listeneres at any time.

Best regards
-Michael
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #6 - Posted 2005-07-13 18:13:02 »

You will only get your init() method called if your GLEventListener is registered before the OpenGL context is created (typically when the widget is realized). For this reason you should install your GLEventListener as early as possible in particular if you have a non-trivial init() method. There is an open bug to document this better but basically we are not going to try to keep track of which listeners had their init() methods called (or not) since the last context creation. It isn't possible to keep track of this in the general case.
Offline zero

Junior Member





« Reply #7 - Posted 2005-07-13 22:01:04 »

thanks again Ken, I assumed it has something todo with the gl_context.

May be offtopic but: Is there any good documentation about the gl_context and its use in JOGL ?
I'm a asking because I was used to work with DirectX and a Direct3D Device can be shared among several controls/components, but everytime the backbuffer is resized one has to reset the device. I don't believe the init method is called after a resize so, I am wondering whether a GL_context can receive a reset and so on..

Best regards
-Michael
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #8 - Posted 2005-07-13 23:28:56 »

I'm afraid not. Your best bet would probably be to look at the JOGL source code and read the various platforms' documentation on the APIs integrating OpenGL into their window systems.
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.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!