Hello,
I've become comfortable with model loading, lighting, keyboard input, texturing, etc, and I'm trying to move on to GLSL. Try as I might, I cannot get my program to link properly. I'm using VC++ 2008 beta 2, but had the same problems on 2005.
Here is my output:
1>Compiling...
1>main.cpp
1>Linking...
1>main.obj : error LNK2001: unresolved external symbol __imp____glewAttachShader
1>main.obj : error LNK2001: unresolved external symbol __imp____glewCreateProgram
1>main.obj : error LNK2001: unresolved external symbol __imp____glewShaderSource
1>main.obj : error LNK2001: unresolved external symbol __imp____glewCreateShader
If I use GLee, I get the same thing:
1>Compiling...
1>main.cpp
1>Linking...
1>main.obj : error LNK2001: unresolved external symbol _pglAttachShader
1>main.obj : error LNK2001: unresolved external symbol _pglCreateProgram
1>main.obj : error LNK2001: unresolved external symbol _pglShaderSource
1>main.obj : error LNK2001: unresolved external symbol _pglCreateShader
I put the .lib files in the VC/lib folder just as I was told. What have I done wrong?
Here's the program source:
#include <windows.h>
#include <GL/GLee.h>
#include <GL/glut.h>
#include <fstream>
#include <string>
GLuint vShader, p;
const char *loadShader(char *filename) {
std::ifstream ifs(filename);
std::string text = "", line, nl="\n";
if(ifs.is_open()) {
while(!ifs.eof()) {
std::getline(ifs, line);
text.append(line.append(nl));
}
}
return text.data();
}
static void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
}
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
static void MainLoop(void)
{
display();
}
void setupRC() {
GLfloat bg[] = {0.0f, 0.0f, 0.0f, 1.0f};
glClearColor(bg[0], bg[1], bg[2], bg[3]);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glClearStencil(0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_NORMALIZE);
}
void setupShaders() {
vShader = glCreateShader(GL_VERTEX_SHADER);
const char *vs = loadShader("hello.vs");
glShaderSource(vShader, 1, &vs, NULL);
free((void *)vs);
p = glCreateProgram();
glAttachShader(p, vShader);
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(800,600);
glutInitWindowPosition(10,30);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Shaders Intro");
glutReshapeFunc(resize);
glutDisplayFunc(MainLoop);
glutIdleFunc(MainLoop);
setupRC();
setupShaders();
glutMainLoop();
return EXIT_SUCCESS;
}
[Edited by - MattHughes on November 18, 2007 6:36:19 PM]
|