Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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  
  Support for multiple threads and multiple contexts  (Read 1575 times)
0 Members and 1 Guest are viewing this topic.
Offline elias

Senior Devvie





« Posted 2005-02-17 10:12:00 »

As of today, LWJGL CVS supports multiple threads, each rendering to a separate context.

This was one of the major gripes with LWJGL from the JOGL camp, and Ken Russel even stated that it would require a major rewrite of the LWJGL architecture to fix. It turned out he was absolutely right Smiley. What I have done is to scrap the manually created java and native OpenGL/OpenAL binding source and replace it with generated ones. I wanted to retain the extensive checking and function signatures that we already had, so I could not generate from a gl/al C header file, like JOGL. Instead I chose to generate from template files, which are really annotated java interface files. Annotations are a java 1.5 feature, and they describe the meta-information needed for each OpenGL/OpenAL function that enables the generator to spit out proper checking, auto-compute lengths and types and all those LWJGL rules and conventions that have cropped up over the years.

The template files are still manually created from the spec and header file, but unlike the old way where each and every function has to be written in java and the native stubs created, a template file are much more terse and declarative. For example, there is always one method in the template for each opengl function, while in the old days there could be several, one for each nio buffer type and one additional one if the function supported VBO/PBO operation. Those functions are now auto-generated. More information about the generator can be found in the LWJGL CVS in doc/generator.txt.

So, finally, what does this mean to the average LWJGL user? Not much. The real advantage will come when multiple AWTGLCanvases is complete and used extensively. However there are a few things you  should be aware of:


  • The context, the function pointers and the extension flags are now per thread. OpenGL methods are still called statically like you're used to, but the extension flags had to be put in an object. So if you're using extensions (or GL > 1.1) and have code like this:

    1  [/li][/list]
    2  
    3  
    if (GLContext.GL_vertex_buffer_object) {
    ...
    }


    you have to replace it with this:

    1  
    2  
    3  
    if (GLContext.getCapabilities().GL_vertex_buffer_object) {
    ...
    }


    That's it.

  • Calling OpenGL from a thread where a context is not current now correctly fails with an exception. Before, this was allowed and could lead to crashes and unexpected results.

  • I have manually converted the entire OpenGL/OpenAL API to the new template format, so while I've been making sure that the generator generates code equivalent with the old manually created API, it's likely that some bugs have cropped up either in the generator itself or in the template files. Please test 0.96 when it is released and report any inconsistencies so we can fix it as fast as possible. If you're not the adventurous kind, please stay with 0.95 while I fight it out Smiley



- elias

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.

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

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

toopeicgaming1999 (10 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (27 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!