/programs/demos/cubeline/trunk/Makefile |
---|
0,0 → 1,15 |
OUTFILE = cubeline |
SRCS = main.cpp fps.cpp |
OBJS = $(SRCS:.cpp=.o) |
CPPFLAGS = -I$(TINYGL)\include -O2 |
LIBR = TinyGL m |
LIBS = $(addprefix -l,$(LIBR)) -L$(TINYGL)\lib |
all: $(OUTFILE) |
objcopy $(OUTFILE) -O binary |
include $(MENUETDEV)/makefiles/Makefile_for_cpp_program |
/programs/demos/cubeline/trunk/ProcessTab.h |
---|
0,0 → 1,24 |
struct process_table_entry_ |
{ |
__u32 cpu_usage __attribute__((packed)); |
__u16 pos_in_windowing_stack __attribute__((packed)); |
__u16 win_stack_val_at_ecx __attribute__((packed)); |
__u16 rez1 __attribute__((packed)); |
char name[11] __attribute__((packed)); |
__u8 rez2 __attribute__((packed)); |
__u32 memstart __attribute__((packed)); |
__u32 memused __attribute__((packed)); |
__u32 pid __attribute__((packed)); |
__u32 winx_start,winy_start __attribute__((packed)); |
__u32 winx_size,winy_size __attribute__((packed)); |
__u8 slot __attribute__((packed)); |
__u8 rez3 __attribute__((packed)); |
__u32 clarx_start,clary_start __attribute__((packed)); |
__u32 clarx_size,clary_size __attribute__((packed)); |
__u8 win_condition __attribute__((packed)); |
__u8 buf[955] __attribute__((packed)); |
} __attribute__((packed)); |
#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 |
/programs/demos/cubeline/trunk/SysCall.h |
---|
0,0 → 1,188 |
#ifndef __cplusplus |
//"inline" ôóíêöèè äëÿ âûçîâà ñèñòåìíûõ ôóíêöèé Kolibri â C - â èìåíè ôóíêöèè êîë-âî ïàðàìåòðîâ |
//SysCall# (íîìåð_ñèñòåìíîé_ôóíêöèè, ïàðàìåòðû,...) |
static inline int SysCall1 (int EAX__) __attribute__((always_inline)); |
static inline int SysCall2 (int EAX__, int EBX__) __attribute__((always_inline)); |
static inline int SysCall3 (int EAX__, int EBX__, int ECX__) __attribute__((always_inline)); |
static inline int SysCall4 (int EAX__, int EBX__, int ECX__, int EDX__) __attribute__((always_inline)); |
static inline int SysCall5 (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__) __attribute__((always_inline)); |
static inline int SysCall6 (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__, int EDI__) __attribute__((always_inline)); |
static inline int SysCall1 (int EAX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall2 (int EAX__, int EBX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall3 (int EAX__, int EBX__, int ECX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall4 (int EAX__, int EBX__, int ECX__, int EDX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile(""::"d"(EDX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall5 (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile(""::"d"(EDX__)); |
asm volatile(""::"S"(ESI__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall6 (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__, int EDI__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile(""::"d"(EDX__)); |
asm volatile(""::"S"(ESI__)); |
asm volatile(""::"D"(EDI__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
#else |
//"inline" ôóíêöèè äëÿ âûçîâà ñèñòåìíûõ ôóíêöèé Kolibri â C++ |
//SysCall(íîìåð_ñèñòåìíîé_ôóíêöèè, ïàðàìåòðû,...) |
static inline int SysCall (int EAX__) __attribute__((always_inline)); |
static inline int SysCall (int EAX__, int EBX__) __attribute__((always_inline)); |
static inline int SysCall (int EAX__, int EBX__, int ECX__) __attribute__((always_inline)); |
static inline int SysCall (int EAX__, int EBX__, int ECX__, int EDX__) __attribute__((always_inline)); |
static inline int SysCall (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__) __attribute__((always_inline)); |
static inline int SysCall (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__, int EDI__) __attribute__((always_inline)); |
static inline int SysCall (int EAX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall (int EAX__, int EBX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall (int EAX__, int EBX__, int ECX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall (int EAX__, int EBX__, int ECX__, int EDX__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile(""::"d"(EDX__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile(""::"d"(EDX__)); |
asm volatile(""::"S"(ESI__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
static inline int SysCall (int EAX__, int EBX__, int ECX__, int EDX__, int ESI__, int EDI__) |
{ |
asm volatile(""::"a"(EAX__)); |
asm volatile(""::"b"(EBX__)); |
asm volatile(""::"c"(ECX__)); |
asm volatile(""::"d"(EDX__)); |
asm volatile(""::"S"(ESI__)); |
asm volatile(""::"D"(EDI__)); |
asm volatile("int $0x40"); |
register int res; |
asm volatile("":"=a"(res):); |
return res; |
} |
#endif |
/programs/demos/cubeline/trunk/fps.cpp |
---|
0,0 → 1,46 |
#include<menuet/os.h> |
#include "SysCall.h" |
/******************************************************************************* |
ÔÓÍÊÖÈß ÎÏÐÅÄÅËÅÍÈß FPS |
x,y - êîîðäèíàòû âûâîäà FPS íà îêíî |
âîçâðàùàåò âðåìÿ â ñîòûõ äîëÿõ ñåêóíäû çàòðà÷èâàåìîå íà 1 öèêë |
*/ |
int time1=0; |
int time2=0; |
int fps1=0; |
int timerend=0; |
int Fps (long x, long y)//ôóíêöèÿ îïðåäåëåíèÿ FPS |
{ |
int tr; |
time1 = SysCall(26,9);//îïðåäåëÿåì âðåìÿ ïðîøåäøåå ìîìåíòà çàïóñêà ñèñòåìû |
if (timerend==0) |
{ |
time2=time1; |
timerend=time1; |
} |
tr = time1 - timerend; |
if ((time1 - time2) < 100)//åñëè ïðîøëî ìåíåå 1 ñåêóíäû |
{ //óâåëè÷èâàåì ñ÷åò÷èê fps |
fps1++; |
} |
else |
{ |
//âûâîäèì ÷èñëî fps |
SysCall(13,(x<<16)+23,(y<<16)+7,0x00555555); //ÍÀÐÈÑÎÂÀÒÜ ÏÎËÎÑÓ |
SysCall(47,4<<16,fps1,(x<<16)+y,0xfafafa);//ÂÛÂÅÑÒÈ Â ÎÊÍÎ ÏÐÈËÎÆÅÍÈß ×ÈÑËÎ |
fps1=0; |
time2=time1; |
} |
timerend=time1; |
return tr; |
} |
//****************************************************************************** |
/programs/demos/cubeline/trunk/main.cpp |
---|
0,0 → 1,251 |
/* |
Ïðèìåð âçÿò èç íàáîðà ïðèìåðîâ ê êîìïèëÿòîðó XS Compiler |
iadn |
http://www.iadn.narod.ru |
iadn@bk.ru |
*/ |
#include <string.h> |
#include<menuet/os.h> |
#include <kosgl.h> //TinyGL |
#include "SysCall.h" |
#include "ProcessTab.h" |
int Fps (long x, long y); |
extern "C"{ |
void app_main(void); |
} |
struct { |
int x,y; |
int dx,dy; |
} win; |
#define CUBE_STEP 0.1 |
#define KEY_ESC 1 |
#define KEY_F 33 |
char *title1 = "TinyGL in KolibriOS"; |
char *title2 = "F full screen"; |
char *title3 = "ESC - exit"; |
char *fps = "FPS:"; |
unsigned char FullScreen = 0; |
unsigned char skin = 3; |
float angle; |
process_table_entry_* pri; |
KOSGLContext cgl; |
void draw_cube() |
{ |
float x,y,z; |
glBegin(GL_LINES); |
for(y=-0.5;y<=0.5;y+=CUBE_STEP) |
{ |
// the front |
glColor3f(0,y+0.5,0); |
glVertex3f(-0.5,y,-0.5); |
glColor3f(1,y+0.5,0); |
glVertex3f(0.5,y,-0.5); |
// the back |
glColor3f(0,y+0.5,1); |
glVertex3f(-0.5,y,0.5); |
glColor3f(1,y+0.5,1); |
glVertex3f(0.5,y,0.5); |
//right side |
glColor3f(1,y+0.5,0); |
glVertex3f(0.5,y,-0.5); |
glColor3f(1,y+0.5,1); |
glVertex3f(0.5,y,0.5); |
//left side |
glColor3f(0,y+0.5,0); |
glVertex3f(-0.5,y,-0.5); |
glColor3f(0,y+0.5,1); |
glVertex3f(-0.5,y,0.5); |
} |
for(x=-0.5;x<=0.5;x+=CUBE_STEP) |
{ |
// the front |
glColor3f(x+0.5,1,0); |
glVertex3f(x,0.5,-0.5); |
glColor3f(x+0.5,0,0); |
glVertex3f(x,-0.5,-0.5); |
// the back |
glColor3f(x+0.5,1,1); |
glVertex3f(x,0.5,0.5); |
glColor3f(x+0.5,0,1); |
glVertex3f(x,-0.5,0.5); |
// the top |
glColor3f(x+0.5,1,0); |
glVertex3f(x,0.5,-0.5); |
glColor3f(x+0.5,1,1); |
glVertex3f(x,0.5,0.5); |
// the bottom |
glColor3f(x+0.5,0,0); |
glVertex3f(x,-0.5,-0.5); |
glColor3f(x+0.5,0,1); |
glVertex3f(x,-0.5,0.5); |
} |
for(z=-0.5;z<=0.5;z+=CUBE_STEP) |
{ |
// the top |
glColor3f(0,1,z+0.5); |
glVertex3f(-0.5,0.5,z); |
glColor3f(1,1,z+0.5); |
glVertex3f(0.5,0.5,z); |
// the bottom |
glColor3f(0,0,z+0.5); |
glVertex3f(-0.5,-0.5,z); |
glColor3f(1,0,z+0.5); |
glVertex3f(0.5,-0.5,z); |
// right side |
glColor3f(1,1,z+0.5); |
glVertex3f(0.5,0.5,z); |
glColor3f(1,0,z+0.5); |
glVertex3f(0.5,-0.5,z); |
// left side |
glColor3f(0,1,z+0.5); |
glVertex3f(-0.5,0.5,z); |
glColor3f(0,0,z+0.5); |
glVertex3f(-0.5,-0.5,z); |
} |
glEnd(); |
} |
void DrawGL() |
{ |
glLoadIdentity(); // óñòàíàâëèâàåì åäåíè÷íóþ ìàòðèöó |
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
glTranslatef(0.0, 0.0, -3.0); |
glRotatef(angle, 1.0, 0.0, 0.0); |
glRotatef(2.0*angle, 0.0, 1.0, 0.0); |
glRotatef(3.0*angle, 0.0, 0.0, 1.0); |
draw_cube(); |
kosglSwapBuffers(); |
} |
void reshape() |
{ |
__menuet__get_process_table((process_table_entry*)pri,-1); |
glViewport(0, 0, pri->winx_size, pri->winy_size-20); |
glMatrixMode(GL_PROJECTION); |
glLoadIdentity(); |
gluPerspective(45.0, (GLfloat)pri->winx_size/pri->winy_size, 1.0, 300.0); |
glMatrixMode(GL_MODELVIEW); |
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); |
} |
void disabletgl() |
{ |
kosglDestroyContext(cgl); |
delete pri; |
} |
void Title() |
{ |
__menuet__write_text(300,8,0x10ffffff,fps,strlen(fps)); |
__menuet__write_text(8,8,0x10ffffff,title1,strlen(title1)); |
__menuet__write_text(180,8,0x00ffffff,title2,strlen(title2)); |
__menuet__write_text(600,8,0x00ffffff,title3,strlen(title3)); |
} |
void draw_window(void) |
{ |
// start redraw |
__menuet__window_redraw(1); |
// define&draw window |
__menuet__define_window(win.x,win.y,win.dx,win.dy,TYPEWIN(0,0,0,1,skin,0,0,0),0,0); |
// end redraw |
__menuet__window_redraw(2); |
// display string |
Title(); |
} |
void app_main(void) |
{ |
win.x = 100; |
win.y = 100; |
win.dx = 400; |
win.dy = 400; |
draw_window(); |
cgl = kosglCreateContext( 0, 0); |
kosglMakeCurrent( 0, 20, win.dx, win.dy-20, cgl); |
glMatrixMode(GL_MODELVIEW); |
glLoadIdentity(); |
glClearDepth(1.0); |
glEnable( GL_CULL_FACE ); |
glEnable(GL_DEPTH_TEST); |
pri=new process_table_entry_; |
SysCall(66,1,1); |
reshape(); |
do{ |
if (angle < 360.0) angle += 0.001 + 0.1*Fps (330,8); |
else angle = 0.0; |
DrawGL(); |
switch(__menuet__check_for_event()) |
{ |
case 1: draw_window(); |
reshape(); |
break; |
case 2: |
switch(__menuet__getkey()){ |
case KEY_F: |
if(!FullScreen){ |
skin=0; |
SysCall(67,0,0,SysCall(14)>>16,SysCall(14)&0xffff); |
draw_window(); |
reshape(); |
FullScreen = 1; |
} |
else{ |
skin=3; |
draw_window(); |
SysCall(67,win.x,win.y,win.dx,win.dy); |
reshape(); |
FullScreen = 0; |
}; |
break; |
case KEY_ESC: disabletgl(); |
return;} |
break; |
case 3: disabletgl(); |
return; |
} |
}while(1); |
} |
/programs/demos/cubeline/trunk |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/demos/cubeline/. |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |