mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-07 01:49:47 +00:00
OpenGL
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@61 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -14,12 +14,13 @@ void handler(MwWidget handle, void* user_data, void* call_data){
|
||||
|
||||
void resize(MwWidget handle, void* user_data, void* call_data){
|
||||
unsigned int w, h;
|
||||
w = MwGetInteger(handle, MwNwidth);
|
||||
h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
w = MwGetInteger(handle, MwNwidth);
|
||||
h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
MwVaApply(button,
|
||||
MwNwidth, w - 50 * 2,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
|
||||
61
examples/opengl.c
Normal file
61
examples/opengl.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
MwWidget window, opengl;
|
||||
int ow, oh;
|
||||
|
||||
void resize(MwWidget handle, void* user_data, void* call_data){
|
||||
unsigned int w, h;
|
||||
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
w = MwGetInteger(handle, MwNwidth);
|
||||
h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
MwVaApply(opengl,
|
||||
MwNwidth, (ow = w - 100),
|
||||
MwNheight, (oh = h - 100),
|
||||
NULL);
|
||||
}
|
||||
|
||||
void tick(MwWidget handle, void* user_data, void* call_data){
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
MwOpenGLMakeCurrent(opengl);
|
||||
|
||||
glViewport(0, 0, ow, oh);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1, 1, -1, 1, -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1, 0, 0); glVertex2f(0, 0.8);
|
||||
glColor3f(0, 1, 0); glVertex2f(-0.8, -0.8);
|
||||
glColor3f(0, 0, 1); glVertex2f(0.8, -0.8);
|
||||
glEnd();
|
||||
|
||||
MwOpenGLSwapBuffer(opengl);
|
||||
}
|
||||
|
||||
int main(){
|
||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
|
||||
MwNtitle, "hello world",
|
||||
NULL);
|
||||
opengl = MwCreateWidget(MwOpenGLClass, "opengl", window, 50, 50, (ow = 300), (oh = 300));
|
||||
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
||||
|
||||
MwLoop(window);
|
||||
}
|
||||
Reference in New Issue
Block a user