-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
76 lines (50 loc) · 1.97 KB
/
main.cpp
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
#include <iostream>
#include <SDL2/SDL.h>
const int SCREEN_WIDTH = 800, SCREEN_HEIGHT = 600;
int main( int argc, char *argv[] ){
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;
SDL_Surface* screenSurface = NULL;
std::cout << "Rendering...";
if( SDL_Init ( SDL_INIT_EVERYTHING ) < 0 )
{
printf( "SDL could not initialized! SDL_Error: %s\n", SDL_GetError() );
}
else
{
window = SDL_CreateWindow( "Physics Engine 1.0", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if( window == NULL || renderer == NULL)
{
printf( "Window/renderer could not be created! SDL_ERROR: %s\n", SDL_GetError() );
}else
{
screenSurface = SDL_GetWindowSurface( window );
SDL_FillRect ( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0&0xFF, 0&0xFF, 0&0xFF ) );
SDL_UpdateWindowSurface( window );
SDL_RenderSetLogicalSize( renderer, 200, 200 );
SDL_Event e; bool quit = false;
while ( quit == false )
{
while( SDL_PollEvent( &e ) )
{
if( e.type == SDL_QUIT )
{
quit = true;
}
}
std::cout << "Rendering...";
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0 );
SDL_RenderClear( renderer );
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255 );
//SDL_RenderSetScale( renderer, 1.0, 1.0 );
SDL_RenderDrawPoint(renderer, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
SDL_RenderPresent( renderer );
}
}
}
SDL_DestroyWindow( window );
SDL_DestroyRenderer( renderer );
SDL_Quit();
return 0;
}