minor refactoring
This commit is contained in:
parent
c1d7cd803f
commit
e3a48c7aba
23
glxgears.c
23
glxgears.c
@ -12,6 +12,7 @@
|
|||||||
* Other modifications by Lexxy Fox.
|
* Other modifications by Lexxy Fox.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <GL/gl.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -309,13 +310,7 @@ static void reshape(int width, int height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void init(int argc, char *argv[]) {
|
static void init(int argc, char *argv[]) {
|
||||||
static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0};
|
glLightfv(GL_LIGHT0, GL_POSITION, (GLfloat[]){5.0, 5.0, 10.0, 0.0});
|
||||||
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
|
||||||
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
|
||||||
static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
|
|
||||||
GLint i;
|
|
||||||
|
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
@ -324,25 +319,31 @@ static void init(int argc, char *argv[]) {
|
|||||||
/* make the gears */
|
/* make the gears */
|
||||||
gear1 = glGenLists(1);
|
gear1 = glGenLists(1);
|
||||||
glNewList(gear1, GL_COMPILE);
|
glNewList(gear1, GL_COMPILE);
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
glMaterialfv(
|
||||||
|
GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (GLfloat[]){0.8, 0.1, 0.0, 1.0}
|
||||||
|
);
|
||||||
gear(1.0, 4.0, 1.0, 20, 0.7);
|
gear(1.0, 4.0, 1.0, 20, 0.7);
|
||||||
glEndList();
|
glEndList();
|
||||||
|
|
||||||
gear2 = glGenLists(1);
|
gear2 = glGenLists(1);
|
||||||
glNewList(gear2, GL_COMPILE);
|
glNewList(gear2, GL_COMPILE);
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
glMaterialfv(
|
||||||
|
GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (GLfloat[]){0.0, 0.8, 0.2, 1.0}
|
||||||
|
);
|
||||||
gear(0.5, 2.0, 2.0, 10, 0.7);
|
gear(0.5, 2.0, 2.0, 10, 0.7);
|
||||||
glEndList();
|
glEndList();
|
||||||
|
|
||||||
gear3 = glGenLists(1);
|
gear3 = glGenLists(1);
|
||||||
glNewList(gear3, GL_COMPILE);
|
glNewList(gear3, GL_COMPILE);
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
glMaterialfv(
|
||||||
|
GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (GLfloat[]){0.2, 0.2, 1.0, 1.0}
|
||||||
|
);
|
||||||
gear(1.3, 2.0, 0.5, 10, 0.7);
|
gear(1.3, 2.0, 0.5, 10, 0.7);
|
||||||
glEndList();
|
glEndList();
|
||||||
|
|
||||||
glEnable(GL_NORMALIZE);
|
glEnable(GL_NORMALIZE);
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (GLint i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-info") == 0) {
|
if (strcmp(argv[i], "-info") == 0) {
|
||||||
printf("GL_VENDOR = %s\n", (char *)glGetString(GL_VENDOR));
|
printf("GL_VENDOR = %s\n", (char *)glGetString(GL_VENDOR));
|
||||||
printf("GL_RENDERER = %s\n", (char *)glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n", (char *)glGetString(GL_RENDERER));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user