Glew problèmes externes non résolus
Je veux commencer à travailler avec OpenGL 3+ et 4, mais je vais avoir des problèmes pour obtenir Glew de travail. J'ai essayé d'inclure le glew32.lib dans les Dépendances Supplémentaires et je me suis déplacé à la bibliothèque, et .dll dans le dossier principal donc il ne devrait pas y avoir de problèmes de chemins. Les erreurs que j'obtiens sont:
Error 5 error LNK2019: unresolved external symbol __imp__glewInit referenced in function "void __cdecl init(void)" (?init@@YAXXZ) C:\Users\Mike\Desktop\Test Folder\ModelLoader through VBO\ModelLoader\main.obj ModelLoader
Error 4 error LNK2019: unresolved external symbol __imp__glewGetErrorString referenced in function "void __cdecl init(void)" (?init@@YAXXZ) C:\Users\Mike\Desktop\Test Folder\ModelLoader through VBO\ModelLoader\main.obj ModelLoader
Error 3 error LNK2001: unresolved external symbol __imp____glewGenBuffers C:\Users\Mike\Desktop\Test Folder\ModelLoader through VBO\ModelLoader\main.obj ModelLoader
Error 1 error LNK2001: unresolved external symbol __imp____glewBufferData C:\Users\Mike\Desktop\Test Folder\ModelLoader through VBO\ModelLoader\main.obj ModelLoader
Error 2 error LNK2001: unresolved external symbol __imp____glewBindBuffer C:\Users\Mike\Desktop\Test Folder\ModelLoader through VBO\ModelLoader\main.obj ModelLoader
Et ici est plus de mon code:
#define NOMINMAX
#include <vector>
#include <memory>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <Windows.h>
#include <cstdio>
#include <time.h>
#include "GL\glew.h"
#include "glut.h"
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "opengl32.lib")
using namespace std;
GLsizei screen_width, screen_height;
float camera[3] = {0.0f, 10.0f, -15.0f};
float xPos = 0;
float yPos = 10;
float zPos = -15;
float orbitDegrees = 0;
clock_t sTime;
float fPS;
int fCount;
GLdouble* modelV;
GLdouble* projM;
GLint* vPort;
//Lights settings
GLfloat light_ambient[]= { 0.1f, 0.1f, 0.1f, 0.1f };
GLfloat light_diffuse[]= { 1.0f, 1.0f, 1.0f, 0.0f };
GLfloat light_specular[]= { 1.0f, 1.0f, 1.0f, 0.0f };
GLfloat light_position[]= { 100.0f, 0.0f, -10.0f, 1.0f };
//Materials settings
GLfloat mat_ambient[]= { 0.5f, 0.5f, 0.0f, 0.0f };
GLfloat mat_diffuse[]= { 0.5f, 0.5f, 0.0f, 0.0f };
GLfloat mat_specular[]= { 1.0f, 1.0f, 1.0f, 0.0f };
GLfloat mat_shininess[]= { 1.0f };
typedef struct Vectors {
float x;
float y;
float z;
}Vector;
typedef struct Polys {
Vector v;
Vector vt;
Vector vn;
int texture;
} Poly;
vector<Vector> vecs;
vector<Vector> normVecs;
vector<Vector> textVecs;
vector<Poly> polyList;
void loadModel(string filepath);
void createTex(string ref);
void render();
//An array of 3 vectors which represents 3 vertices
static const GLfloat g_vertex_buffer_data[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
};
void render()
{
}
void createTex(string ref)
{
}
void loadModel(string filepath)
{
}
void resize (int p_width, int p_height)
{
if(screen_width==0 && screen_height==0) exit(0);
screen_width=p_width; //Obtain the new screen width values and store it
screen_height=p_height; //Height value
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear both the color and the depth buffer so to draw the next frame
glViewport(0,0,screen_width,screen_height); //Viewport transformation
glMatrixMode(GL_PROJECTION); //Projection transformation
glLoadIdentity(); //Initialize the projection matrix as identity
gluPerspective(45.0f,(GLfloat)screen_width/(GLfloat)screen_height,1.0f,10000.0f);
glutPostRedisplay(); //This command redraw the scene (it calls the same routine of glutDisplayFunc)
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //This clear the background color to dark blue
glMatrixMode(GL_MODELVIEW); //Modeling transformation
glPushMatrix();
glLoadIdentity(); //Initialize the model matrix as identity
gluLookAt(xPos, yPos, zPos, /* look from camera XYZ */
0, yPos, 0, /* look at the origin */
0, 1, 0); /* positive Y up vector */
glRotatef(orbitDegrees, 0.f, 1.0f, 0.0f);
//glTranslatef(0.0,0.0,-20); //We move the object forward (the model matrix is multiplied by the translation matrix)
//rotation_x = 30;
//rotation_x = rotation_x + rotation_x_increment;
//rotation_y = rotation_y + rotation_y_increment;
//rotation_z = rotation_z + rotation_z_increment;
//if (rotation_x > 359) rotation_x = 0;
//if (rotation_y > 359) rotation_y = 0;
//if (rotation_z > 359) rotation_z = 0;
// glRotatef(rotation_x,1.0,0.0,0.0); //Rotations of the object (the model matrix is multiplied by the rotation matrices)
//glRotatef(rotation_y,0.0,1.0,0.0);
// glRotatef(rotation_z,0.0,0.0,1.0);
//if (objarray[0]->id_texture!=-1)
//{
// glBindTexture(GL_TEXTURE_2D, objarray[0]->id_texture); //We set the active texture
// glEnable(GL_TEXTURE_2D); //Texture mapping ON
// printf("Txt map ON");
//}
//else
// glDisable(GL_TEXTURE_2D); //Texture mapping OFF
glGetDoublev(GL_PROJECTION_MATRIX, modelV);
glGetDoublev(GL_PROJECTION_MATRIX, projM);
glGetIntegerv(GL_VIEWPORT, vPort);
if(clock() > sTime)
{
fPS = fCount;
fCount = 0;
sTime = clock() + CLOCKS_PER_SEC;
}
render();
glDisable(GL_LIGHTING);
GLdouble pos[3];
gluUnProject(100, yPos, -14, modelV, projM, vPort, &pos[0], &pos[1], &pos[2]);
char buffer2[255];
int pAmmount = sprintf(buffer2,"FPS: %.2f", fPS);
//glRasterPos3f(pos[0], pos[1], pos[2]);
for(int i = 0; i < pAmmount; i++)
{
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, buffer2[i]);
}
glEnable(GL_LIGHTING);
/*glPopMatrix();
glPushMatrix();
glTranslatef(5.0,0.0,-20.0);
objarray[1]->render();*/
glPopMatrix();
glFlush(); //This force the execution of OpenGL commands
glutSwapBuffers(); //In double buffered mode we invert the positions of the visible buffer and the writing buffer
fCount++;
}
void keyboard(unsigned char k, int x, int y)
{
switch(k)
{
case 'w':
yPos++;
break;
case 's':
yPos--;
break;
case 'a':
xPos--;
break;
case 'd':
xPos++;
break;
case 'q':
orbitDegrees--;
break;
case 'e':
orbitDegrees++;
break;
case 'z':
zPos--;
break;
case 'x':
zPos++;
break;
}
}
void initWindow(GLsizei screen_width, GLsizei screen_height)
{
glClearColor(0.0, 0.0, 0.0, 0.0); //Clear background color to black
//Viewport transformation
glViewport(0,0,screen_width,screen_height);
//Projection transformation
glMatrixMode(GL_PROJECTION); //Specifies which matrix stack is the target for matrix operations
glLoadIdentity(); //We initialize the projection matrix as identity
gluPerspective(45.0f,(GLfloat)screen_width/(GLfloat)screen_height,1.0f,10000.0f); //We define the "viewing volume"
gluLookAt(camera[0], camera[1], camera[2], /* look from camera XYZ */
0, 0, 0, /* look at the origin */
0, 1, 0); /* positive Y up vector */
try
{
//loadModel("Goku habit dechiré.obj");
loadModel("Flooring.obj");;
}
catch(string& filepath)
{
cerr << "Model could not be loaded: " << filepath << endl;
filepath = "Model could not be loaded: " + filepath;
wostringstream sString;
sString << filepath.c_str();
MessageBox(HWND_DESKTOP, sString.str().c_str(), L"Error: loadModel(string filepath)", MB_OK);
}
//Lights initialization and activation
glLightfv (GL_LIGHT1, GL_AMBIENT, light_ambient);
glLightfv (GL_LIGHT1, GL_DIFFUSE, light_diffuse);
glLightfv (GL_LIGHT1, GL_DIFFUSE, light_specular);
glLightfv (GL_LIGHT1, GL_POSITION, light_position);
glEnable (GL_LIGHT1);
glEnable (GL_LIGHTING);
//Materials initialization and activation
glMaterialfv (GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_specular);
glMaterialfv (GL_FRONT, GL_POSITION, mat_shininess);
//Other initializations
glShadeModel(GL_SMOOTH); //Type of shading for the polygons
//glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //Texture mapping perspective correction
//glEnable(GL_TEXTURE_2D); //Texture mapping ON
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); //Polygon rasterization mode (polygon filled)
glEnable(GL_CULL_FACE); //Enable the back face culling
glEnable(GL_DEPTH_TEST); //Enable the depth test
glEnable(GL_NORMALIZE);
/*float* matrix = new float[16];
glGetFloatv(GL_PROJECTION_MATRIX, matrix);
for(int i = 0; i < 4; i++)
{
cout << matrix[0] << " " << matrix[1] << " " << matrix[2] << " " << matrix[3] << endl;
matrix += 3;
}*/
modelV = new GLdouble[16];
projM = new GLdouble[16];
vPort = new GLint[4];
sTime = clock() + CLOCKS_PER_SEC;
}
void init()
{
GLenum GlewInitResult;
GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult) {
fprintf(
stderr,
"ERROR: %s\n",
glewGetErrorString(GlewInitResult)
);
exit(EXIT_FAILURE);
}
//This will identify our vertex buffer
GLuint vertexbuffer;
//Generate 1 buffer, put the resulting identifier in vertexbuffer
glGenBuffers(1, &vertexbuffer);
//The following commands will talk about our 'vertexbuffer' buffer
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
//Give our vertices to OpenGL.
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
}
int main(int argc, char **argv)
{
screen_width = 800;
screen_height = 800;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(screen_width,screen_height);
glutInitWindowPosition(0,0);
glutCreateWindow("ModelLoader");
glutDisplayFunc(display);
glutIdleFunc(display);
glutReshapeFunc (resize);
glutKeyboardFunc(keyboard);
//glutKeyboardFunc(keyboard);
//glutSpecialFunc(keyboard_s);
initWindow(screen_width, screen_height);
init();
glutMainLoop();
return 0;
}
OriginalL'auteur M Davies | 2012-06-16
Vous devez vous connecter pour publier un commentaire.
Vous avez un problème de liaison. Vous n'êtes pas fournir à l'éditeur de liens le chemin d'accès correct à la glew fichier lib. Pour cette raison, l'éditeur de liens n'est pas en mesure de trouver le code compilé des fonctions que vous appelez.
De votre journal, il semble que vous travaillez sur Windows. Si vous utilisez Visual Studio, cliquez-droit sur votre projet. Sélectionnez l'éditeur de liens, et puis à l'Entrée. Vérifier que les dépendances Supplémentaires contient le chemin d'accès à glew lib.
Avis que la dll n'est pas requis au temps de lien. Ce seront chargés uniquement au moment de l'exécution (n'oubliez pas de mettre dans le même dossier que votre fichier exécutable ou dans un chemin d'accès indiqué dans votre chemin d'accès au système).
OriginalL'auteur Pierluigi
Cela a été corrigé. Le problème, c'est que représenté sur la machine que j'utilisais à l'Université. Le problème est que la machine avait un vieux .dll qui est en conflit avec la .dll que j'ai eu dans les fichiers de la solution. Il a été installé dans le Système de fichiers de la machine. En tant que tel, il a été la production de ces erreurs.
Je devrais probablement vérifier quelque chose pour la prochaine fois.
OriginalL'auteur M Davies
Pas sûr de savoir comment il va vous aider, mais, vous pourriez donner un essai et lier statiquement votre projet à un ".une" bibliothèque. ou il est .lib sous windows. Si il y a des symbole non ça veut dire qu'il a essayé de lien vers une bibliothèque et pas vraiment à une dll.
Si c'est à l'aide de la dll, il ne serait probablement pas au moment de l'exécution.
OriginalL'auteur Loïc Faure-Lacroix