forked from fredbcode/cabrio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.c
93 lines (80 loc) · 2.75 KB
/
setup.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
#include <stdio.h>
#include "setup.h"
#include "config.h"
#include "event.h"
#include "font.h"
#include "sdl_ogl.h"
static const char *str_setup = "Setup";
static const char *str_instr1 = "Please follow the on-screen instructions";
static const char *str_instr2 = "in order to set up your installation";
static const char *str_press = "Please press the control for: ";
static struct texture *msg_setup = NULL;
static struct texture *msg_instr1 = NULL;
static struct texture *msg_instr2 = NULL;
static struct texture *msg_press = NULL;
int setup_draw_msg( struct texture *msg, GLfloat y, GLfloat scale ) {
ogl_load_alterego();
glTranslatef( 0, y, -6 );
glColor4f( 1.0, 1.0, 1.0, 1.0 );
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glBindTexture( GL_TEXTURE_2D, msg->id );
glBegin( GL_QUADS );
glTexCoord2f(0.0, 0.0); glVertex3f(-((msg->width*scale)/2), ((msg->height*scale)/2), 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-((msg->width*scale)/2), -((msg->height*scale)/2), 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f( ((msg->width*scale)/2), -((msg->height*scale)/2), 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f( ((msg->width*scale)/2), ((msg->height*scale)/2), 0.0);
glEnd();
return 0;
}
int setup( void ) {
struct texture *msg_event = NULL;
struct event event;
int i;
msg_setup = font_create_texture( str_setup );
if( msg_setup == NULL ) {
fprintf( stderr, "Error: Couldn't create message for string '%s'", str_setup );
return -1;
}
msg_instr1 = font_create_texture( str_instr1 );
if( msg_setup == NULL ) {
fprintf( stderr, "Error: Couldn't create message for string '%s'", str_instr1 );
return -1;
}
msg_instr2 = font_create_texture( str_instr2 );
if( msg_setup == NULL ) {
fprintf( stderr, "Error: Couldn't create message for string '%s'", str_instr2 );
return -1;
}
msg_press = font_create_texture( str_press );
if( msg_setup == NULL ) {
fprintf( stderr, "Error: Couldn't create message for string '%s'", str_press );
return -1;
}
ogl_clear();
sdl_swap();
event_flush();
SDL_Delay( 500 );
for( i = 1 ; i < NUM_EVENTS ; i++ ) {
msg_event = font_create_texture( event_name(i) );
ogl_clear();
setup_draw_msg( msg_setup, 1.0, 0.012 );
setup_draw_msg( msg_instr1, 0.2, 0.005 );
setup_draw_msg( msg_instr2, -0.1, 0.005 );
setup_draw_msg( msg_press, -0.5, 0.005 );
setup_draw_msg( msg_event, -0.8, 0.005 );
sdl_swap();
/* Clear out any unwanted events */
event_flush();
/* Catch out wanted event */
while( event_probe( 100, &event ) != 1 );
event_set( i, &event );
ogl_free_texture( msg_event );
}
ogl_free_texture( msg_setup );
ogl_free_texture( msg_instr1 );
ogl_free_texture( msg_instr2 );
ogl_free_texture( msg_press );
return 0;
}