Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (711)
Games in Android Showcase (213)
games submitted by our members
Games in WIP (785)
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 2009 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]
    if (GLContext.GL_vertex_buffer_object) {

    you have to replace it with this:

    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.

numerical (178 views)
2017-02-21 07:32:16

numerical (177 views)
2017-02-21 07:31:46

theagentd (285 views)
2017-02-18 13:42:33

theagentd (286 views)
2017-02-18 13:35:16

h.pernpeintner (1453 views)
2017-01-24 22:39:11

h.pernpeintner (1438 views)
2017-01-24 22:38:32

Galdo (2003 views)
2017-01-12 13:44:09

Archive (2048 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2585 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2332 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!