Jump to content
  • Advertisement
Sign in to follow this  
Zeophlite

OpenGL GLEW + GLUT = no luck

This topic is 2956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay so the below code compiles nicely, but when I uncomment the first line, then it doesn't. I'm using glut-3.7.6-bin.zip from http://www.xmission.com/~nate/glut.html and glew-1.5.5-win32.zip (Windows 32-bit) from http://glew.sourceforge.net/ and for my C toolchain, I'm using TDM-GCC (http://tdm-gcc.tdragon.net/), with Netbeans. All the linker commands are in the 2nd and 3rd listings below

I've tried similar toolkits (SDL, freeglut, glfw) and they all work with and without glew. So I want to know why glut doesn't work with glew.


//#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#define GLUT_DISABLE_ATEXIT_HACK
#include "glut.h"
#include <stdio.h>
#include <unistd.h>

#define ESCAPE 27

int window;

float angle = 0.0f;

void render() {
angle += 0.05f;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(-1.5f, 0.0f, -6.0f);

glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glEnd();

glTranslatef(3.0f, 0.0f, 0.0f);
glRotatef(angle,0.0f,0.0f,1.0f);

glColor3f(0.5f, 0.5f, 1.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glEnd();
}

void InitGL(int Width, int Height) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0f, (GLfloat) Width / (GLfloat) Height, 0.1f, 100.0f);

glMatrixMode(GL_MODELVIEW);
}

void ReSizeGLScene(int Width, int Height) {
if (Height == 0)
Height = 1;

glViewport(0, 0, Width, Height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0f, (GLfloat) Width / (GLfloat) Height, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
}

void DrawGLScene() {
render();

glutSwapBuffers();
}

void keyPressed(unsigned char key, int x, int y) {
usleep(100);

if (key == ESCAPE) {
glutDestroyWindow(window);

exit(0);
}
}

int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutInitWindowPosition(0, 0);
window = glutCreateWindow("Jeff Molofee's GL Code Tutorial ... NeHe '99");

/* GLenum err = glewInit();
if (GLEW_OK != err) {
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
if (glewIsSupported("GL_VERSION_1_4 GL_ARB_point_sprite")) {
fprintf(stderr, "Safe to use GL1.4 & Point Sprites\n");
} else {
fprintf(stderr, "Not safe to use GL1.4 & Point Sprites\n");
}*/



glutDisplayFunc(&DrawGLScene);
glutFullScreen();
glutIdleFunc(&DrawGLScene);
glutReshapeFunc(&ReSizeGLScene);
glutKeyboardFunc(&keyPressed);
InitGL(640, 480);
glutMainLoop();

return 1;
}



This is my output normally.

"/usr/bin/make" -f nbproject/Makefile-GLUT.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
rm -f -r build/GLUT
rm -f dist/GLUT/MinGW_TDM-Windows/opengl.exe
make[1]: Leaving directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'

CLEAN SUCCESSFUL (total time: 1s)
"/usr/bin/make" -f nbproject/Makefile-GLUT.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
"/usr/bin/make" -f nbproject/Makefile-GLUT.mk dist/GLUT/MinGW_TDM-Windows/opengl.exe
make[2]: Entering directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
mkdir -p build/GLUT/MinGW_TDM-Windows/_ext/360110485
rm -f build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o.d
gcc -c -g -I/C/Users/Daniel/Downloads/glut-3.7.6-bin -I/C/Users/Daniel/Downloads/glew-1.5.5/include -MMD -MP -MF build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o.d -o build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o /C/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c
mkdir -p build/GLUT/MinGW_TDM-Windows/_ext/360110485
rm -f build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o.d
gcc -c -g -I/C/Users/Daniel/Downloads/glut-3.7.6-bin -I/C/Users/Daniel/Downloads/glew-1.5.5/include -MMD -MP -MF build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o.d -o build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o /C/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/common.c
mkdir -p dist/GLUT/MinGW_TDM-Windows
gcc -o dist/GLUT/MinGW_TDM-Windows/opengl build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o /C/Users/Daniel/Downloads/glut-3.7.6-bin/glut32.lib /C/TDM-GCC/lib/libopengl32.a /C/TDM-GCC/lib/libglu32.a
make[2]: Leaving directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
make[1]: Leaving directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'

BUILD SUCCESSFUL (total time: 2s)



And then when I remove the first // from my code above (so it includes glew)

"/usr/bin/make" -f nbproject/Makefile-GLUT.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
rm -f -r build/GLUT
rm -f dist/GLUT/MinGW_TDM-Windows/opengl.exe
make[1]: Leaving directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'

CLEAN SUCCESSFUL (total time: 1s)
"/usr/bin/make" -f nbproject/Makefile-GLUT.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
"/usr/bin/make" -f nbproject/Makefile-GLUT.mk dist/GLUT/MinGW_TDM-Windows/opengl.exe
make[2]: Entering directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
mkdir -p build/GLUT/MinGW_TDM-Windows/_ext/360110485
rm -f build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o.d
gcc -c -g -I/C/Users/Daniel/Downloads/glut-3.7.6-bin -I/C/Users/Daniel/Downloads/glew-1.5.5/include -MMD -MP -MF build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o.d -o build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o /C/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c
mkdir -p build/GLUT/MinGW_TDM-Windows/_ext/360110485
rm -f build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o.d
gcc -c -g -I/C/Users/Daniel/Downloads/glut-3.7.6-bin -I/C/Users/Daniel/Downloads/glew-1.5.5/include -MMD -MP -MF build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o.d -o build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o /C/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/common.c
mkdir -p dist/GLUT/MinGW_TDM-Windows
gcc -o dist/GLUT/MinGW_TDM-Windows/opengl build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o build/GLUT/MinGW_TDM-Windows/_ext/360110485/common.o /C/Users/Daniel/Downloads/glut-3.7.6-bin/glut32.lib /C/TDM-GCC/lib/libopengl32.a /C/TDM-GCC/lib/libglu32.a
build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o: In function `DrawGLScene':
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:44: undefined reference to `glutSwapBuffers'
build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o: In function `keyPressed':
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:51: undefined reference to `glutDestroyWindow'
build/GLUT/MinGW_TDM-Windows/_ext/360110485/glut.o: In function `main':
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:58: undefined reference to `glutInit'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:59: undefined reference to `glutInitDisplayMode'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:60: undefined reference to `glutInitWindowSize'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:61: undefined reference to `glutInitWindowPosition'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:62: undefined reference to `glutCreateWindow'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:76: undefined reference to `glutDisplayFunc'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:77: undefined reference to `glutFullScreen'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:78: undefined reference to `glutIdleFunc'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:79: undefined reference to `glutReshapeFunc'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:80: undefined reference to `glutKeyboardFunc'
c:/Users/Daniel/Documents/NetBeansProjects/OpenGL/src/glut.c:82: undefined reference to `glutMainLoopmake[2]: Leaving directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
make[1]: Leaving directory `/c/Users/Daniel/Documents/NetBeansProjects/OpenGL'
'
collect2: ld returned 1 exit status
make[2]: *** [dist/GLUT/MinGW_TDM-Windows/opengl.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!