Java and JOGL for serious Game development?

Started by
5 comments, last by xranby 9 years, 8 months ago

Hi,

I've recently being having a lot of headaches with C++ and OpenGL, I upgraded my OS to Ubuntu 14.04 and a few of my applications have stopped working and are throwing GLSL compilation errors. This is obviously due to the differences in opengl versions, is there anyway to enforce a particular version of opengl consistently throughout the development of a project in C++? I recently developed an opengl app on android and all the opengl methods were encapsulated in a GL10 class which made things so much easier... going back to C++ just makes me feel dizzy :(

I've always used GLEW, an extension library, which I believe (could be wrong here) is required to actually use any opengl API above 1.0 ? but I don't know if there is any way to throw a compiler error if the opengl version is incorrect. Also, I'm not entirely sure how I would install a previous version of opengl on my machine, it use to be that it was fully backwards compatible so that wasn't really an issue but they've removed a lot of methods in later versions of opengl.

I'm thinking about switching to using Java and JOGL for any future applications I develop because of this but I'm concerned about performance, has anyone here developed any graphically demanding games in Java/JOGL?

Thanks.

Advertisement


I'm thinking about switching to using Java and JOGL for any future applications I develop because of this but I'm concerned about performance, has anyone here developed any graphically demanding games in Java/JOGL?

If you do this you will soon say "I was having trouble with my OpenGL, so I switched to JOGL, and now I have two problems."

If you look at the documentation for the different JOGL versions you'll see that it isn't going to fix anything (scroll to the picture at the bottom).

http://jogamp.org/jogl/doc/Overview-OpenGL-Evolution-And-JOGL.html

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Ok, so I'm running OpenGL 3.0, one of the first things I do in code is check my GL version number to make sure it is compatible through GLEW:


	if(!GLEW_VERSION_2_1)
	{
		cerr << "OpenGL version 2.1 or higher required" << endl;
		return false;
	}

When I compile my shaders I get the error:

error: 'in' qualifier in declaration of 'position' only valid for function parameters in GLSL 1.10.

> in vec3 position;

Even though the GLSL version should be at least 1.20.8 according to this: (for OpenGL 2.1)

http://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions

This is what is causing my headaches, I'm not sure if this is an error on my part or an error with GLEW.

Ok, so I'm running OpenGL 3.0, one of the first things I do in code is check my GL version number to make sure it is compatible through GLEW:


	if(!GLEW_VERSION_2_1)
	{
		cerr << "OpenGL version 2.1 or higher required" << endl;
		return false;
	}
When I compile my shaders I get the error:

error: 'in' qualifier in declaration of 'position' only valid for function parameters in GLSL 1.10.

> in vec3 position;

Even though the GLSL version should be at least 1.20.8 according to this: (for OpenGL 2.1)

http://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions

This is what is causing my headaches, I'm not sure if this is an error on my part or an error with GLEW.


It is most likely an error on your part, the in qualifier is only valid in the global scope (with some restrictions) and in function parameters, i would guess that the error is caused by you using the in qualifier in a local scope. (Allthough its just a guess, i havn't seen your code so ...)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Ok, so I'm running OpenGL 3.0, one of the first things I do in code is check my GL version number to make sure it is compatible through GLEW:


	if(!GLEW_VERSION_2_1)
	{
		cerr << "OpenGL version 2.1 or higher required" << endl;
		return false;
	}
When I compile my shaders I get the error:

error: 'in' qualifier in declaration of 'position' only valid for function parameters in GLSL 1.10.

> in vec3 position;

Even though the GLSL version should be at least 1.20.8 according to this: (for OpenGL 2.1)

http://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions

This is what is causing my headaches, I'm not sure if this is an error on my part or an error with GLEW.


It is most likely an error on your part, the in qualifier is only valid in the global scope (with some restrictions) and in function parameters, i would guess that the error is caused by you using the in qualifier in a local scope. (Allthough its just a guess, i havn't seen your code so ...)

It was defined in global scope, although I updated my drivers and it seemed to fix the problem. It was using an incorrect version of GLSL.

Always specify the GLSL version you want to use by using:

#version 150

In your shader files. Replace 150 by whatever version you want to use (120, 330, etc)

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator


I'm thinking about switching to using Java and JOGL for any future applications I develop because of this but I'm concerned about performance, has anyone here developed any graphically demanding games in Java/JOGL?

If you do this you will soon say "I was having trouble with my OpenGL, so I switched to JOGL, and now I have two problems."

If you look at the documentation for the different JOGL versions you'll see that it isn't going to fix anything (scroll to the picture at the bottom).

http://jogamp.org/jogl/doc/Overview-OpenGL-Evolution-And-JOGL.html

The graph illustrates that JOGL gives you an object oriented representation of all possible OpenGL profiles _all_ supported using the latest version of JOGL.

This is a good thing because you can then use a Common OpenGL Profile Subsets of OpenGL that is then at compiletime guaranteed to work on both mobile and desktop systems!

  • GL2ES2 Interface containing the common subset of GL3, GL2 and GLES2. <- this is a good choice if you want to target as many devices as possible, the GLSL syntax compiled by the GPU driver can differ thus you need to think of what you send to the GPU.
  • GL3ES3 Interface containing the common subset of core GL3 (OpenGL 3.1+) and GLES3 (OpenGL ES 3.0).
  • GL4ES3 Interface containing the common subset of core GL4 (OpenGL 4.0+) and GLES3 (OpenGL ES 3.0). <- this is a good choice if you want to target the latest hardware, the GLSL syntax between mobile and desktop opengl drivers are now identical

I recently developed an opengl app on android and all the opengl methods were encapsulated in a GL10 class which made things so much easier

Thus yes by switching to JOGL you will get this interface class behaviour on both mobile and desktop,

you can sure at compiletime that you only use OpenGL function calls that belong to the OpenGL profile you want to use!

I upgraded my OS to Ubuntu 14.04 and a few of my applications have stopped working and are throwing GLSL compilation errors

You can ask JOGL to give you a specific profile that support the "old" GLSL shaders.

GPU drivers will refuse to compile "old" GLSL shaders if you have requested a "default" profile and then recived say a GL4 profile with backward compatible code removed.

Here are some guidelines how to write GLSL shaders that work on both mobile and desktop opengl profiles

http://jogamp.org/wiki/index.php/How_to_write_cross_GLProfile_compatible_shader_using_JOGL

This topic is closed to new replies.

Advertisement