mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-06 17:39:45 +00:00
better layout
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@343 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
64
examples/gldemos/glutlayer.c
Normal file
64
examples/gldemos/glutlayer.c
Normal file
@@ -0,0 +1,64 @@
|
||||
#include <Mw/Milsko.h>
|
||||
#include <Mw/Widget/OpenGL.h>
|
||||
|
||||
MwWidget opengl;
|
||||
|
||||
static void draw(void);
|
||||
static void idle(void);
|
||||
static void reshape(int width, int height);
|
||||
static void init(void);
|
||||
static void key(int k);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void key_pressed(MwWidget handle, void* user, void* client) {
|
||||
key(*(int*)client);
|
||||
}
|
||||
|
||||
int main() {
|
||||
MwWidget window;
|
||||
|
||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 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);
|
||||
|
||||
MwAddUserHandler(opengl, MwNkeyHandler, key_pressed, NULL);
|
||||
|
||||
MwLoop(window);
|
||||
}
|
||||
Reference in New Issue
Block a user