Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (756)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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  
  caching GL objects  (Read 1989 times)
0 Members and 1 Guest are viewing this topic.
Offline gouessej
« Posted 2008-09-26 08:27:12 »

Hi!

In TUER, I store a reference to the first GL I get from the canvas and I use it everywhere instead of doing GL gl=glCanvas.getGL(). But I read that in the documentation:
Quote
Users should not rely on the identity of the returned GL object; for example, users should not maintain a hash table with the GL object as the key. Additionally, the GL object should not be cached in client code, but should be re-fetched from the GLAutoDrawable at the beginning of each call to init, display, etc.

Can my bad practice have any impact on the performance?

Julien Gouesse | Personal blog | Website | Jogamp
Offline hell32.dll

Senior Newbie





« Reply #1 - Posted 2008-09-26 09:34:58 »

Hi!

how about to use not GL gl=glCanvas.getGL() in everywhere
and use next construction:

1  
2  
3  
4  
public void yourDefinedMethod(){
   GL gl = GLU.getCurrentGL();
   ...
}


you can take GL from thread, where was created canvas...

Sorry i'm bad speak English =)
Offline gouessej
« Reply #2 - Posted 2008-09-26 10:56:56 »

Hi!

how about to use not GL gl=glCanvas.getGL() in everywhere
and use next construction:

1  
2  
3  
4  
public void yourDefinedMethod(){
   GL gl = GLU.getCurrentGL();
   ...
}


you can take GL from thread, where was created canvas...

Good idea. But I'm going to check if GL is really changing during the execution of the game to be sure such a modification is required.

Julien Gouesse | Personal blog | Website | Jogamp
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lhkbob

JGO Knight


Medals: 32



« Reply #3 - Posted 2008-09-26 20:52:16 »

If the underlying context is destroyed, then the GL will be invalidated (and cause a crash if you try to use it).  On reliable systems this happens with a GLCanvas when it is removed and re-added to a JFrame.  On a GLJPanel, I've heard rumors this happens when it is resized (but I'm not sure).

A better approach, is to pass the GL around in the methods that need it, or to keep the GLContext object (which will never change) and call getGL() on it inside each method.

Offline gouessej
« Reply #4 - Posted 2008-09-27 18:18:01 »

If the underlying context is destroyed, then the GL will be invalidated (and cause a crash if you try to use it).  On reliable systems this happens with a GLCanvas when it is removed and re-added to a JFrame.  On a GLJPanel, I've heard rumors this happens when it is resized (but I'm not sure).

A better approach, is to pass the GL around in the methods that need it, or to keep the GLContext object (which will never change) and call getGL() on it inside each method.
Now I fetch the GL instance where I need it and it works fine. Thank you for your precisions.

Julien Gouesse | Personal blog | Website | Jogamp
Pages: [1]
  ignore  |  Print  
 
 

 
DesertCoockie (56 views)
2018-05-13 18:23:11

nelsongames (88 views)
2018-04-24 18:15:36

nelsongames (78 views)
2018-04-24 18:14:32

ivj94 (763 views)
2018-03-24 14:47:39

ivj94 (95 views)
2018-03-24 14:46:31

ivj94 (647 views)
2018-03-24 14:43:53

Solater (108 views)
2018-03-17 05:04:08

nelsongames (189 views)
2018-03-05 17:56:34

Gornova (430 views)
2018-03-02 22:15:33

buddyBro (1090 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
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!