#ifdef __APPLE__
#include <gl.h>
#include <glu.h>
#include <glut.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
#include <assert.h>
static char *TITLE = "test_materials";
void init() {
GLfloat LP[] = {(GLfloat) 0,
(GLfloat) 0,
(GLfloat) 10,
(GLfloat) 1};
GLfloat A[] = {(GLfloat) 0.1,
(GLfloat) 0.1,
(GLfloat) 0.1};
GLfloat S[] = {(GLfloat) 0.5,
(GLfloat) 0.5,
(GLfloat) 0.5};
GLfloat D[] = {(GLfloat) 0.5,
(GLfloat) 0.5,
(GLfloat) 0.5};
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_FRONT);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightfv(GL_LIGHT0, GL_POSITION, LP);
glLightfv(GL_LIGHT0, GL_AMBIENT, A);
glLightfv(GL_LIGHT0, GL_SPECULAR, S);
glLightfv(GL_LIGHT0, GL_DIFFUSE, D);
glClearColor(0.f, 0.f, 0.f, 1.f);
}
void reshape(int width, int height) {
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(65.0, (float) width / (float) height, 1.0, 100);
}
void display() {
static GLfloat RA[] = {(GLfloat) 1,
(GLfloat) 0,
(GLfloat) 0,
(GLfloat) 1};
static GLfloat RS[] = {(GLfloat) 1,
(GLfloat) 0,
(GLfloat) 0,
(GLfloat) 1};
static GLfloat RD[] = {(GLfloat) 1,
(GLfloat) 0,
(GLfloat) 0,
(GLfloat) 1};
static GLfloat GA[] = {(GLfloat) 0,
(GLfloat) 1,
(GLfloat) 0,
(GLfloat) 1};
static GLfloat GS[] = {(GLfloat) 0,
(GLfloat) 1,
(GLfloat) 0,
(GLfloat) 1};
static GLfloat GD[] = {(GLfloat) 0,
(GLfloat) 1,
(GLfloat) 0,
(GLfloat) 1};
static GLfloat BA[] = {(GLfloat) 0,
(GLfloat) 0,
(GLfloat) 1,
(GLfloat) 1};
static GLfloat BS[] = {(GLfloat) 0,
(GLfloat) 0,
(GLfloat) 1,
(GLfloat) 1};
static GLfloat BD[] = {(GLfloat) 0,
(GLfloat) 0,
(GLfloat) 1,
(GLfloat) 1};
static GLfloat Y = 0;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 5,
0, 0, 0,
0, 1, 0);
glBegin(GL_QUADS);
glNormal3d(0, 0, 1);
glMaterialfv(GL_FRONT, GL_AMBIENT, RA);
glMaterialfv(GL_FRONT, GL_DIFFUSE, RD);
glMaterialfv(GL_FRONT, GL_SPECULAR, RS);
glMaterialf(GL_FRONT, GL_SHININESS, Y);
glVertex3d(0, 0, 0);
glVertex3d(1, 0, 0);
glVertex3d(1, 1, 0);
glVertex3d(0, 1, 0);
glEnd();
glBegin(GL_TRIANGLES);
glNormal3d(0, 0, 1);
glMaterialfv(GL_FRONT, GL_AMBIENT, GA);
glMaterialfv(GL_FRONT, GL_DIFFUSE, GD);
glMaterialfv(GL_FRONT, GL_SPECULAR, GS);
glMaterialf(GL_FRONT, GL_SHININESS, Y);
glVertex3d(1, 0, 0);
glVertex3d(2, 0, 0);
glVertex3d(2, 1, 0);
glEnd();
glBegin(GL_TRIANGLES);
glNormal3d(0, 0, 1);
glMaterialfv(GL_FRONT, GL_AMBIENT, BA);
glMaterialfv(GL_FRONT, GL_DIFFUSE, BD);
glMaterialfv(GL_FRONT, GL_SPECULAR, BS);
glMaterialf(GL_FRONT, GL_SHININESS, Y);
glVertex3d(0, 0, 0);
glVertex3d(-1, 1, 0);
glVertex3d(-1, 0, 0);
glEnd();
glutSwapBuffers();
}
int main(int argc, char **argv) {
int window = 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutInitWindowPosition(0, 0);
window = glutCreateWindow(TITLE);
assert(window);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
init();
glutMainLoop();
glutDestroyWindow(window);
return 0;
}
gcc -o test_materials tests/test_materials.c -ansi -O0 -noixemul -noixemul -lm -lGl -lglut
The problem is somewhere in my code. Any debugging hints on MorphOs, since there no gdb.