purrforce/main.c

92 lines
2.4 KiB
C

#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <SDL_image.h>
#include "api.h"
int app_is_live=0;
SDL_Window * purrwin;
void purrer(void) {
SDL_Init(SDL_INIT_TIMER|SDL_INIT_EVENTS|SDL_INIT_VIDEO);
purrwin = SDL_CreateWindow("PurrForce :3",
100, 100, 320,
360, SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP|SDL_WINDOW_SHOWN);
if(purrwin == NULL) {
puts(SDL_GetError());
} else {
SDL_DestroyWindow(purrwin);
}
SDL_Quit();
}
int main(int argc,char**argv){
app_is_live=1;
puts("hello world");
SDL_SetMainReady();
print_stats(ps_startup);
systray_initialscan();
//purrer();
while(app_is_live) {
unsigned ms_to_next_run = taskmgr_ms_till_next();
ms_sleep(ms_to_next_run);
taskmgr_run(0);
}
print_stats(ps_shutdown);
return 0;
}
/*
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* mascot_tex;
int zmain(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;
}
*/