85 | | |
| 85 | * Native stuff: |
| 86 | * This will be a pain in the ass. JOGL requires its own jars and native libs in order to function. [https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=11509&expandFolder=11509&folderID=11508 Here] you can find binaries and libraries for different platforms for the current stable release 1.1.1. |
| 87 | * My setup: |
| 88 | * Ubuntu 8.04 32 bit |
| 89 | * I use [http://download.java.net/media/jogl/builds/archive/jsr-231-1.1.1a/jogl-1.1.1a-linux-i586.zip this] download. |
| 90 | * I add the two jars as external libs in Eclipse |
| 91 | * My JDK dir is '''/usr/lib/jvm/jdk1.6.0_14/''', so I put the four .so files in '''/usr/lib/jvm/jdk1.6.0_14/jre/lib/i386/'''. Something more clever must be thought of (: |
| 92 | * I've got no idea how this works under MacOSX or Windows. Something with Pav's build script must be done to get deployment right. |
| 93 | * There is also a compiler settings problem with these libraries. For every reference to these libs, you get a "Forbidden reference" error in Eclipse. This has to do something with Ganymede+ and some new policy. I guess that maybe using a later version of JOGL will be ok, I'm not sure. There is a JOGL 2.0 version but it's not stable yet. I guess I'll try using it in the next revision. |
| 94 | * The quick fix in Eclipse is to go to Windows->Preferences->Java->Compiler->Errors/Warnings->Deprecated And Restricted API and set the "Forbidden reference" field to "ignore" (: Currently I don't have a better solution to this problem. |
| 95 | * Real design stuff: |
| 96 | * I'll use the main.scene.jogl module finally |
| 97 | * Inside I'll create a JoglSceneVisual which will be analogical to SimpleSceneVisual but will provide a different swingComponent() which is OpenGL-powered. Actually it is called GLJPanel and is designed to have good integration with Swing. |
| 98 | * I'll provide an extension in the MainSceneJoglModule for this JoglSceneVisual. |
| 99 | * This new swingComponent will have a method analogical to paintComponent in the SimpleSceneVisual.ScenePanel component which will call a new method SceneHelper.paint(). This method won't have a Graphics2D as a parameter but a GLAutoDrawable which is the drawing surface in JOGL which I'll use. |
| 100 | * The new SceneHalper.paint(GLAutoDrawable ...) method will mimic the logic in the old SceneHelepr.paint(Graphics2D...) method but with JOGL draw primitives. |
| 101 | * The new SceneHalper.paint(GLAutoDrawable ...) will call a new ElementHelper.drawContent(GLAutoDrawable...) method which will mimic the old ElementHelper.drawContent(Graphics2D...) method but done with JOGL draw primitives. |
| 102 | * Each ElementHelper will have its own new implementation of this drawContent(GLAutoDrawable...) method. |
| 103 | * I'll need some util functions which I'll place in a SceneUtil class in org.sophie2.base.scene.util. |
| 104 | * There will be a transformation from an ImmMatrix to a float[16] representation, which is needed by OpenGL. |
| 105 | * There will be a helper method for loading and BufferedImage in memory and displaying it as a texture in OpenGL. |
| 106 | * I'll put some other minor helper functions there. |
| 107 | * More details on the implementation of different ElementHelpers: |
| 108 | * ShapeElementHelper / ContourElement: |
| 109 | * I'll iterate over the Shape boundary path and draw what's needed. |
| 110 | * ImageElementHelper: |
| 111 | * I'll convert the BufferedImage to a GL texture and span it over a rectangle in the Scene. |
| 112 | * (Hot)TextElementHelper: |
| 113 | * I'll reuse the existing implementation with Graphics2D - I'll create an off-screen BufferedImage, draw the text there and then treat it as an image. |
| 114 | * VideoElementHelper / AudioElementHelper: |
| 115 | * Will do them in next revision. |
| 116 | * CompositeelementHelper: |
| 117 | * Won't need any special treatment. |
| 118 | * SwingElementHelper: |
| 119 | * Won't implement it because we'll soon throw it away. |
| 120 | * I'll update SimpleSceneDemo and it should work like before by only changing the SceneVisual used. It now works like the original with some minor differences but ~10x faster. |
| 121 | * Sophie runs with the new implementation, though quite buggy and there are itnegration problems which I'll fix in the next revision. |
| 122 | * I already described some of the implementation details but here are some useful links: |
| 123 | * http://pepijn.fab4.be/software/nehe-java-ports/ -- the famous NeHe OpenGL lessons, ported to JOGL. Veeeeeery useful (: |
| 124 | * https://jogl-demos.dev.java.net/ -- a big pile of JOGL demos. |
| 125 | * This implementation is mostly visual, so no tests for now. |