开发者

can you create a 3D component using JOGL?

(system flagged this is being subjective but i don't see how, anyone explain ?)

Anyway, as my title asks,can you create a 3D component using JOGL? What I'm trying to do is, imagine an empty cylinder. You cut the cylinder in two halves and you're looking into one half. On the inside I want to stick images...not entirely sure to what purpose this will serve yet but i'm playing around with JOGL, been through the NEHE tutorials and others and the idea came to me from an app I saw on my phone.

I'm not sure how this would work but my first thought was that its proba开发者_JAVA百科bly needs to be a subclass of JPanel or JFrame for the sake of being able to easily add normal components, but then I'm not sure...

I know I need to become more familiar with JOGL but this is my little Christmas mission but I'd appreciate any suggestions on how i could do this (eventually) or if i should just leave it as an idea and continue to play with the API.


The essence of JOGL is that you create a Java component and render GL calls to it. This needs to be an implementer of GLDrawable (typically either GLJPanel if you are working with Swing and GLCanvas if you are not). You can then draw whatever 3D scene you want into it using the JOGL calls, and it behaves like the appropriate kind of Java Component (with a few restrictions).

The other thing you can do is draw your 3D scene offscreen to a GLPbuffer and then draw the resulting bitmap to the screen as part of the component.


Well ., first of all you need to setup Eclipse and create the JOGL library:

  • Go to the top menu bar, click Window -> Preferences and click new and type a name for your library, such as jogl-2.0. Leave the System library (added to the boot class path) checkbox unchecked and click ok.

  • Back in the user libraries panel, you should see your library appear and click add JARs.. and navigate to the location where you extracted your JOGL library and then open the 'lib' directory, which contains all the various JAR files and native libraries for JOGL. Select the following JARs: gluegen-rt.jar, jogl.all.jar, nativewindow.all.jar, newt.all.jar and click ok to add these four JARs to your user library. You should see them listed under jogl-2.0 now.

  • Click native library location and then edit on the right and select External Folder.. and navigate to the same directory all the JAR files for JOGL are in. This should be the 'lib' directory inside the location you extracted the JOGL files, and click ok.

Now you simply have to tell your project to use your JOGL user library, right click the project folder and select Properties, select Java Build Path and click -> Libraries tab at the top -> add library -> select user library and click next, then put a check mark next to JOGL-2.0 and click finish.

I hope that you want to make something created by you and not copied :)

Now ., put the code here to see what you have and if something is wrong.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜