/programs/demos/cubetext/trunk/Makefile |
---|
0,0 → 1,15 |
OUTFILE = cubetext |
SRCS = main.cpp fps.cpp bmp.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/cubetext/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/cubetext/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/cubetext/trunk/bmp.cpp |
---|
0,0 → 1,442 |
// |
// bmp.cpp - source file / freeware |
// |
// David Henry - tfc_duke@hotmail.com |
// |
#include "bmp.h" |
#include <stdio.h> |
#include <libc/stubs.h> |
extern "C"{ |
long filelength(int fhandle); |
} |
// -------------------------------------------------- |
// LoadFileBMP() - load a Windows/OS2 BITMAP image |
// [.bmp]. |
// |
// parameters : |
// - filename [in] : image source file |
// - pixels [out] : 32 bits rgb image data |
// - width [out] : image width in pixels |
// - height [out] : image height in pixels |
// - flipvert [in] : flip vertically |
// |
// return value : |
// - -1 : no image data |
// - 0 : failure |
// - 1 : success |
// |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
// accepted image formats : |
// # RGB 1-4-8-24-32 bits WINDOWS - OS/2 |
// # RLE 4-8 bits WINDOWS |
// -------------------------------------------------- |
int LoadFileBMP( const char *filename, unsigned char **pixels, int *width, int *height, bool flipvert ) |
{ |
FILE *file; // file stream |
BITMAPFILEHEADER *bmfh; // bitmap file header |
BITMAPINFOHEADER *bmih; // bitmap info header (windows) |
BITMAPCOREHEADER *bmch; // bitmap core header (os/2) |
RGBTRIPLE *os2_palette; // pointer to the color palette os/2 |
RGBQUAD *win_palette; // pointer to the color palette windows |
char *buffer; // buffer storing the entire file |
unsigned char *ptr; // pointer to pixels data |
int bitCount; // number of bits per pixel |
int compression; // compression type (rgb/rle) |
int row, col, i; // temporary variables |
int w, h; // width, height |
///////////////////////////////////////////////////// |
// read the entire file in the buffer |
file = fopen(filename,"rb"); |
if( !file) |
return 0; |
long flen = filelength(fileno(file)); |
buffer = new char[ flen + 1 ]; |
int rd = fread(buffer, flen, 1, file); |
char *pBuff = buffer; |
fclose(file); |
///////////////////////////////////////////////////// |
// read the header |
bmfh = (BITMAPFILEHEADER *)pBuff; |
pBuff += sizeof( BITMAPFILEHEADER ); |
// verify that it's a BITMAP file |
if( bmfh->bfType != BITMAP_ID ) |
{ |
delete [] buffer; |
return 0; |
} |
bmch = (BITMAPCOREHEADER *)pBuff; |
bmih = (BITMAPINFOHEADER *)pBuff; |
if( (bmih->biCompression < 0) || (bmih->biCompression > 3) ) |
{ |
// OS/2 style |
pBuff += sizeof( BITMAPCOREHEADER ); |
bitCount = bmch->bcBitCount; |
compression = BI_OS2; |
w = bmch->bcWidth; |
h = bmch->bcHeight; |
} |
else |
{ |
// WINDOWS style |
pBuff += sizeof( BITMAPINFOHEADER ); |
bitCount = bmih->biBitCount; |
compression = bmih->biCompression; |
w = bmih->biWidth; |
h = bmih->biHeight; |
} |
if( width ) |
*width = w; |
if( height ) |
*height = h; |
if( !pixels ) |
{ |
delete [] buffer; |
return (-1); |
} |
///////////////////////////////////////////////////// |
// read the palette |
if( bitCount <= 8 ) |
{ |
// 24 and 32 bits images are not paletted |
// ajust the palette pointer to the memory in the buffer |
os2_palette = (RGBTRIPLE *)pBuff; |
win_palette = (RGBQUAD *)pBuff; |
// [number of colors in the palette] * [size of one pixel] |
pBuff += (1 << bitCount) * (bitCount >> 3) * sizeof( unsigned char ); |
} |
///////////////////////////////////////////////////// |
// allocate memory to store pixel data |
*pixels = new unsigned char[ w * h * 3 ]; |
ptr = &(*pixels)[0]; |
// move the pixel data pointer to the begening of bitmap data |
pBuff = buffer + (bmfh->bfOffBits * sizeof( char )); |
///////////////////////////////////////////////////// |
// read pixel data following the image compression |
// type and the number of bits per pixels |
///////////////////////////////////////////////////// |
switch( compression ) |
{ |
case BI_OS2: |
case BI_RGB: |
{ |
for( row = h - 1; row >= 0; row-- ) |
{ |
if( flipvert ) |
ptr = &(*pixels)[ row * w * 3 ]; |
switch( bitCount ) |
{ |
case 1: |
{ |
// RGB 1 BITS |
for( col = 0; col < (int)(w / 8); col++ ) |
{ |
// read the current pixel |
unsigned char color = *((unsigned char *)(pBuff++)); |
for( i = 7; i >= 0; i--, ptr += 3 ) |
{ |
// convert indexed pixel (1 bit) into rgb (32 bits) pixel |
int clrIdx = ((color & (1<<i)) > 0); |
if( compression == BI_OS2 ) |
{ |
ptr[2] = os2_palette[ clrIdx ].rgbtRed; |
ptr[1] = os2_palette[ clrIdx ].rgbtGreen; |
ptr[0] = os2_palette[ clrIdx ].rgbtBlue; |
} |
else |
{ |
ptr[2] = win_palette[ clrIdx ].rgbRed; |
ptr[1] = win_palette[ clrIdx ].rgbGreen; |
ptr[0] = win_palette[ clrIdx ].rgbBlue; |
} |
} |
} |
break; |
} |
case 4: |
{ |
// RGB 4 BITS |
for( col = 0; col < (int)(w / 2); col++, ptr += 6 ) |
{ |
// read the current pixel |
unsigned char color = *((unsigned char *)(pBuff++)); |
// convert indexed pixel (4 bits) into rgb (32 bits) pixel |
int clrIdx; |
if( compression == BI_OS2 ) |
{ |
clrIdx = (color >> 4); |
ptr[2] = os2_palette[ clrIdx ].rgbtRed; |
ptr[1] = os2_palette[ clrIdx ].rgbtGreen; |
ptr[0] = os2_palette[ clrIdx ].rgbtBlue; |
clrIdx = (color & 0x0F); |
ptr[6] = os2_palette[ clrIdx ].rgbtRed; |
ptr[5] = os2_palette[ clrIdx ].rgbtGreen; |
ptr[4] = os2_palette[ clrIdx ].rgbtBlue; |
} |
else |
{ |
clrIdx = (color >> 4); |
ptr[2] = win_palette[ clrIdx ].rgbRed; |
ptr[1] = win_palette[ clrIdx ].rgbGreen; |
ptr[0] = win_palette[ clrIdx ].rgbBlue; |
clrIdx = (color & 0x0F); |
ptr[6] = win_palette[ clrIdx ].rgbRed; |
ptr[5] = win_palette[ clrIdx ].rgbGreen; |
ptr[4] = win_palette[ clrIdx ].rgbBlue; |
} |
} |
break; |
} |
case 8: |
{ |
// RGB 8 BITS |
for( col = 0; col < w; col++, ptr += 3 ) |
{ |
// read the current pixel |
unsigned char color = *((unsigned char *)(pBuff++)); |
// convert indexed pixel (8 bits) into rgb (32 bits) pixel |
if( compression == BI_OS2 ) |
{ |
ptr[2] = os2_palette[ color ].rgbtRed; |
ptr[1] = os2_palette[ color ].rgbtGreen; |
ptr[0] = os2_palette[ color ].rgbtBlue; |
} |
else |
{ |
ptr[2] = win_palette[ color ].rgbRed; |
ptr[1] = win_palette[ color ].rgbGreen; |
ptr[0] = win_palette[ color ].rgbBlue; |
} |
} |
break; |
} |
case 24: |
{ |
// RGB 24 BITS |
for( col = 0; col < w; col++, ptr += 3 ) |
{ |
// convert bgr pixel (24 bits) into rgb (32 bits) pixel |
RGBTRIPLE *pix = (RGBTRIPLE *)pBuff; |
pBuff += sizeof( RGBTRIPLE ); |
ptr[2] = pix->rgbtRed; |
ptr[1] = pix->rgbtGreen; |
ptr[0] = pix->rgbtBlue; |
} |
break; |
} |
case 32: |
{ |
// RGB 32 BITS |
for( col = 0; col < w; col++, ptr += 3 ) |
{ |
// // convert bgr pixel (32 bits) into rgb (32 bits) pixel |
RGBQUAD *pix = (RGBQUAD *)pBuff; |
pBuff += sizeof( RGBQUAD ); |
ptr[2] = pix->rgbRed; |
ptr[1] = pix->rgbGreen; |
ptr[0] = pix->rgbBlue; |
} |
break; |
} |
} |
} |
break; |
} |
case BI_RLE8: |
{ |
// RLE 8 BITS |
for( row = h - 1; row >= 0; row-- ) |
{ |
if( flipvert ) |
ptr = &(*pixels)[ row * w * 3 ]; |
for( col = 0; col < w; /* nothing */ ) |
{ |
// get one packet (2 bytes) |
unsigned char byte1 = *((unsigned char *)(pBuff++)); |
unsigned char byte2 = *((unsigned char *)(pBuff++)); |
if( byte1 == RLE_COMMAND ) |
{ |
// absolute encoding |
for( i = 0; i < byte2; i++, ptr += 3, col++ ) |
{ |
// read the current pixel |
unsigned char color = *((unsigned char *)(pBuff++)); |
// convert indexed pixel (8 bits) into rgb (32 bits) pixel |
ptr[2] = win_palette[ color ].rgbRed; |
ptr[1] = win_palette[ color ].rgbGreen; |
ptr[0] = win_palette[ color ].rgbBlue; |
} |
if( (byte2 % 2) == 1 ) |
pBuff++; |
} |
else |
{ |
// read next pixels |
for( i = 0; i < byte1; i++, ptr += 3, col++ ) |
{ |
// convert indexed pixel (8 bits) into rgb (32 bits) pixel |
ptr[2] = win_palette[ byte2 ].rgbRed; |
ptr[1] = win_palette[ byte2 ].rgbGreen; |
ptr[0] = win_palette[ byte2 ].rgbBlue; |
} |
} |
} |
} |
break; |
} |
case BI_RLE4: |
{ |
// RLE 4 BITS |
unsigned char color; |
int bytesRead = 0; // number of bytes read |
for( row = h - 1; row >= 0; row-- ) |
{ |
if( flipvert ) |
ptr = &(*pixels)[ row * w * 3 ]; |
for( col = 0; col < w; /* nothing */ ) |
{ |
// get one packet (2 bytes) |
unsigned char byte1 = *((unsigned char *)(pBuff++)); |
unsigned char byte2 = *((unsigned char *)(pBuff++)); |
bytesRead += 2; |
if( byte1 == RLE_COMMAND ) |
{ |
// absolute encoding |
unsigned char databyte; |
for( i = 0; i < byte2; i++, ptr += 3, col++ ) |
{ |
if( (i % 2) == 0 ) |
{ |
// read the current pixel |
databyte = *((unsigned char *)(pBuff++)); |
bytesRead++; |
color = (databyte >> 4); // 4 first bits |
} |
else |
{ |
color = (databyte & 0x0F); // 4 last bits |
} |
// convert indexed pixel (4 bits) into rgb (32 bits) pixel |
ptr[2] = win_palette[ color ].rgbRed; |
ptr[1] = win_palette[ color ].rgbGreen; |
ptr[0] = win_palette[ color ].rgbBlue; |
} |
while( (bytesRead % 2) != 0 ) |
{ |
pBuff++; |
bytesRead++; |
} |
} |
else |
{ |
// read next pixels |
for( i = 0; i < byte1; i++, ptr += 3, col++ ) |
{ |
if( (i % 2) == 0 ) |
color = (byte2 >> 4); // 4 first bits |
else |
color = (byte2 & 0x0F); // 4 last bits |
// convert indexed pixel (4 bits) into rgb (32 bits) pixel |
ptr[2] = win_palette[ color ].rgbRed; |
ptr[1] = win_palette[ color ].rgbGreen; |
ptr[0] = win_palette[ color ].rgbBlue; |
} |
} |
} |
} |
break; |
} |
} |
// free buffer memory |
delete [] buffer; |
// return success |
return 1; |
} |
/programs/demos/cubetext/trunk/bmp.h |
---|
0,0 → 1,142 |
// |
// bmp.h - header file / freeware |
// |
// David Henry - tfc_duke@hotmail.com |
// |
#ifndef __BITMAP_H_ |
#define __BITMAP_H_ |
// magic number "BM" |
#define BITMAP_ID ('B' + ('M'<<8)) |
// header byte type for RLE |
#define RLE_COMMAND 0 |
#define RLE_ENDOFLINE 0 |
#define RLE_ENDOFBITMAP 1 |
#define RLE_DELTA 2 |
#define BI_OS2 -1 |
// compression type |
#define BI_RGB 0 |
#define BI_RLE8 1 |
#define BI_RLE4 2 |
#define BI_BITFIELDS 3 |
#pragma warning( disable : 4103 ) |
// -------------------------------------------- |
// tagBITMAPFILEHEADER - bitmap file header. |
// -------------------------------------------- |
#pragma pack(2) |
typedef struct tagBITMAPFILEHEADER // bmfh |
{ |
unsigned short bfType; // magic number "BM" |
unsigned int bfSize; // file size |
unsigned short bfReserved1; // reserved |
unsigned short bfReserved2; // reserved |
unsigned int bfOffBits; // offset to bitmap data |
} BITMAPFILEHEADER, *PBITMAPFILEHEADER; |
#pragma pack(4) |
// -------------------------------------------- |
// tagBITMAPCOREHEADER - bitmap core header. |
// -------------------------------------------- |
typedef struct tagBITMAPCOREHEADER // bmch |
{ |
unsigned int bcSize; // size of the structure |
unsigned short bcWidth; // image width |
unsigned short bcHeight; // image height |
unsigned short bcPlanes; // must be equal to 1 |
unsigned short bcBitCount; // number of bits per pixel |
} BITMAPCOREHEADER, *PBITMAPCOREHEADER; |
// -------------------------------------------- |
// tagRGBTRIPLE - 24 bits pixel |
// -------------------------------------------- |
typedef struct tagRGBTRIPLE // rgbt |
{ |
unsigned char rgbtBlue; // blue |
unsigned char rgbtGreen; // green |
unsigned char rgbtRed; // red |
} RGBTRIPLE, *PRGBTRIPLE; |
// -------------------------------------------- |
// tagRGBQUAD - 32 bits pixel |
// -------------------------------------------- |
typedef struct tagRGBQUAD // rgbt |
{ |
unsigned char rgbBlue; // blue |
unsigned char rgbGreen; // green |
unsigned char rgbRed; // red |
unsigned char rgbReserved; // reserved |
} RGBQUAD, *PRGBQUAD; |
// -------------------------------------------- |
// tagBITMAPCOREINFO - bitmap core info. |
// -------------------------------------------- |
typedef struct tagBITMAPCOREINFO // bmci |
{ |
BITMAPCOREHEADER bmciHeader; // size of the structure |
RGBTRIPLE bcmiColors[1]; // color palette |
} BITMAPCOREINFO, *PBITMAPCOREINFO; |
// -------------------------------------------- |
// BITMAPFILEHEADER - bitmap info header. |
// -------------------------------------------- |
typedef struct tagBITMAPINFOHEADER |
{ |
unsigned int biSize; // size of the structure |
int biWidth; // image width |
int biHeight; // image height |
unsigned short biPlanes; // must be equal to 1 |
unsigned short biBitCount; // number of bits per pixel |
unsigned int biCompression; // compression type |
unsigned int biSizeImage; // size of data bitmap |
int biXPelsPerMeter; // number of pixels per meter on the X axis |
int biYPelsPerMeter; // number of pixels per meter on the Y axis |
unsigned int biClrUsed; // number of colors used |
unsigned int biClrImportant; // number of important colors |
} BITMAPINFOHEADER, *PBITMAPINFOHEADER; |
// prototype |
int LoadFileBMP( const char *filename, unsigned char **pixels, int *width, int *height, bool flipvert ); |
#endif // __BITMAP_H_ |
/programs/demos/cubetext/trunk/fps.cpp |
---|
0,0 → 1,47 |
#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/cubetext/trunk/logio.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/demos/cubetext/trunk/main.cpp |
---|
0,0 → 1,223 |
/* |
iadn |
http://www.iadn.narod.ru |
iadn@bk.ru |
*/ |
#include<menuet/os.h> |
#include <kosgl.h> //TinyGL |
#include <string.h> |
#include "SysCall.h" |
#include "ProcessTab.h" |
#include "bmp.h" |
int Fps (long x, long y); |
extern "C"{ |
void app_main(void); |
} |
struct { |
int x,y; |
int dx,dy; |
} win; |
#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; |
static GLuint* TexObj; |
float angle = 0.0; |
process_table_entry_* pri; |
KOSGLContext cgl; |
struct V3{ |
float v1; |
float v2; |
float v3; |
} ptrv[8] = {{-1.0,1.0,1.0}, |
{-1.0,-1.0,1.0}, |
{1.0,-1.0,1.0}, |
{1.0,1.0,1.0}, |
{-1.0,1.0,-1.0}, |
{-1.0,-1.0,-1.0}, |
{1.0,-1.0,-1.0}, |
{1.0,1.0,-1.0}}; |
struct T2{ |
float t1; |
float t2; |
} ptrt[4] = { |
{0.0, 0.0}, |
{1.0, 0.0}, |
{1.0, 1.0}, |
{0.0, 1.0} |
}; |
void DrawQUADS(V3* ptr, int iv1, int iv2, int iv3, int iv4, T2* ptrt, int it1, int it2, int it3, int it4) |
{ |
glBegin(GL_QUADS); |
glTexCoord2fv((float*)&ptrt[it1]); |
glVertex3fv((float*)&ptr[iv1]); |
glTexCoord2fv((float*)&ptrt[it2]); |
glVertex3fv((float*)&ptr[iv2]); |
glTexCoord2fv((float*)&ptrt[it3]); |
glVertex3fv((float*)&ptr[iv3]); |
glTexCoord2fv((float*)&ptrt[it4]); |
glVertex3fv((float*)&ptr[iv4]); |
glEnd(); |
} |
void DrawGL() |
{ |
glLoadIdentity(); // óñòàíàâëèâàåì åäåíè÷íóþ ìàòðèöó |
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
glTranslatef(0.0, 0.0, -6.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); |
DrawQUADS((V3*)&ptrv,0,1,2,3,(T2*)&ptrt,3,0,1,2); |
DrawQUADS((V3*)&ptrv,0,3,7,4,(T2*)&ptrt,1,2,3,0); |
DrawQUADS((V3*)&ptrv,4,7,6,5,(T2*)&ptrt,2,3,0,1); |
DrawQUADS((V3*)&ptrv,5,6,2,1,(T2*)&ptrt,3,0,1,2); |
DrawQUADS((V3*)&ptrv,7,3,2,6,(T2*)&ptrt,3,0,1,2); |
DrawQUADS((V3*)&ptrv,5,1,0,4,(T2*)&ptrt,3,0,1,2); |
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(50.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); |
int width, height; |
unsigned char* texture; |
LoadFileBMP( "./logio.bmp", &texture, &width, &height, false ); |
/* Setup texturing */ |
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); |
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); |
/* generate texture object IDs */ |
glGenTextures(1, TexObj); |
glBindTexture(GL_TEXTURE_2D, *TexObj); |
glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture); |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
glBindTexture(GL_TEXTURE_2D, *TexObj); |
glEnable(GL_TEXTURE_2D); |
pri=new process_table_entry_; |
SysCall(66,1,1); |
reshape(); |
do{ |
angle += 0.001 + 0.1*Fps (330,8); |
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/cubetext/trunk/readme.txt |
---|
0,0 → 1,0 |
Ëîãî KolibriOS - Lrz |
/programs/demos/cubetext/trunk/. |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |