working, forgot to enable client state for vertex/color arrays
This commit is contained in:
parent
126a355e47
commit
a8b85f7246
@ -5,6 +5,7 @@
|
||||
#include <GL/gl.h>
|
||||
|
||||
#define checkGLError() _checkGLError(__FILE__, __LINE__)
|
||||
#define GL_CHECK(x) ({x; checkGLError();})
|
||||
|
||||
GLenum _checkGLError(const char *fname, int lineno);
|
||||
|
||||
|
@ -10,12 +10,13 @@
|
||||
#define HEIGHT 500
|
||||
|
||||
#define ADDR_DIFF(x, y) ((unsigned long) (y) - (unsigned long) (x))
|
||||
#define GL_CHECK(x) ({x; checkGLError();})
|
||||
|
||||
void init(void)
|
||||
{
|
||||
GL_CHECK(glClearColor (0.0, 0.0, 0.0, 0.0));
|
||||
GL_CHECK(glEnable(GL_DEPTH_TEST));
|
||||
GL_CHECK(glEnableClientState(GL_VERTEX_ARRAY));
|
||||
GL_CHECK(glEnableClientState(GL_COLOR_ARRAY));
|
||||
GL_CHECK(glShadeModel(GL_SMOOTH));
|
||||
GL_CHECK(glViewport(0, 0, WIDTH, HEIGHT));
|
||||
GL_CHECK(glMatrixMode(GL_PROJECTION));
|
||||
@ -35,7 +36,7 @@ void display(void)
|
||||
{{0.8, 0.8, 0.0, 1.0}, {0.0, 0.0, 1.0, 1.0}},
|
||||
{{-0.8, 0.8, 0.0, 1.0}, {0.0, 0.4, 1.0, 1.0}}
|
||||
};
|
||||
static const GLbyte indexes[] = {1, 0, 2, 3};
|
||||
static const GLushort indexes[] = {1, 0, 2, 3};
|
||||
GLuint buffers[2];
|
||||
GL_CHECK(glGenBuffers(sizeof(buffers)/sizeof(buffers[0]), buffers));
|
||||
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, buffers[0]));
|
||||
@ -50,7 +51,7 @@ void display(void)
|
||||
(void *) ADDR_DIFF(&data, &data[0][0][0])));
|
||||
GL_CHECK(glColorPointer(4, GL_FLOAT, ADDR_DIFF(&data[0], &data[1]),
|
||||
(void *) ADDR_DIFF(&data, &data[0][1][0])));
|
||||
GL_CHECK(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, NULL));
|
||||
GL_CHECK(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, NULL));
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user