2011-01-29 18:39:35 +01:00
|
|
|
|
/*
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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"{
|
2014-09-12 17:15:23 +02:00
|
|
|
|
int main(void);
|
2011-01-29 18:39:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static struct {
|
2011-01-29 18:39:35 +01:00
|
|
|
|
int x,y;
|
|
|
|
|
int dx,dy;
|
|
|
|
|
} win;
|
|
|
|
|
|
|
|
|
|
#define CUBE_STEP 0.1
|
|
|
|
|
|
|
|
|
|
#define KEY_ESC 1
|
|
|
|
|
#define KEY_F 33
|
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static unsigned char FullScreen = 0;
|
|
|
|
|
static unsigned char skin = 3;
|
2011-01-29 18:39:35 +01:00
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static float angle;
|
|
|
|
|
static process_table_entry_* pri;
|
|
|
|
|
static KOSGLContext cgl;
|
2011-01-29 18:39:35 +01:00
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static void draw_cube()
|
2011-01-29 18:39:35 +01:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static void DrawGL()
|
2011-01-29 18:39:35 +01:00
|
|
|
|
{
|
|
|
|
|
glLoadIdentity(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static void reshape()
|
2011-01-29 18:39:35 +01:00
|
|
|
|
{
|
|
|
|
|
__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 );
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static void disabletgl()
|
2011-01-29 18:39:35 +01:00
|
|
|
|
{
|
|
|
|
|
kosglDestroyContext(cgl);
|
|
|
|
|
delete pri;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
static void draw_window(void)
|
2011-01-29 18:39:35 +01:00
|
|
|
|
{
|
2020-05-19 22:28:37 +02:00
|
|
|
|
__menuet__window_redraw(1); // start redraw
|
2020-05-19 22:35:55 +02:00
|
|
|
|
__menuet__define_window(win.x,win.y,win.dx,win.dy,TYPEWIN(0,0,0,1,skin,0,0,0),0,
|
|
|
|
|
"Cubeline / F full screen / FPS:");
|
2020-05-19 22:28:37 +02:00
|
|
|
|
__menuet__window_redraw(2); // end redraw
|
2011-01-29 18:39:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 17:15:23 +02:00
|
|
|
|
int main(void)
|
2011-01-29 18:39:35 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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();
|
2014-09-12 17:15:23 +02:00
|
|
|
|
return 0;}
|
2011-01-29 18:39:35 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3: disabletgl();
|
2014-09-12 17:15:23 +02:00
|
|
|
|
return 0;
|
2011-01-29 18:39:35 +01:00
|
|
|
|
}
|
|
|
|
|
}while(1);
|
|
|
|
|
}
|