I want to model my room in OpenGL and when I created my first object and followed some tutorials what and how to do, upon loading the object in my Visual Studio 2013 Professional application I get the following errors:
Warning 1 warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification d:\Egyetem\Semester 5\Graphic processing systems\Project\OpenGLApplication\OpenGLApplication.obj OpenGLApplication
Error 2 error LNK2019: unresolved external symbol "float __cdecl glmUnitize(struct _GLMmodel *)" (?glmUnitize@@YAMPAU_GLMmodel@@@Z) referenced in function "void __cdecl drawModel(struct _GLMmodel * *,char *,unsigned int)" (?drawModel@@YAXPAPAU_GLMmodel@@PADI@Z) d:\Egyetem\Semester 5\Graphic processing systems\Project\OpenGLApplication\OpenGLApplication.obj OpenGLApplication
Error 3 error LNK2019: unresolved external symbol "void __cdecl glmFacetNormals(struct _GLMmodel *)" (?glmFacetNormals@@YAXPAU_GLMmodel@@@Z) referenced in function "void __cdecl drawModel(struct _GLMmodel * *,char *,unsigned int)" (?drawModel@@YAXPAPAU_GLMmodel@@PADI@Z) d:\Egyetem\Semester 5\Graphic processing systems\Project\OpenGLApplication\OpenGLApplication.obj OpenGLApplication
Error 4 error LNK2019: unresolved external symbol "void __cdecl glmVertexNormals(struct _GLMmodel *,float)" (?glmVertexNormals@@YAXPAU_GLMmodel@@M@Z) referenced in function "void __cdecl drawModel(struct _GLMmodel * *,char *,unsigned int)" (?drawModel@@YAXPAPAU_GLMmodel@@PADI@Z) d:\Egyetem\Semester 5\Graphic processing systems\Project\OpenGLApplication\OpenGLApplication.obj OpenGLApplication
Error 5 error LNK2019: unresolved external symbol "struct _GLMmodel * __cdecl glmReadOBJ(char *)" (?glmReadOBJ@@YAPAU_GLMmodel@@PAD@Z) referenced in function "void __cdecl drawModel(struct _GLMmodel * *,char *,unsigned int)" (?drawModel@@YAXPAPAU_GLMmodel@@PADI@Z) d:\Egyetem\Semester 5\Graphic processing systems\Project\OpenGLApplication\OpenGLApplication.obj OpenGLApplication
Error 6 error LNK2019: unresolved external symbol "void __cdecl glmDraw(struct _GLMmodel *,unsigned int)" (?glmDraw@@YAXPAU_GLMmodel@@I@Z) referenced in function "void __cdecl drawModel(struct _GLMmodel * *,char *,unsigned int)" (?drawModel@@YAXPAPAU_GLMmodel@@PADI@Z) d:\Egyetem\Semester 5\Graphic processing systems\Project\OpenGLApplication\OpenGLApplication.obj OpenGLApplication
Error 7 error LNK1120: 5 unresolved externals d:\Egyetem\Semester 5\Graphic processing systems\Project\OpenGLApplication\Debug\OpenGLApplication.exe OpenGLApplication
Here is my code, very simple, just loading and visualizing the object:
// OpenGLApplication.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "glut.h"
#include "glm.h"
#include <gl/gl.h>
#include <math.h>
int screen_width=1366;
int screen_height=768;
GLMmodel *bed;
void initOpenGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glViewport(0, 0, screen_width, screen_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)screen_width/(GLfloat)screen_height, 1.0f, 1000.0f);
glEnable(GL_DEPTH_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
}
void drawModel(GLMmodel **pmodel, char*filename, GLuint mode)
{
if (!*pmodel){
*pmodel = glmReadOBJ(filename);
if (!*pmodel){
exit(0);
}
glmUnitize(*pmodel);
//generate facet normal vectors for model
glmFacetNormals(*pmodel);
//generate vertex normal vectors (called after generating facet normals)
glmVertexNormals(*pmodel, 90.0);
}
glmDraw(*pmodel, mode);
}
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, -10.0, 0.0, 1.0, 0.0);
glPushMatrix();
drawModel(&bed, "castle.obj", GLM_NONE | GLM_FLAT);
glPopMatrix();
glutSwapBuffers();
}
void changeSize(int w, int h)
{
screen_width=w;
screen_height=h;
if(h == 0)
h = 1;
float ratio = 1.0*w/h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45.0f, ratio, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 50.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f);
}
void processNormalKeys(unsigned char key, int x, int y)
{
switch(key)
{
case 't':
//process
glutPostRedisplay();
break;
}
}
int main(int argc, char* argv[])
{
//Initialize the GLUT library
glutInit(&argc, argv);
//Set the display mode
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
//Set the initial position and dimensions of the window
glutInitWindowPosition(100, 100);
glutInitWindowSize(screen_width, screen_height);
//creates the window
glutCreateWindow("First OpenGL Application");
//Specifies the function to call when the window needs to be redisplayed
glutFullScreen();
glutDisplayFunc(renderScene);
//Sets the idle callback function
glutIdleFunc(renderScene);
//Sets the reshape callback function
glutReshapeFunc(changeSize);
//Keyboard callback function
glutKeyboardFunc(processNormalKeys);
//Initialize some OpenGL parameters
initOpenGL();
//Starts the GLUT infinite loop
glutMainLoop();
return 0;
}
Possible mistakes that I was thinking of (or found on Google or here) and did not change anything:
tried to set project -> linker -> general -> enable incremental linking=NO
glm.cpp, glm.h, glut.h, glut32.dll, glut32.lib, StdAfx.h, StdAfx.cpp are in the project directory
the object and it's .mtl file are in the project directory
Can anyone help me with finding out why I cannot load this object?