This is a quick 'n dirty page, where I will try and jot down some of the problems I've encountered while trying to get the hang of openGL.
| One of my first attempts at 3D uses GLUT. I don't remember whether it uses lighting, but it does contain a texture mapped quad. The RGB axis are my XYZ world axis. windows executable You need this texture as well | |
![]() |
screenshot of my first attempt to import an object with the lighting correct. The purple lines are the normals in each vector made visible (a GL_LINE from vertex to (vertex+normal)), and they're obviously screwed up. |
![]() |
Fixed the previous bug with the normals. This object contains about 2000 GL_TRIANGLES, and I had a framerate of about 25-30. Since this is passed to openGL as a single vertex array, I have no idea how I can make it go faster. |
![]() |
As you can see, though, there is still a problem. The normals are not
perpendicular to the surface, and so the wrong sets of surfaces light up. The actual
light iluminating this scene is somewhere on the right-hand side, even though
it looks like the left side of the cylinder lights up more. You'll see that the
normals point to the right, in the direction of where the light actually is.
From what I can tell, this is not a problem in my source, but in ASE. I think. Or am I wrong ? Whatever the cause was, I gave up on ASE, and I started converting Alias/Wavefront .obj files into my very own format. There are no lighting anomalies, so I think it was a problem with ASE. |
![]() |
YAY ! I'm very proud of this one. Model created in 3d studio and exported to
Alias/Wavefront object, then applied uvmapper,
and drew a texture from scratch with PSP 6.0
The tank consists of 25 triangles, in an interleaved array. The red, green and blue line sticking out of the tank are my world x,y and z axis respectively. Executable and datafiles for win98 |
![]() |
The part where the barrel goes into the turret has some problems, and I can't figure
out why. To make it even more complicated, this problem does NOT exist when I draw my
frame in a window (see previous screenshot). In full screen, though, I get this jagged
line that has nothing to do with pixelwidth or anti-aliasing. It looks like a depth-test
problem, but then why don't I have the same in windowed mode ?
Paul Marz at the openGL newsgroup helped me out. In full screen (16 bit color), my depth buffer was only 16 bits wide. Apparently, I can't choose a 24bits depth buffer is the color depth is only 16 bits. Go figure. |
![]() |
The terrain is a rough 1800 triangles with one texture. The framerate in 640*480 full screen mode is maxed out at my vertical refresh rate. But in windowed mode, with a window size of about 1152*864, my framerate drops to +/- 30. I guess I'm pushing my fill rate, right now. |
![]() |
Disabling one out of two lights seems to work wonders. This patch of terrain
contains a rough 3900 triangles, stored in a display list, and the framerate is
around 40 fps !
I fiddled around with the remaining light so that it would give a maximum depth effect. |
![]() |
Yeeha ! Same code as the previous shot, but now with a patch of 257*257 squares,
or a sloppy 130000 triangles ! I'm amazed it doesn't just crash. With
one normal per square, four 2-dim texture coordinates and four 3-dim coordinates,
this is almost ten meg of raw data, not counting the overhead.
The textures -a 32x32 bitmap applied to each square- have been reduced to simple colors, because I'm looking at it from such a distance. Some of the depth effect of the previous shot is lost. |
![]() |
I'm making a terrain editor now, and I want the far-away triangles to fade
away, rather than to suddenly disappear when they hit the rear plane of the
frustrum. I'm using a fog color of (0,0,0,0), so I figured that for far away
geometry, the alpha channel should be 0, right ?
The background image is a red-and-yellow sky, with two suns to the right. So after all the geometry has been rendered, I blend in the background picture, and I use glBlendFunc( GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); but as you can see, the far distance fades to red, it does not fade to transparent. What am I doing wrong ? Somebody explained that the fog alpha channel doesn't have any effect whatsoever. Darn. I'll have to throw away that really nice looking background for now and simply go with a fade to black. It doesn't look as cool, but I'm too lazy to code any hacks that will have the desired effect. |
![]() |
Dropped the background, added more normals for a smoother lighting.
I have packed the Win98 executables and bitmaps. A bit of an explanation, perhaps? The textures on the terrain are not at all good looking at the moment. The idea is that I have several parts: a square of water, a square of grass, and a square where grass fades into water. By applying these textures strategically, I should be able to create a decent looking terrain. Right now, though, the different elements of the puzzle are thrown randomly on the terrain, so you'll find a bunch of squares where grass fades into ice right next to each other, even though it doesn't "fit". The buttons don't do anything. A mouseclick on the terrain will tell you where in the heightmap you clicked (useful for terrain editing) The logo was my first test of blending. ESC exits. The arrow keys move you around. SHIFT + arrow keys move only the target, at which you are looking (use to rotate). The 'z' key (in conjunction with SHIFT) move you up and down. |