Jump to content

  • Log In with Google      Sign In   
  • Create Account

Zeophlite

Member Since 16 Jul 2004
Offline Last Active Aug 06 2011 11:34 AM

Topics I've Started

VBOs & glew undefined references

10 November 2010 - 06:50 PM

I can get Immediate Mode & Vertex Arrays to work, but not VBOs.


#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

Seamless hexagon textures

08 November 2010 - 10:15 PM

So I'm making a game with a regular hexagon map. Now the difficulty is in creating seamless tiles. With square tiles, I can make the tile in Photoshop, then use Offset to correct the edges, but I can't do the same with hexagons.

I was wondering what method you guys use to make hexagon tiles?

Cheers

GLEW + GLUT = no luck

23 August 2010 - 07:21 AM

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)


Arbitary Rule Changing

20 October 2009 - 07:39 PM

In many games, the rules are changed mid game. The best example of this is Magic: The Gathering - the golden rule is if there's a conflict, then the card is right. I'm wondering how to program this into a game. Consider an RPG where you have equipment. The rules as originally concieved state that your armour score is your dexterity + the value of the armour you wear. Now say I pick up a pair of Shielding Gauntlets of +2 Awesomeness, that give you +2 to your armour, and that of your adjacent allies. The bonus to yourself seems simple enough, but how about for your allies? My instinct tells me to use some form of Aura system... The above example is simple enough, but what about more complex rule changes? Such as the boss having an Axe of Disabling, that instead of doing damage, prevents one of your equipment from working? Or a Bow that shoots flaming bolts, or a cloak that prevents 30% of ice damage?

Programming Music

19 October 2009 - 04:10 AM

What do you listen to when your programming? I find myself listening to stuff from rpgmp3.com, The Nerdy Show and LoadingReadyRun podcasts. Also I seem to like remixes. Does music help you program, or does it hinder you. I know if I have to think about the words, then I can't concentrate.

PARTNERS