#include <stdlib.h>#define GLEW_STATIC#include <GL/glew.h>#include <stdio.h>#include "sdl.h"const int NODRAW = 0;const int IMMEDIATE = 1;const int VERTEX_ARRAY = 2;const int VBO = 3;extern int method;extern int print, delay;GLfloat vertices[] = { -0.2f, -0.2f, 0.0f, -0.2f, 0.2f, 0.0f, 0.2f, 0.2f, 0.0f, 0.2f, -0.2f, 0.0f};GLfloat colors[] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f};int numverts = sizeof(vertices) / (3*sizeof(GLfloat));GLuint vboId = 0;static int make_resources(void) { /* glGenBuffers(1, &vboId); glBindBuffer(GL_ARRAY_BUFFER, vboId); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices) + sizeof(colors), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); glBufferSubData(GL_ARRAY_BUFFER, sizeof(vertices), sizeof(colors), colors); */ return 1;}static int clean_resources(void) { // glDeleteBuffers(1, &vboId);}static void render(void) { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); if (method == IMMEDIATE) { glBegin(GL_POLYGON); int i; for(i = 0; i < numverts; i++) { glColor3fv(&colors[i*3]); glVertex3fv(&vertices[i*3]); } glEnd(); } else if (method == VERTEX_ARRAY) { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); glColorPointer(3, GL_FLOAT, 0, colors); glDrawArrays(GL_POLYGON, 0, numverts); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); } else if (method == VBO) { // glBindBuffer(GL_ARRAY_BUFFER, vboId); // glEnableClientState(GL_VERTEX_ARRAY); // glEnableClientState(GL_COLOR_ARRAY); // glVertexPointer(3, GL_FLOAT, 0, 0); // glColorPointer(3, GL_FLOAT, 0, (GLvoid*)(numverts * 3 * sizeof(GLfloat))); // glDrawArrays(GL_LINE_LOOP, 0, numverts); // glDisableClientState(GL_COLOR_ARRAY); // glDisableClientState(GL_VERTEX_ARRAY); // glBindBuffer(GL_ARRAY_BUFFER, 0); } SDL_GL_SwapBuffers();}extern int done;int main(int argc, char** argv) { initSDL(); glewInit(); if (!glewIsSupported("GL_VERSION_2_0")) { fprintf(stderr, "OpenGL 2.0 not available\n"); return 1; } if (!make_resources()) { fprintf(stderr, "Failed to load resources\n"); return 1; } while (!done) { handleInput(); render(); } clean_resources(); SDL_Quit(); return 0;}
I won't bother you with initSDL() or handleInput(), but they are both in a seperate file, sdl.c, along with some ints & have a header, sdl.h. (I realise that that's a bad name, could interfer with SDL.h!)
I'm linking with:
glew32.lib
libopengl32.a
libglu32.a
libmingw32.a
libSDLmain.a
libSDL.dll.a
Now If I uncomment the code in render(), make_resources() & clean_resources(), I get these errors:
build/main.o: In function `make_resources':src/main.c:35: undefined reference to `__glewGenBuffers'src/main.c:36: undefined reference to `__glewBindBuffer'src/main.c:37: undefined reference to `__glewBufferData'src/main.c:39: undefined reference to `__glewBufferSubData'src/main.c:40: undefined reference to `__glewBufferSubData'build/main.o: In function `clean_resources':src/main.c:49: undefined reference to `__glewDeleteBuffers'build/main.o: In function `render':src/main.c:86: undefined reference to `__glewBindBuffer'src/main.c:99: undefined reference to `__glewBindBuffer'
So what do I have to do to get glew to fix it?
Cheers