forked from KolibriOS/kolibrios
gears: clean
git-svn-id: svn://kolibrios.org@8530 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
15d1f5c424
commit
6b8f636ed1
@ -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
|
@ -12,18 +12,18 @@ iadn@bk.ru
|
||||
* Brian Paul
|
||||
*/
|
||||
|
||||
/*
|
||||
* Newlib port by maxcodehack
|
||||
*/
|
||||
|
||||
#include <kos32sys.h>
|
||||
#include <kosgl.h> // TinyGL
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "SysCall.h"
|
||||
#include "ProcessTab.h"
|
||||
|
||||
int Fps (long x, long y);
|
||||
extern "C"{
|
||||
int main(void);
|
||||
}
|
||||
|
||||
struct {
|
||||
int x,y;
|
||||
@ -33,13 +33,13 @@ struct {
|
||||
#define KEY_ESC 1
|
||||
#define KEY_F 33
|
||||
|
||||
char *title1 = "TinyGL in KolibriOS";
|
||||
char *title2 = "F full screen";
|
||||
char *title3 = "ESC - exit";
|
||||
char *title = "Gears (F - full screen, ESC - exit)";
|
||||
char *fps = "FPS:";
|
||||
|
||||
unsigned char FullScreen = 0;
|
||||
unsigned char skin = 3;
|
||||
unsigned char skin = 0x34;
|
||||
|
||||
oskey_t key;
|
||||
|
||||
proc_info* pri;
|
||||
KOSGLContext cgl;
|
||||
@ -173,7 +173,7 @@ static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void init( void )
|
||||
void init()
|
||||
{
|
||||
static GLfloat pos[4] = {5.0, 5.0, 10.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()
|
||||
{
|
||||
kos_text(300,8,0x10ffffff,fps,strlen(fps));
|
||||
kos_text(180,8,0x00ffffff,title2,strlen(title2));
|
||||
kos_text(600,8,0x00ffffff,title3,strlen(title3));
|
||||
/*kos_text(180,8,0x90ffffff,title2,strlen(title2));
|
||||
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)
|
||||
{
|
||||
asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) );
|
||||
}
|
||||
|
||||
void draw_window(void)
|
||||
void draw_window()
|
||||
{
|
||||
// start redraw
|
||||
begin_draw();
|
||||
// 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_draw();
|
||||
// display string
|
||||
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.y = 100;
|
||||
win.dx = 400;
|
||||
@ -282,7 +269,7 @@ int main(void)
|
||||
draw_window();
|
||||
|
||||
cgl = kosglCreateContext( 0, 0);
|
||||
kosglMakeCurrent( 0, 20, win.dx, win.dy-20, cgl);
|
||||
kosglMakeCurrent( 0, 0, win.dx, win.dy, cgl);
|
||||
|
||||
init();
|
||||
|
||||
@ -292,7 +279,6 @@ int main(void)
|
||||
reshape();
|
||||
|
||||
do {
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
glPushMatrix();
|
||||
@ -324,25 +310,26 @@ do{
|
||||
|
||||
angle += 0.01 + 0.3 * Fps (330, 8);
|
||||
|
||||
switch(SysCall(11))
|
||||
switch(check_os_event())
|
||||
{
|
||||
case 1: draw_window();
|
||||
case 1:
|
||||
draw_window();
|
||||
reshape();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
switch(kos_get_key()){
|
||||
|
||||
key = get_key();
|
||||
switch(key.code) {
|
||||
case KEY_F:
|
||||
if(!FullScreen){
|
||||
skin=0;
|
||||
skin=0x01;
|
||||
SysCall(67,0,0,SysCall(14)>>16,SysCall(14)&0xffff);
|
||||
draw_window();
|
||||
reshape();
|
||||
FullScreen = 1;
|
||||
}
|
||||
else{
|
||||
skin=3;
|
||||
skin=0x34;
|
||||
draw_window();
|
||||
SysCall(67,win.x,win.y,win.dx,win.dy);
|
||||
reshape();
|
||||
@ -350,11 +337,14 @@ do{
|
||||
};
|
||||
break;
|
||||
|
||||
case KEY_ESC: disabletgl();
|
||||
return 0;}
|
||||
case KEY_ESC:
|
||||
disabletgl();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: disabletgl();
|
||||
case 3:
|
||||
disabletgl();
|
||||
return 0;
|
||||
}
|
||||
} while(1);
|
||||
|
Loading…
Reference in New Issue
Block a user