57 lines
1.6 KiB
C
57 lines
1.6 KiB
C
#include <stdlib.h>
|
|
#include <SDL.h>
|
|
#include <SDL_image.h>
|
|
|
|
#include "api.h"
|
|
|
|
SDL_Window* window;
|
|
SDL_Renderer* renderer;
|
|
SDL_Texture* mascot_tex;
|
|
int main(int argc, char* argv[]) {
|
|
SDL_Surface* mascot_sur=NULL;
|
|
reportError("startup purrforce?");
|
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
|
reportError("Error SDL2 Initialization : %s",SDL_GetError());
|
|
return 1;
|
|
}
|
|
window = SDL_CreateWindow("First program", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL);
|
|
if (window == NULL) {
|
|
reportError("Error window creation");
|
|
return 3;
|
|
}
|
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
|
if (renderer == NULL) {
|
|
reportError("Error renderer creation");
|
|
return 4;
|
|
}
|
|
//mascot_sur = IMG_Load("mascot.png");
|
|
if (mascot_sur == NULL) {
|
|
reportError("Error loading image: %s",IMG_GetError());
|
|
return 5;
|
|
}
|
|
mascot_tex = SDL_CreateTextureFromSurface(renderer, mascot_sur);
|
|
if (mascot_tex == NULL) {
|
|
reportError("Error creating texture");
|
|
return 6;
|
|
}
|
|
SDL_FreeSurface(mascot_sur);
|
|
while (1) {
|
|
SDL_Event e;
|
|
if (SDL_WaitEvent(&e)) {
|
|
if (e.type == SDL_QUIT) {
|
|
break;
|
|
}
|
|
}
|
|
SDL_RenderClear(renderer);
|
|
SDL_RenderCopy(renderer, mascot_tex, NULL, NULL);
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
SDL_DestroyTexture(mascot_tex);
|
|
SDL_DestroyRenderer(renderer);
|
|
SDL_DestroyWindow(window);
|
|
// IMG_Quit();
|
|
SDL_Quit();
|
|
return 0;
|
|
}
|
|
|