Opengl Tutorial Java

1 view
Skip to first unread message

Elvisa Schimke

unread,
Aug 4, 2024, 1:24:55 PM8/4/24
to quoflexerstor
Iusually put this annoying little step in an installation script. I custom-made a zipped JRE for each platform, and I have the script unzip them into the right directories during the install process.

The Eclipse plugin fragment mechanism (the one we used to create the JOGL plugin fragments in the project) also contains the magic that allows us to build a single application that can run on five different OS/HW platforms. When you launch your exported application, the Eclipse framework finds the correct native JOGL libraries for the current platform (which it zipped up in the export process) and unzips them into a temporary directory where the JVM can find them.


Thanks for the quick reply! I thought I had looked for a log file, but maybe I missed it due to the hidden nature. Anyhow, that revealed that I had bungled when making my JOGL projects and left out some files. Adding them fixed the problem.


You might also try checking the log files (both the Eclipse workspace .metatdata/.log file, and the log file created in the export directory when you try to export your project). Sometimes the export process can fail, and the log will contain more info than it shows you in the console.


Sorry for keeping you hassled, but I create a new plug in project, set it to be a RCP project, eclipse generates an application.java file which outputs some text to the system.out. I take this project, right click it and create a product for it, export it for windows x86, x86_64. It exports fine, but no executable is generated in the target folder?


Renamed the .metadata filter, since I run windows vista I of course had no initial permission to do but resorting to some tricks that tired old bag of rotting cabbage gave up. I managed to produce one product that generated an .exe file(not using the delta pack). I then managed to produce my stuff, also generating a .exe, without that incomprehensible error message. However, when I try to run it I get this:

java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)

at org.eclipse.equinox.launcher.Main.run(Main.java:1410)


After some experimentation I found that I need to have org.eclipse.core.runtime in the start levels(and it NEED to be set to auto start), as well as the plugin project for which the product is made. I did not need to do that for the HelloProduct I wrote, possibly because HelloProduct did not use any fragments. I think that is kind of weird, because the runtime is included in the dependencies as well.


Now I am trying to find the error log the RCP outputs, because it rudely shuts down the console box. My ninja like reflexes coupled with the print screen key however allowed me to take a picture of the console box just before it closes, and it appears that an exception is thrown when compiling one of the shaders(a debug shader for looking at array textures).


Sorry for double posting, but I finally found the solution: AT LEAST for the following configuration, eclipse delta pack does not work:

windows vista SP 2, using Eclipse 3.7.2 with Delta pack 3.7.2.

What I did was that I actually downloaded a legacy version of Eclipse, the one you were using for this tutorial, as well the delta pack for that version, both 3.6.1.


You just need to create separate 32-bit and 64-bit fragments for the two different OS versions, rather than putting them together in the same fragment (as you probably saw in my first tutorial). Just let me know if you need any more help.


I know its jan 13 now, but I just stumbled across this web page. I have created my own RCP before with no problems on my laptop (win 64 bit) using eclipse indigo. Yesterday i started a new RCP on my desktop (win 32 bit) also eclipse indigo and everything seems to be working properly. But when I launch the exe a window pops up along with the application GUI. The window has the icon and the directory where it is launching from in the title and then the body of the window is black (looks like a windows command window). There are two icons on my task bar. This did not happen on my previous program. Have you had this problem before? And any ideas as to how i can prevent this from happening?


In this tutorial, we will learn how to create 3D graphics applications using Java OpenGL (JOGL). JOGL is a Java binding for the OpenGL API, which allows Java developers to access native OpenGL functionality in their applications. By the end of this tutorial, you should have a good understanding of how to create and manipulate 3D graphics using JOGL in Java.


Add these JAR files to your project's build path. The process may vary depending on your IDE. For example, in IntelliJ IDEA, you can add the JAR files by right-clicking on your project, selecting "Open Module Settings", and then adding the JAR files to the "Libraries" section.


Now, you have a basic JOGL application with a window and a GLCanvas inside it. The GLCanvas will call the GLEventListener methods when required, such as when the window is resized, or when it's time to draw a new frame.


In this tutorial, we covered the basics of creating a 3D graphics application using Java OpenGL (JOGL). We showed you how to set up the JOGL library, create a basic application window, and draw 3D shapes. There's much more to learn about JOGL and 3D graphics in Java, so we encourage you to explore further and build more complex applications.


In Java OpenGL (JOGL), GLEventListener is an interface that can be implemented by classes interested in receiving OpenGL events. It defines methods for initialization, drawing graphics, cleaning up resources, and responding to the window being resized. Learn more


An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools and a debugger. Some popular IDEs for Java include Eclipse, IntelliJ IDEA, and NetBeans.


The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (javadoc), and other tools needed in Java development. Learn more


Java OpenGL (JOGL) is a Java library that provides a binding for the OpenGL API, enabling Java developers to access native OpenGL functionality within their applications. It is widely used for creating interactive 3D graphics applications. Learn more


JOGL is the OpenGL binding for Java(JSR-231),mapping functions asclosely as possible from C.OpenGL is a standardized API used to draw3D graphics to the screen (similar to DirectX / Direct3D).The primary difference to 2D is that you need to think about zcoordinates and theposition of the viewer ("camera", including viewing angle and such).


I am writing this JOGL tutorial because I did not find another goodone. The JOGL homepage ispoor in information, the few tutorials aremostly outdated (not using newer functions, e.g. for textures orfonts), and thefamous NeHe OpenGLtutorials are for pure OpenGL under C (Java portavailable though). The best API doc I found is the PythonOpenGL API (better than the JOGLjavadoc).


First, a few words on how OpenGL works: Procedural. You start athread that repeatedly calls a display()method at your fps (frames per second) rate; in this method, you clearthe screen and rebuild the entire scene. You do this by issuingprimitive commands: Begin vertex, this is the 1st point, the 2nd point,the 3rd, end vertex. And so on.


Of course, it gets more complicated for textures, lighting and thelike, but the bottom line is that there is one GL object whichhas like 1000 glWhatever() methodsthat you will call over and over again. Yes it is primitive but near tothe hardware, and this means fast and flexible.


To integrate with Java, there have to be some concessions: Namely,the AWT component (a GLCanvas extending Component)is integrated into the AWT event queue, and you need to implement alistener (GLEventListener)for lifecycle callbacks (not so procedural here, aint it).


A positive z coordinate is coming out of the screen,a negative into the screen. The camera position isdetermined by one point to be in, another point to look at, and avector defining where your head is pointing into the sky (well, and aviewing angle, but more on that later). With that, lets start doing abit 3D!


The capabilities simply define what you want from the underlyingOpenGL implementation. If the machine cannot do this, an exception willbe thrown and you know what will work and what wont. Now going to the init()method:


A little more lines here. At first, you can notice the GLobject:This is the one that we will issue most commands on. As a nice featureof JOGL, we can decorate it with a DebugGL, which will supplyus with stacktraces on exceptions (as opposed to simply crashingas it does in C).


Next, some global settings (here: my standard settings). The firsttwoenable z-buffers (always needed for 3D drawing - you could also useOpenGL to do 2D only) with last-one-wins settings (draw a rect, and aline on it, the line will still be visible). A shade model of GL_SMOOTHlooks nice, as does the GL_NICEST correction hint. The clearcolor is the CLS (ClrScr) color: Black with no translucency (alpha is 1),specified as RGBAin floats.

3a8082e126
Reply all
Reply to author
Forward
0 new messages