Merge pull request #1 from DulcisL/SDL2_Init
Initial processes for SDL2 and window creation
This commit is contained in:
2 files changed
+46
-4
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O3 -Wall -Wextra -std=c11 -pthread
|
CFLAGS = -O3 -Wall -Wextra $(shell sdl2-config --cflags)
|
||||||
LDFLAGS = -lm
|
LDFLAGS = $(shell sdl2-config --libs)
|
||||||
TARGET = src/main
|
TARGET = src/main
|
||||||
SOURCES = src/main.c
|
SOURCES = src/main.c
|
||||||
|
|
||||||
|
|||||||
+44
-2
@@ -1,6 +1,48 @@
|
|||||||
|
#define SDL_MAIN_USE_CALLBACKS 1
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
void main(int argc, char *argv[]){
|
|
||||||
printf("Hello World!\n");
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
|
//Initialize Variables
|
||||||
|
const SDL_VideoInfo* info = NULL;
|
||||||
|
SDL_Surface *SCREEN;
|
||||||
|
int DX = 1920;
|
||||||
|
int DY = 1080;
|
||||||
|
int PixelDepth = 3;
|
||||||
|
int Flags = 0;
|
||||||
|
|
||||||
|
printf("Initializing SDL ... \n");
|
||||||
|
//error check if the video was initialized
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) == -1){
|
||||||
|
printf("Failed to initialize \n", SDL_GetError());
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
printf("SDL Initialized \n");
|
||||||
|
|
||||||
|
//Get SDL_OpenGl info and initialize
|
||||||
|
info =SDL_GetVideoInfo(SDL_GL_RED_SIZE, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
|
||||||
|
|
||||||
|
//Request initial window
|
||||||
|
Flags = SDL_OPENGL | SDL_FULLSCREEN;
|
||||||
|
|
||||||
|
//Set up the screen
|
||||||
|
SCREEN = SDL_SetVideoMode(DX, DY, PixelDepth, Flags);
|
||||||
|
//Check that screen was initialized
|
||||||
|
if (SCREEN == NULL) {
|
||||||
|
printf(stderr, "Screen could not be initialized \n", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Quit SDL Before program close
|
||||||
|
SDL_Quit();
|
||||||
|
printf("Program out\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user