git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@62 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
Nishi 2025-09-29 08:22:34 +00:00
commit 002e721a31
4 changed files with 77 additions and 68 deletions

View file

@ -62,7 +62,7 @@ lib: src/libMw$(SO)
examples: $(EXAMPLES) examples: $(EXAMPLES)
format: format:
clang-format --verbose -i $(shell find src include -name "*.c" -or -name "*.h") clang-format --verbose -i $(shell find src include examples -name "*.c" -or -name "*.h")
src/libMw$(SO): $(L_OBJS) src/libMw$(SO): $(L_OBJS)
$(CC) $(L_LDFLAGS) -shared -o $@ $(L_OBJS) $(L_LIBS) $(CC) $(L_LDFLAGS) -shared -o $@ $(L_OBJS) $(L_LIBS)

View file

@ -4,7 +4,7 @@
MwWidget window, button, button2, button3, button4; MwWidget window, button, button2, button3, button4;
void handler(MwWidget handle, void* user_data, void* call_data){ void handler(MwWidget handle, void* user_data, void* call_data) {
(void)handle; (void)handle;
(void)user_data; (void)user_data;
(void)call_data; (void)call_data;
@ -12,7 +12,7 @@ void handler(MwWidget handle, void* user_data, void* call_data){
printf("hello world!\n"); printf("hello world!\n");
} }
void resize(MwWidget handle, void* user_data, void* call_data){ void resize(MwWidget handle, void* user_data, void* call_data) {
unsigned int w, h; unsigned int w, h;
(void)user_data; (void)user_data;
@ -45,7 +45,7 @@ void resize(MwWidget handle, void* user_data, void* call_data){
NULL); NULL);
} }
int main(){ int main() {
window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400, window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
MwNtitle, "hello world", MwNtitle, "hello world",
NULL); NULL);

View file

@ -6,8 +6,9 @@
MwWidget window, opengl; MwWidget window, opengl;
int ow, oh; int ow, oh;
double deg = 0;
void resize(MwWidget handle, void* user_data, void* call_data){ void resize(MwWidget handle, void* user_data, void* call_data) {
unsigned int w, h; unsigned int w, h;
(void)user_data; (void)user_data;
@ -22,7 +23,7 @@ void resize(MwWidget handle, void* user_data, void* call_data){
NULL); NULL);
} }
void tick(MwWidget handle, void* user_data, void* call_data){ void tick(MwWidget handle, void* user_data, void* call_data) {
(void)handle; (void)handle;
(void)user_data; (void)user_data;
(void)call_data; (void)call_data;
@ -39,16 +40,24 @@ void tick(MwWidget handle, void* user_data, void* call_data){
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glPushMatrix();
glRotatef(deg, 0, 0, 1);
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0); glVertex2f(0, 0.8); glColor3f(1, 0, 0);
glColor3f(0, 1, 0); glVertex2f(-0.8, -0.8); glVertex2f(0, 0.8);
glColor3f(0, 0, 1); glVertex2f(0.8, -0.8); glColor3f(0, 1, 0);
glVertex2f(-0.8, -0.8);
glColor3f(0, 0, 1);
glVertex2f(0.8, -0.8);
glEnd(); glEnd();
glPopMatrix();
MwOpenGLSwapBuffer(opengl); MwOpenGLSwapBuffer(opengl);
deg += 120.0 / (1000.0 / MwWaitMS);
} }
int main(){ int main() {
window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400, window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
MwNtitle, "hello world", MwNtitle, "hello world",
NULL); NULL);

View file

@ -16,7 +16,7 @@ double deg = 0;
int ww, wh; int ww, wh;
void handler(MwWidget w, void* user, void* client){ void handler(MwWidget w, void* user, void* client) {
int i; int i;
double cdeg = deg; double cdeg = deg;
@ -24,7 +24,7 @@ void handler(MwWidget w, void* user, void* client){
(void)user; (void)user;
(void)client; (void)client;
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++){ for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
double rad = cdeg / 180 * M_PI; double rad = cdeg / 180 * M_PI;
int x = ww / 2; int x = ww / 2;
int y = wh / 2; int y = wh / 2;
@ -46,7 +46,7 @@ void handler(MwWidget w, void* user, void* client){
deg += 120.0 / (1000.0 / MwWaitMS); deg += 120.0 / (1000.0 / MwWaitMS);
} }
void resize(MwWidget w, void* user, void* client){ void resize(MwWidget w, void* user, void* client) {
(void)w; (void)w;
(void)user; (void)user;
(void)client; (void)client;
@ -55,13 +55,13 @@ void resize(MwWidget w, void* user, void* client){
wh = MwGetInteger(w, MwNheight); wh = MwGetInteger(w, MwNheight);
} }
int main(){ int main() {
MwWidget window = MwVaCreateWidget(MwWindowClass, "window", NULL, 0, 0, (ww = 500), (wh = 500), MwWidget window = MwVaCreateWidget(MwWindowClass, "window", NULL, 0, 0, (ww = 500), (wh = 500),
MwNtitle, "rotate", MwNtitle, "rotate",
NULL); NULL);
int i; int i;
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++){ for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
const char* color = ""; const char* color = "";
char fgcolor[5]; char fgcolor[5];
int j; int j;
@ -75,7 +75,7 @@ int main(){
fgcolor[0] = '#'; fgcolor[0] = '#';
fgcolor[4] = 0; fgcolor[4] = 0;
for(j = 0; j < 3; j++){ for(j = 0; j < 3; j++) {
fgcolor[j + 1] = color[j + 1] == 'f' ? '6' : 'f'; fgcolor[j + 1] = color[j + 1] == 'f' ? '6' : 'f';
} }