-
Notifications
You must be signed in to change notification settings - Fork 1
/
video.c
139 lines (100 loc) · 3.01 KB
/
video.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
/*
*
* This is the main part of the application that is used to display the video stuff
*
*
* */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/wait.h>
#include <err.h>
#include <fcntl.h>
#include <mqueue.h>
#include <signal.h>
#include <string.h>
#include <SDL/SDL.h>
#include <stdbool.h>
//this stuff might not be needed
//~ #include "SDL/SDL_opengl.h"
//~ #include "SDL/SDL_ttf.h"
//not needed
//~ #define MQNAME "/CREAL_KEYBOARD"
//~ #define LOOPS 1000
//~ #define PRIO 10
//~ #define C_MAX_MSG 256 //this will be the max messages right here
//~ #define C_DEF_MODE 777 //this is for default shit right here with fds
int pid;
pid_t mainPid;
#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 720
#define SCREEN_BPP 32
#define MQNAME "/CREAL_VIDEO_0"
#define JOYQUEUE "/CREAL_JOY_0"
#define LOOPS 1000
#define PRIO 10
#define C_MAX_MSG 256 //this will be the max messages right here
#define C_DEF_MODE 777 //this is for default shit right here with fds
int pid;
pid_t mainPid;
bool mainGameLoopConditional;
//begin
int renderQuad = 1;
int main()
{
SDL_Surface *mainSurface = NULL;
SDL_Surface *screen = NULL;
mainGameLoopConditional = true; //this is for the main loop
//message queue stuff
mqd_t mq;
int status;
struct mq_attr attr,attrOld;
int i;
fd_set set;//crap
struct mq_attr mqa;
mode_t defaultMode = C_DEF_MODE; //this is supposed to be the default mode right here for the queue
//Analog joystick dead zone
const int JOYSTICK_DEAD_ZONE = 8000; //taken from lazy foo's website : http://lazyfoo.net/tutorials/SDL/19_gamepads_and_joysticks/index.php
mq_unlink(MQNAME); //remove the original message queue
attr.mq_flags = 0;
attr.mq_curmsgs = 0;
attr.mq_maxmsg = 1024;
attr.mq_msgsize = 2; //just using an integer here
mq = mq_open(MQNAME, O_CREAT|O_RDWR , 0644, &attr); //openning the bullshit
SDL_Init( SDL_INIT_EVERYTHING );
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
SDL_EnableUNICODE( SDL_TRUE ); //
SDL_WM_SetCaption( "CREAL", NULL ); //sets the caption of the window
mainSurface = SDL_LoadBMP( "70s.bmp" );
//~ hello = SDL_LoadBMP( "english.bmp" );
SDL_BlitSurface( mainSurface, NULL, screen, NULL );
//Update Screen
SDL_Flip( screen );
//Pause
SDL_Delay( 2000 );
//~ hello = SDL_LoadBMP( "english.bmp" );
SDL_BlitSurface( mainSurface, NULL, screen, NULL );
//Update Screen
SDL_Flip( screen );
//Pause
SDL_Delay( 2000 );
//~ hello = SDL_LoadBMP( "70s.bmp" );
//~ hello = SDL_LoadBMP( "english.bmp" );
SDL_BlitSurface( mainSurface, NULL, screen, NULL );
//Update Screen
SDL_Flip( screen );
//Pause
SDL_Delay( 2000 );
//~ hello = SDL_LoadBMP( "english.bmp" );
SDL_BlitSurface( mainSurface, NULL, screen, NULL );
//Update Screen
SDL_Flip( screen );
//Pause
SDL_Delay( 2000 );
SDL_FreeSurface( mainSurface );
//Quit SDL
SDL_Quit();
return 0;
}