PDA

View Full Version : Some help



ThinIce
02-04-2002, 12:22 PM
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_LIGHT1, GL_POSITION,LightPosition);
glLightfv(GL_LIGHT2, GL_AMBIENT, RoomAmbient);// Position The Light
glLightfv(GL_LIGHT2, GL_DIFFUSE, LightRoom);
glLightfv(GL_LIGHT2, GL_POSITION,RoomLightPos);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHT2);
glEnable(GL_LIGHTING); // Initialization Went OK
}

VC6++ says:

warning C4715: 'InitGL' : not all control paths return a value

And don't worry about my commenting http://www.opengl.org/discussion_boards/ubb/wink.gif
please help. I am new to all this.

[This message has been edited by ThinIce (edited 02-04-2002).]

yakuza
02-04-2002, 12:30 PM
You need to return a value, since your routine is of type "int". Stick a



return TRUE;

before the final closing brace, that should fix things. http://www.opengl.org/discussion_boards/ubb/smile.gif

ThinIce
02-04-2002, 01:03 PM
Umm, that fixed the warning, but not the rendering http://www.opengl.org/discussion_boards/ubb/frown.gif


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.
http://12.225.213.131/opengl.zip


~200Kb, c++ files, headerm and Workspace file.

You should see what I mean by the rendering

yakuza
02-04-2002, 02:16 PM
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... http://www.opengl.org/discussion_boards/ubb/smile.gif Hang on, I'm trying something with your code...

[This message has been edited by yakuza (edited 02-04-2002).]

ThinIce
02-04-2002, 02:26 PM
Thanks, No, it doesn't really render anyhing visable. It just shows a scrambeled mess of colors.

yakuza
02-04-2002, 02:35 PM
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:
In OGLECODE.cpp:



#include "hdrgfxogle.h"


and comment out:



int DrawGLScene();


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. http://www.opengl.org/discussion_boards/ubb/smile.gif 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.

ThinIce
02-04-2002, 02:55 PM
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!

yakuza
02-04-2002, 03:12 PM
Glad to have helped, I'm a relative newbie myself, so it feels good to be able help a little. http://www.opengl.org/discussion_boards/ubb/smile.gif