Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
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 1938 times)
0 Members and 1 Guest are viewing this topic.
Offline quew8

JGO Knight

Medals: 48

« Posted 2013-12-19 14: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 Devvie

Medals: 7

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

Why not write a tutorial about glGetError(), how to use it and why?
Offline SHC
« Reply #2 - Posted 2013-12-19 15: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 Knight

Medals: 48

« Reply #3 - Posted 2013-12-19 17: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 12: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 Knight

Medals: 48

« Reply #5 - Posted 2013-12-29 13: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 13: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 Knight

Medals: 48

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


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 14: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 01: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

« JGO Bitwise Duke »

Medals: 564
Projects: 4
Exp: 8 years

« Reply #10 - Posted 2013-12-31 06: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.

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL12.*;

And then you can do this:

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

Offline quew8

JGO Knight

Medals: 48

« Reply #11 - Posted 2013-12-31 12: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 12: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 Knight

Medals: 48

« Reply #13 - Posted 2013-12-31 12: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.

BurntPizza (19 views)
2015-10-07 02:11:23

KaiHH (15 views)
2015-10-06 20:22:20

KaiHH (11 views)
2015-10-06 19:41:59

BurntPizza (24 views)
2015-10-06 19:04:48

basil_ (44 views)
2015-09-30 17:04:40

shadowstryker (22 views)
2015-09-29 15:55:06

TheSpaceHedgehog (28 views)
2015-09-29 01:58:48

GamerC4 (54 views)
2015-09-24 21:10:38

GamerC4 (71 views)
2015-09-24 21:09:48

htuy (28 views)
2015-09-24 04:57:24
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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‑
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!