Ok, I’ve been working on a multi-textured, lighted scene. I removed an item (A rotating cube, and sphere) and I now have a problem, a warning actually, and it is messing up the rendering,
here is the code:
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
if (!LoadGLTextures()) // Jump To Texture Loading Routine
return FALSE; // If Texture Didn’t Load Return FALSE
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Create Texture Coords
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
glLightfv(GL_LIGHT2, GL_AMBIENT, RoomAmbient);// Position The Light
glLightfv(GL_LIGHT2, GL_DIFFUSE, LightRoom);
glEnable(GL_LIGHTING); // Initialization Went OK
warning C4715: ‘InitGL’ : not all control paths return a value
And don’t worry about my commenting
please help. I am new to all this.
[This message has been edited by ThinIce (edited 02-04-2002).]
You need to return a value, since your routine is of type “int”. Stick a
before the final closing brace, that should fix things.
Umm, that fixed the warning, but not the rendering
Here is a link to my server, and the C++ files. (it isn’t always on, but it is on a bit, whenever I am on the comp. Its a zipfile, I’m sure you have WinZip.
~200Kb, c++ files, headerm and Workspace file.
You should see what I mean by the rendering
Alright, I got the files, and I’m looking them over. Please describe the behavior that you’re seeing? The screen just flickers, and doesn’t seem to draw much of anything for me after I built your code… is this what you meant by “rendering problems”?
Edit: Ok, I ran it in a window, and it looks different, but worse… Hang on, I’m trying something with your code…
[This message has been edited by yakuza (edited 02-04-2002).]
Thanks, No, it doesn’t really render anyhing visable. It just shows a scrambeled mess of colors.
Ok, I figured it out… you’re not clearing the depth buffer before you draw, add this to the file GFX.cpp in DrawGLRoom() :
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
I also did the following changes to your code:
and comment out:
I also had to comment out in file hdrgfxogle.h:
extern GLfloat z=-7.3f;
It was causing a link error, and I didn’t feel like taking the time to figure it out. This now builds and renders successfully for me, and I think that’s all the changes I made. Let me know if you don’t understand or have troubles.
Thanks! The glClear(); Fixed the whole problem. I had the circle and cube with that code, and it applied to the rest of the functions included in my DrawGLScene().
That was my error, Phew! Thanks for catching that one for me! Thanks a million!
Glad to have helped, I’m a relative newbie myself, so it feels good to be able help a little.