PDA

View Full Version : Need help!



Alan W
04-20-2000, 05:22 AM
I have the visual C++ 6.0 compiler and I tried to read in obj files in my program with Nate Robin's glm.h and glm.c files. Every time I tried to run a program, it would give me unresolved external symbols. I didn't create a library like others told me (because I don't know what to put in the library), and found that the program will link fine and compile if you: put glm.c in the source files of the project along with your main source file, put glm.h in the header files and put glm.c, glm.h and glut.h in the external dependencies. I tried to compile this, and i got no unresolved symbols...woohoo!

However, when it loaded, all it appears to do is clear the buffers and draw a black background. Here is the code I used:

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glut.h>
#include <glm.c>
#include <math.h>

void DrawModel(void);

GLMmodel* pmodel=NULL;

void initOpenGL(void)
{
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glShadeModel( GL_SMOOTH );
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glEnable( GL_DEPTH_TEST );
}

void renderscene(void)
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f( 1.0, 1.0, 1.0 );

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

DrawModel();

glFlush();
}

void ChangeSize( int w, int h )
{
glViewport( 0,0, 500, 500 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();

gluLookAt( 0.0,0.0,3.0,0.0,0.0,0.0,0.0,1.0,0.0 );
gluPerspective( 60.0, 1.0, 1.0, 10.0 );

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}

void DrawModel(void)
{
//al.obj is an obj file Nate Robins used for one of his projects....I was too lazy to make my own
pmodel= glmReadOBJ("data/al.obj");

glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);

glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL );
}

int main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize( 500,500 );
glutInitWindowPosition( 100,100 );
glutCreateWindow("GLM Test");

initOpenGL();
glutDisplayFunc( renderscene );
glutReshapeFunc( ChangeSize );

glutMainLoop();

return 0;

}

I can't find any problems, if anyone knows what the problem is, or finds some flaw in the code, please e-mail me at cppking@home.com, or reply to this message. Thanks!!!!

FATBUDDHA
04-21-2000, 05:11 AM
I don't know what the problem is with your code, but I'd try out the following:

1. Put some other object (a simple polygon or something) in the DrawModel function, and check that you can see it.

2. Maybe you should be settings the z-depth clearing value?

I've never used these functions so I can't really help anymore I'm afraid. Good luck with it.