Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  OpenGL Tutorial's Need to talk about glCheckError()  (Read 901 times)
0 Members and 1 Guest are viewing this topic.
Offline quew8

JGO Coder


Medals: 29



« Posted 2013-12-19 15:27:47 »

This is a problem that I have always encountered but at the moment it seems to be occurring so frequently that I feel justified in posting this.

The problem is that beginners (sometimes even those with a fair amount of experience) to OpenGL are not checking OpenGL for errors (sometimes they aren't even aware that such a thing exists because they're so used to Java exceptions), hence they find that a function "isn't working" or that their whole screen goes black for "no reason."

When I started learning OpenGL, I approached it from The Red Book and I'm 80% certain that one of the first things it taught you to do was call glGetError(), and then kept telling you, because this is the first thing I do in any OpenGL program I write. Now I think that all the new tutorials people are writing (which are good - don't get me wrong) need to have this same insistence or at the very least a mention of this.

Now the discussion: Do people think that it would be appropriate to take some action on this front? Primarily I was thinking of an OpenGL specific please-read-before-posting thread in the Articles and Tutorials section. But what are other people's opinions?
Offline Axeman

Senior Member


Medals: 7



« Reply #1 - Posted 2013-12-19 15:58:46 »

Why not write a tutorial about glGetError(), how to use it and why?
Offline SHC
« Reply #2 - Posted 2013-12-19 16:06:59 »

That's true. I will modify mine to include this.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline quew8

JGO Coder


Medals: 29



« Reply #3 - Posted 2013-12-19 18:06:34 »

@SHC Thank you.

@Axeman Do you think that this deserves its own tutorial? As far as I can see there is nothing really to say on the topic other than "use it." I don't believe that people want to fish around for general tutorials, they want one that will take them through the process - like SHC's series. Stopping half way through to read my tutorial on the off chance that in the future something will go wrong with their code is not something many people will do even given the unlikely chance that they are aware of my tutorial.

Despite my forthcomings, it something that I am perfectly happy to do if there's any kind of general consensus here.
Offline tom_mai78101
« Reply #4 - Posted 2013-12-29 13:24:58 »

I advocate glCheckError()'s own tutorial. Possibly a tutorial on different ways to obtain/peek errors (log, status, etc.) with glCheckError in its own chapter/section.
Offline quew8

JGO Coder


Medals: 29



« Reply #5 - Posted 2013-12-29 14:23:55 »

Now that does sound like a good idea. I think most people would be happy to read a tutorial on how to debug their OpenGL applications.
Offline Danny02
« Reply #6 - Posted 2013-12-29 14:32:38 »

This is one reason why I dislike the static nature of LWJGL, JOGLs approach is much better in this regard.
JOGL provides you with an GL object to call OpenGL functions on. You then can set a Debug mode so that after each OpenGL call glCheckError is called which then can throw an exception or log the error.
Offline quew8

JGO Coder


Medals: 29



« Reply #7 - Posted 2013-12-29 14:39:06 »

@Danny02

A) That has nothing to do with static / instance bindings. It is perfectly possible using a static context. In fact, recently whilst writing an abstract "backend" for OpenGL calls to Android's OpenGL and LWJGL's OpenGL, I considered doing just that using an static context. The only reason I didn't was the overhead associated with error checking when it is only necessary in developing applications.

B) If I do write a tutorial, I will be sure to mention this (I've never used JOGL so I had no idea).
Offline Danny02
« Reply #8 - Posted 2013-12-29 15:39:55 »

The thing is that you can't inject a static context in Java. On the other hand you can of course inject an DebuglGL instance into something which needs a GL(interface) object. With this you can circumvent the overhead you are pointing at.

To go on with this a bit Wink, providing interfaces for all the different OpenGL version and letting them inherit from each other;
i.e. GL3 -> GL2 -> GL
does help to make the API more easy to use.

For example in LWJGL I always have to guess in which OpenGL version a specific function or method was added, I know that something is included in 3, but dunno if it was added in 1.0 1.2 or 1.5.

And something like this makes your codebase more type-safe of course. You can i.e. code with this in a way so that you can't use code which uses Shaders, when you only have a GL1 Context and not a GL2 one.
Offline tom_mai78101
« Reply #9 - Posted 2013-12-31 02:52:19 »

If you were to make GL classes inherit each other, it will make them have different OpenGL specifications mixed up, thus creating a mess on how to deprecate similar methods but entirely different functions.

I'd rather have all available constants from GL1.1 through GL4.4 in one place, while all methods are designated in their respective classes according to the specifications.

Also, method naming scheme probably can do a little upgrade:

glBegin() can be gl11Begin()
gl...() specific to GL3.0 can be gl30...()
glShader...() can be gl20Shader...(), or if it's GL4.X specific, it would become gl40Shader...()

(I don't know any GL functions, but at least my point is given.)

That way, you have your methods categorized.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #10 - Posted 2013-12-31 07:12:47 »

I'd rather have all available constants from GL1.1 through GL4.4 in one place, while all methods are designated in their respective classes according to the specifications.

1  
2  
3  
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL12.*;
...


And then you can do this:

1  
glBegin(GL_QUADS); //Just like in C!

Myomyomyo.
Offline quew8

JGO Coder


Medals: 29



« Reply #11 - Posted 2013-12-31 13:24:10 »

cough ... off topic ... cough. We all have our preferences. What a boring world it would be where everyone did everything the same. Could we maybe try to stay on topic.

Edit: Yes I know I did a bit but I was talking about the topic as well.
Offline tom_mai78101
« Reply #12 - Posted 2013-12-31 13:26:47 »

Oh don't worry, we're just waiting for you to write a tutorial on many different ways to debugging OpenGL, and obscure debugging techniques.
Offline quew8

JGO Coder


Medals: 29



« Reply #13 - Posted 2013-12-31 13:38:26 »

Oh I see. So until I write the tutorial, my thread will descend further and further into chaos. No pressure then.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (32 views)
2014-07-18 06:55:21

Zero Volt (28 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (25 views)
2014-07-16 23:30:00

Cero (40 views)
2014-07-16 00:42:17

Riven (42 views)
2014-07-14 18:02:53

OpenGLShaders (29 views)
2014-07-14 16:23:47

Riven (29 views)
2014-07-14 11:51:35

quew8 (26 views)
2014-07-13 13:57:52

SHC (63 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!