-
Notifications
You must be signed in to change notification settings - Fork 62
/
osdtest.c
153 lines (119 loc) · 2.98 KB
/
osdtest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//Copyright (c) 2011 <>< Charles Lohr - Under the MIT/x11 or NewBSD License you choose.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "CNFG.h"
#include "os_generic.h"
unsigned frames = 0;
unsigned long iframeno = 0;
void HandleKey( int keycode, int bDown )
{
if( keycode == 65307 ) exit( 0 );
printf( "Key: %d -> %d\n", keycode, bDown );
}
void HandleButton( int x, int y, int button, int bDown )
{
printf( "Button: %d,%d (%d) -> %d\n", x, y, button, bDown );
}
void HandleMotion( int x, int y, int mask )
{
// printf( "Motion: %d,%d (%d)\n", x, y, mask );
}
int HandleDestroy()
{
printf( "Destroying\n" );
exit(10);
return 0;
}
short screenx, screeny;
int main()
{
int i, x, y;
double ThisTime;
double LastFPSTime = OGGetAbsoluteTime();
double LastFrameTime = OGGetAbsoluteTime();
double SecToWait;
int linesegs = 0;
CNFGBGColor = 0x800000;
//Deprecated CNFGDialogColor = 0x444444;
CNFGPrepareForTransparency();
CNFGSetupFullscreen( "Test Bench", 0 );
while(CNFGHandleInput())
{
int i, pos;
float f;
iframeno++;
RDPoint pto[3];
CNFGClearFrame();
CNFGColor( 0xFFFFFF );
CNFGGetDimensions( &screenx, &screeny );
// DrawFrame();
/*
pto[0].x = 100;
pto[0].y = 100;
pto[1].x = 200;
pto[1].y = 100;
pto[2].x = 100;
pto[2].y = 200;
CNFGTackPoly( &pto[0], 3 );
CNFGColor( 0xFF00FF );
*/
/* CNFGTackSegment( pto[0].x, pto[0].y, pto[1].x, pto[1].y );
CNFGTackSegment( pto[1].x, pto[1].y, pto[2].x, pto[2].y );
CNFGTackSegment( pto[2].x, pto[2].y, pto[0].x, pto[0].y );
*/
CNFGClearTransparencyLevel();
CNFGDrawToTransparencyMode(1);
CNFGTackRectangle( 0, 0, 260, 260 );
CNFGTackRectangle( 400, 400, 600, 600 );
CNFGPenX = 300;
CNFGPenY = 200;
CNFGSetLineWidth( 7 + sin(iframeno)*5 );
CNFGDrawText( "HELLO!", 5 );
CNFGDrawToTransparencyMode(0);
CNFGSetLineWidth( 1 );
CNFGDrawText( "HELLO!", 5 );
CNFGDrawBox( 0, 0, 260, 260 );
CNFGPenX = 10; CNFGPenY = 10;
pos = 0;
CNFGColor( 0xffffff );
for( i = 0; i < 1; i++ )
{
int c;
char tw[2] = { 0, 0 };
for( c = 0; c < 256; c++ )
{
tw[0] = c;
CNFGPenX = ( c % 16 ) * 16+5;
CNFGPenY = ( c / 16 ) * 16+5;
CNFGDrawText( tw, 2 );
}
}
CNFGPenX = 0;
CNFGPenY = 0;
RDPoint pp[3];
CNFGColor( 0x00FF00 );
pp[0].x = (short)(-200*sin((float)(iframeno)*.01) + 500);
pp[0].y = (short)(-200*cos((float)(iframeno)*.01) + 500);
pp[1].x = (short)(200*sin((float)(iframeno)*.01) + 500);
pp[1].y = (short)(00*cos((float)(iframeno)*.01) + 500);
pp[2].x = (short)(200*sin((float)(iframeno)*.01) + 500);
pp[2].y = (short)(200*cos((float)(iframeno)*.01) + 500);
CNFGTackPoly( pp, 3 );
frames++;
CNFGSwapBuffers();
ThisTime = OGGetAbsoluteTime();
if( ThisTime > LastFPSTime + 1 )
{
printf( "FPS: %d\n", frames );
frames = 0;
linesegs = 0;
LastFPSTime+=1;
}
SecToWait = .016 - ( ThisTime - LastFrameTime );
LastFrameTime += .016;
if( SecToWait > 0 )
OGUSleep( (int)( SecToWait * 1000000 ) );
}
return(0);
}