Difference between revisions of "Multithreading"

From JPCT
Jump to: navigation, search
(Created page with '=== Multihreading === jPCT's renderer in single threaded unless you are using the AWTGLRenderer (or the JOGL-support). In that case, rendering and calculations are split into tw...')
 
Line 1: Line 1:
 
=== Multihreading ===
 
=== Multihreading ===
  
jPCT's renderer in single threaded unless you are using the AWTGLRenderer (or the JOGL-support). In that case, rendering and calculations are split into two threads. This isn't done just for fun, but because the actual drawing has to happen in the AWT event dispatch thread, which usually isn't the thread that executes your game logic.
+
jPCT's renderers are single threaded unless you are using the AWTGLRenderer (or the JOGL-support). In that case, rendering and calculations are split into two different threads. This isn't done just for fun, but because the actual drawing has to happen in the AWT event dispatch thread, which usually isn't the thread that executes your game logic.
When using one of these renderers, make sure that any GL and LWJGL related code is executed in the dispatch thread too. To do this, put it into one of the methods that the IPaintListener-interface offers instead of executing it directly in your main thread.
+
When using one of these renderers, make sure that any GL and LWJGL(JOGL related code is executed in the dispatch thread too. To do this, put it into one of the methods that the IPaintListener-interface offers instead of executing it directly in your main thread.
  
 
It is possible to use multithreading in the "normal" GL renderer too. Just set Config.useMultipleThreads to true before initializing the renderer. All said above about the AWTGLRenderer then applies to the normal renderer too.
 
It is possible to use multithreading in the "normal" GL renderer too. Just set Config.useMultipleThreads to true before initializing the renderer. All said above about the AWTGLRenderer then applies to the normal renderer too.

Revision as of 21:49, 6 June 2009

Multihreading

jPCT's renderers are single threaded unless you are using the AWTGLRenderer (or the JOGL-support). In that case, rendering and calculations are split into two different threads. This isn't done just for fun, but because the actual drawing has to happen in the AWT event dispatch thread, which usually isn't the thread that executes your game logic. When using one of these renderers, make sure that any GL and LWJGL(JOGL related code is executed in the dispatch thread too. To do this, put it into one of the methods that the IPaintListener-interface offers instead of executing it directly in your main thread.

It is possible to use multithreading in the "normal" GL renderer too. Just set Config.useMultipleThreads to true before initializing the renderer. All said above about the AWTGLRenderer then applies to the normal renderer too.

The software renderer doesn't support any kind of multithreading.


The threading framework

jPCT comes with a simple threading framework. It's not used ATM. If you feel the urge to use it, feel free to do so, but it's not tested very well. Use it at your own risk.