git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@161 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-04 15:12:49 +00:00
parent 1143a3d0d6
commit 820e0a7182
2 changed files with 77 additions and 3 deletions

View File

@@ -68,7 +68,7 @@ L_CFLAGS += -DUSE_X11
L_OBJS += src/backend/x11.o
L_LIBS += -lX11 -lXrender -lXext
GL = -lGL
GL = -lGL -lGLU
E_LIBS += -lm
@@ -80,7 +80,7 @@ L_LDFLAGS += -Wl,--out-implib,src/libMw.lib -static-libgcc
L_OBJS += src/backend/gdi.o
L_LIBS += -lgdi32
GL = -lopengl32
GL = -lopengl32 -lglu32
SO = .dll
EXEC = .exe
@@ -90,7 +90,7 @@ EXAMPLES = examples/example$(EXEC) examples/rotate$(EXEC) examples/image$(EXEC)
ifeq ($(OPENGL),1)
L_OBJS += src/widget/opengl.o
EXAMPLES += examples/gltriangle$(EXEC) examples/glgears$(EXEC) examples/glboing$(EXEC)
EXAMPLES += examples/gltriangle$(EXEC) examples/glgears$(EXEC) examples/glboing$(EXEC) examples/glcube$(EXEC)
endif
ifeq ($(VULKAN),1)

74
examples/glcube.c Normal file
View File

@@ -0,0 +1,74 @@
/* $Id$ */
#define TITLE "cube"
#include "oldglut.c"
#include <GL/glu.h>
static double deg = 0;
static void draw(void) {
int i;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(deg, 1, 0, 0);
glRotatef(deg, 0, 1, 0);
glRotatef(deg, 0, 0, 1);
for(i = 0; i < 6; i++) {
if(i == 0) glColor3f(1, 0, 0);
if(i == 1) glColor3f(0, 1, 0);
if(i == 2) glColor3f(1, 1, 0);
if(i == 3) glColor3f(0, 0, 1);
if(i == 4) glColor3f(1, 0, 1);
if(i == 5) glColor3f(0, 1, 1);
glBegin(GL_QUADS);
glNormal3f(0, 1, 0);
glVertex3f(-1, 1, -1);
glVertex3f(-1, 1, 1);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, -1);
glEnd();
if(i < 3) glRotatef(90, 0, 0, 1);
if(i == 3) glRotatef(90, 1, 0, 0);
if(i == 4) glRotatef(180, 0, 0, 1);
}
glPopMatrix();
}
static void idle(void) {
deg += 1.0;
}
static void reshape(int width, int height) {
GLfloat lpos[4];
lpos[0] = 2;
lpos[1] = 2;
lpos[2] = 2;
lpos[3] = 0;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (double)width / height, 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(2, 2, 2, 0, 0, 0, 0, 1, 0);
glLightfv(GL_LIGHT0, GL_POSITION, lpos);
}
static void init(void) {
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
}