gears: clean

git-svn-id: svn://kolibrios.org@8530 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
maxcodehack 2021-01-09 14:13:56 +00:00
parent 15d1f5c424
commit 6b8f636ed1
2 changed files with 243 additions and 255 deletions

View File

@ -1,2 +0,0 @@
#define TYPEWIN(D,C,B,A,Y,RR,GG,BB) (D<<31)|(C<<30)|(B<<29)|(A<<28)|(Y<<24)|\
(RR<<16)|(GG<<8)|BB

View File

@ -12,18 +12,18 @@ iadn@bk.ru
* Brian Paul * Brian Paul
*/ */
/*
* Newlib port by maxcodehack
*/
#include <kos32sys.h> #include <kos32sys.h>
#include <kosgl.h> // TinyGL #include <kosgl.h> // TinyGL
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include "SysCall.h" #include "SysCall.h"
#include "ProcessTab.h"
int Fps (long x, long y); int Fps (long x, long y);
extern "C"{
int main(void);
}
struct { struct {
int x,y; int x,y;
@ -33,13 +33,13 @@ struct {
#define KEY_ESC 1 #define KEY_ESC 1
#define KEY_F 33 #define KEY_F 33
char *title1 = "TinyGL in KolibriOS"; char *title = "Gears (F - full screen, ESC - exit)";
char *title2 = "F full screen";
char *title3 = "ESC - exit";
char *fps = "FPS:"; char *fps = "FPS:";
unsigned char FullScreen = 0; unsigned char FullScreen = 0;
unsigned char skin = 3; unsigned char skin = 0x34;
oskey_t key;
proc_info* pri; proc_info* pri;
KOSGLContext cgl; KOSGLContext cgl;
@ -173,7 +173,7 @@ static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
glEnd(); glEnd();
} }
void init( void ) void init()
{ {
static GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 }; static GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 };
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 }; static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 };
@ -243,37 +243,24 @@ void kos_text(int x, int y, int color, const char* text, int len)
void Title() void Title()
{ {
kos_text(300,8,0x10ffffff,fps,strlen(fps)); kos_text(300,8,0x10ffffff,fps,strlen(fps));
kos_text(180,8,0x00ffffff,title2,strlen(title2)); /*kos_text(180,8,0x90ffffff,title2,strlen(title2));
kos_text(600,8,0x00ffffff,title3,strlen(title3)); kos_text(600,8,0x90ffffff,title3,strlen(title3));*/
} }
void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) void draw_window()
{
asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) );
}
void draw_window(void)
{ {
// start redraw // start redraw
begin_draw(); begin_draw();
// define&draw window // define&draw window
kol_wnd_define(win.x,win.y,win.dx,win.dy,TYPEWIN(0,0,0,1,skin,0,0,0),0,title1); sys_create_window(win.x, win.y, win.dx, win.dy, title, 0, /*TYPEWIN(0,0,0,1,skin,0,0,0)*/skin);
// end redraw // end redraw
end_draw(); end_draw();
// display string // display string
Title(); Title();
} }
int kos_get_key() int main()
{ {
unsigned short __ret;
asm volatile("int $0x40":"=a"(__ret):"0"(2));
if(!(__ret & 0xFF)) return (__ret>>8)&0xFF; else return 0;
}
int main(void)
{
win.x = 100; win.x = 100;
win.y = 100; win.y = 100;
win.dx = 400; win.dx = 400;
@ -282,7 +269,7 @@ int main(void)
draw_window(); draw_window();
cgl = kosglCreateContext( 0, 0); cgl = kosglCreateContext( 0, 0);
kosglMakeCurrent( 0, 20, win.dx, win.dy-20, cgl); kosglMakeCurrent( 0, 0, win.dx, win.dy, cgl);
init(); init();
@ -292,7 +279,6 @@ int main(void)
reshape(); reshape();
do { do {
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix(); glPushMatrix();
@ -324,25 +310,26 @@ do{
angle += 0.01 + 0.3 * Fps (330, 8); angle += 0.01 + 0.3 * Fps (330, 8);
switch(SysCall(11)) switch(check_os_event())
{ {
case 1: draw_window(); case 1:
draw_window();
reshape(); reshape();
break; break;
case 2: case 2:
switch(kos_get_key()){ key = get_key();
switch(key.code) {
case KEY_F: case KEY_F:
if(!FullScreen){ if(!FullScreen){
skin=0; skin=0x01;
SysCall(67,0,0,SysCall(14)>>16,SysCall(14)&0xffff); SysCall(67,0,0,SysCall(14)>>16,SysCall(14)&0xffff);
draw_window(); draw_window();
reshape(); reshape();
FullScreen = 1; FullScreen = 1;
} }
else{ else{
skin=3; skin=0x34;
draw_window(); draw_window();
SysCall(67,win.x,win.y,win.dx,win.dy); SysCall(67,win.x,win.y,win.dx,win.dy);
reshape(); reshape();
@ -350,11 +337,14 @@ do{
}; };
break; break;
case KEY_ESC: disabletgl(); case KEY_ESC:
return 0;} disabletgl();
return 0;
}
break; break;
case 3: disabletgl(); case 3:
disabletgl();
return 0; return 0;
} }
} while(1); } while(1);