PDA

View Full Version : How to use GLEW 1.2.5 ?



_student
12-07-2004, 06:56 AM
#include <gl/glew.h>
#include <gl/glut.h>
//#include <gl/glprocs.h>

static GLint vertices[] = { 25, 25,
100, 325,
175, 25,
175, 325,
250, 25,
325, 325 };

static GLfloat colors[] = { 1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
0.75, 0.75, 0.75,
0.35, 0.35, 0.35,
0.5, 0.5, 0.5 };

void setupVertex()
{
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

glVertexPointer(2, GL_INT, 0, vertices);
glColorPointer(3, GL_FLOAT, 0, colors);
}

void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 400.0, 0.0, 400.0);
setupVertex();
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
GLuint front[] = {0, 1, 2, 3, 4, 5 };
//glDrawElements(GL_LINES, 3, GL_UNSIGNED_INT, front);
glDrawRangeElements(GL_LINES, 1, 2, 2, GL_UNSIGNED_INT, front);
glFlush();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400, 400);
glutInitWindowPosition(100, 100);
glutCreateWindow("");

init();
glutDisplayFunc(display);
glutMainLoop();

return 0;
}

If I used glDrawRangeElements() directly, the program will crash? Could anyone tell how to use glew? Thanks.

V-man
12-08-2004, 07:09 PM
It's explained on the main page

http://glew.sourceforge.net/

pleopard
12-10-2004, 06:59 AM
Yes, it usually pays to read the directions before asking questons. You may just find the answer there ...


glutCreateWindow("GLEW Test");
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* problem: glewInit failed, something is seriously wrong */
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
...
}
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));