by the way all the nehe tutorials works on morphos too(excepte the shader one), just replace the windows code with the glut equivalent :D
Actually there's usually no need to replace, as there are links to "ports" to various other API's (glut, SDL) at the bottom of most tutorials.Quote:
the nehe site is a must for anyone who approach opengl ( iremember reading it in 2002) :D
I agree, it's important to know NeHe if you're learning OpenGL. It's important to know to avoid
I started with NeHe's tutorials but later I heard these were perfect examples about what you should not do
I fully agree. Of course it's very farm from OpenGL 4.0 or even 2.0 (which already had shaders), which is pretty far from TinyGL aswell. But the thing is, the functionality used to draw in 90% of these tutorials hasn't been relevant since very first OpenGL versions, and even TinyGL can do better than that.
In "non-OpenGL terms", NeHe is using:
for(y=0; y<h; ++y)
for(x=0; x<w; ++w)
You are free to guess which one is both faster and more preferable.
Not only that, it often also uses immediate mode in needlessly slow way (like drawing GL_QUADS from array, each within their own glBegin() ... glEnd() block)
And no, vertex arrays aren't really THAT much faster to draw, but compared to immediate mode (glBegin(), glVertex() etc. crap) they're:
1)In 99.9% of cases, more "clean" approach
2)Really close to the REALLY fast way to draw (which TinyGL doesn't currently support, but will probably do some day)
3)Not incompatible with OpenGL ES (OpenGL for mobile devices)
While they are deprecated, VBO's aren't, and they are quite close to each other. As long as TinyGL doesn't support VBO (and shaders), we have no other choice but use deprecated functionality
Here is quite useful comparison between immediate mode and vertex arrays
Also, it's of course a VERY good idea to do your own DrawObject(struct MyObject *object); that will hide the boring details from most of the code.
Few hints on writing OpenGL code with MorphOS:
Immediate mode: glBegin(), glEnd(), glVertex() etc. - AVOID
NOTE: You should NEVER use previously listed functionality!
glColor() - Even if often used with immediate mode, this is ok for setting a constant color for further vertices to draw.
glNormal(), glTexCoord() - As with glColor(), although it's quite rare to set these to a constant value.
glTranslate(), glLoadMatrix(), glMultMatrix() etc. - These are the way to do transformations.
glMatrixMode() - Used to change which matrix to apply changes to. Don't do glFrustum(), glOrtho(), gluPerspective() or similar each frame (unless its arguments change). In most cases,this belongs to your reshape function.
of the previous functionality is deprecated, and done quite differently in "modern" OpenGL, which we cannot currently use on MorphOS.
glEnableClientState(), glVertexPointer() (and equivalent for normals, texcoords, color), glDrawArrays(), glDrawElements() - While deprecated, the "idea" is generally the same (but used functions different) with modern OpenGL. Give OpenGL a pointer to elements, which it will draw. Of course you want to use VBO (upload the data to graphics ram) when possible. You can do this with few #ifdef's if you want to compile your code also for platforms that already support it.
GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN - These are still around in every OpenGL (or OpenGL ES) implementation. Use freely.
NOTE: all previous functionality (except immediate mode) works with OpenGL ES1. OpenGL ES2 uses shaders extensively, and it's not possible to write code that works both on current TinyGL and OpenGL ES2 without using lots of #ifdefs or similar, assuming you do something more complex than clear the screen with the specified color.
GL_QUADS, GL_QUAD_STRIP, GL_POLYGON - AVOID. Deprecated, and missing from both OpenGL ES1 and ES2. Use indexed GL_TRIANGLES or GL_TRIANGLE_STRIP instead.
This thread would be better called "non-MorphOS OpenGL how-not-to"