-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraphics.c
65 lines (52 loc) · 1.41 KB
/
graphics.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
#include"graphics.h"
void initgraph(int *gdriver, int *gmode, char *pathtodriver){
window_h =500;
window_w =500;
if(SDL_Init(SDL_INIT_EVERYTHING)<0){
printf("Failed to Initialize Video\n");
}
window = SDL_CreateWindow("Shivain Window",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,window_h,window_w,SDL_WINDOW_RESIZABLE);
if(!window){
printf("Failed to create window");
}
renderer = SDL_CreateRenderer(window,-1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
}
void checkq(){
SDL_RenderPresent(renderer);
int isrunning =1;
SDL_Event event;
while(isrunning){
while(SDL_PollEvent(&event)){
if(event.type ==SDL_QUIT){
isrunning =0;
}
}
}
}
void closegraph(){
checkq();
SDL_Quit();
}
void delay(int _mseconds){
clock_t starting_time = clock();
printf("Adding Delay");
printf("%lu\n",starting_time);
printf("%lu",starting_time+1000);
while(clock() < starting_time+_mseconds*100);
}
void putpixel(int x,int y, int _color){
SDL_SetRenderDrawColor(renderer,255,255,255,255);
SDL_RenderDrawPoint(renderer,x,y);
}
int getmaxx(){
return window_h;
}
int getmaxy(){
return window_w;
}
int setcolor(int _color){
SDL_SetRenderDrawColor(renderer,255,255,255,255);
}
void line(int x1,int y1,int x2,int y2){
SDL_RenderDrawLine(renderer,x1,y1,x2,y2);
}