diff --git a/examples/glboing.c b/examples/glboing.c index a81f93f..d5b8ef3 100644 --- a/examples/glboing.c +++ b/examples/glboing.c @@ -1,10 +1,6 @@ /* $Id$ */ -#include -#include - -#include - -MwWidget opengl; +#define TITLE "boing" +#include "oldglut.c" /* * Bouncing ball demo. @@ -157,51 +153,3 @@ static void init(void) { glDisable(GL_DITHER); glShadeModel(GL_FLAT); } - -static void tick(MwWidget handle, void* user, void* client) { - (void)handle; - (void)user; - (void)client; - - draw(); - idle(); - - MwOpenGLSwapBuffer(opengl); -} - -static void resize(MwWidget handle, void* user, void* client) { - int ww, wh; - - (void)handle; - (void)user; - (void)client; - - ww = MwGetInteger(handle, MwNwidth) - 100; - wh = MwGetInteger(handle, MwNheight) - 100; - - MwVaApply(opengl, - MwNwidth, ww, - MwNheight, wh, - NULL); - - reshape(ww, wh); -} - -int main() { - MwWidget window; - - window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 500, 500, - MwNtitle, "boing", - NULL); - opengl = MwCreateWidget(MwOpenGLClass, "opengl", window, 50, 50, 400, 400); - - MwOpenGLMakeCurrent(opengl); - - init(); - reshape(400, 400); - - MwAddUserHandler(window, MwNresizeHandler, resize, NULL); - MwAddUserHandler(window, MwNtickHandler, tick, NULL); - - MwLoop(window); -} diff --git a/examples/glgears.c b/examples/glgears.c index c1d745e..ba0b161 100644 --- a/examples/glgears.c +++ b/examples/glgears.c @@ -1,10 +1,6 @@ /* $Id$ */ -#include -#include - -#include - -MwWidget opengl; +#define TITLE "gears" +#include "oldglut.c" /* * 3-D gear wheels. This program is in the public domain. @@ -178,6 +174,10 @@ static void draw(void) { glPopMatrix(); } +static void idle(void) { + angle += 2.0; +} + /* new window size or exposure */ static void reshape(int width, int height) { GLfloat h = (GLfloat)height / (GLfloat)width; @@ -228,51 +228,3 @@ static void init(void) { glEnable(GL_NORMALIZE); } - -static void tick(MwWidget handle, void* user, void* client) { - (void)handle; - (void)user; - (void)client; - - draw(); - angle += 2.0; - - MwOpenGLSwapBuffer(opengl); -} - -static void resize(MwWidget handle, void* user, void* client) { - int ww, wh; - - (void)handle; - (void)user; - (void)client; - - ww = MwGetInteger(handle, MwNwidth) - 100; - wh = MwGetInteger(handle, MwNheight) - 100; - - MwVaApply(opengl, - MwNwidth, ww, - MwNheight, wh, - NULL); - - reshape(ww, wh); -} - -int main() { - MwWidget window; - - window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 500, 500, - MwNtitle, "gears", - NULL); - opengl = MwCreateWidget(MwOpenGLClass, "opengl", window, 50, 50, 400, 400); - - MwOpenGLMakeCurrent(opengl); - - init(); - reshape(400, 400); - - MwAddUserHandler(window, MwNresizeHandler, resize, NULL); - MwAddUserHandler(window, MwNtickHandler, tick, NULL); - - MwLoop(window); -} diff --git a/examples/oldglut.c b/examples/oldglut.c new file mode 100644 index 0000000..bcdd6c1 --- /dev/null +++ b/examples/oldglut.c @@ -0,0 +1,59 @@ +#include +#include + +#include + +MwWidget opengl; + +static void draw(void); +static void idle(void); +static void reshape(int width, int height); +static void init(void); + +static void tick(MwWidget handle, void* user, void* client) { + (void)handle; + (void)user; + (void)client; + + draw(); + idle(); + + MwOpenGLSwapBuffer(opengl); +} + +static void resize(MwWidget handle, void* user, void* client) { + int ww, wh; + + (void)handle; + (void)user; + (void)client; + + ww = MwGetInteger(handle, MwNwidth) - 100; + wh = MwGetInteger(handle, MwNheight) - 100; + + MwVaApply(opengl, + MwNwidth, ww, + MwNheight, wh, + NULL); + + reshape(ww, wh); +} + +int main() { + MwWidget window; + + window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 500, 500, + MwNtitle, TITLE, + NULL); + opengl = MwCreateWidget(MwOpenGLClass, "opengl", window, 50, 50, 400, 400); + + MwOpenGLMakeCurrent(opengl); + + init(); + reshape(400, 400); + + MwAddUserHandler(window, MwNresizeHandler, resize, NULL); + MwAddUserHandler(window, MwNtickHandler, tick, NULL); + + MwLoop(window); +}