This commit is contained in:
James 2024-03-20 16:25:29 +10:00
parent df21a95933
commit c2485979aa
3 changed files with 31 additions and 23 deletions

View File

@ -6,7 +6,7 @@
#include <Windows.h> #include <Windows.h>
static void showError(const char *er) { static void showError(const char *er) {
int ret = MessageBoxA(NULL,er,"Quit the program?",MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2|MB_APPLMODAL); int ret = MessageBoxA(NULL,er,"Quit the program?",MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2|MB_APPLMODAL);
if(ret = IDYES) { if(ret == IDYES) {
exit(1); exit(1);
} }
} }

22
main.c
View File

@ -6,15 +6,15 @@
SDL_Window* window; SDL_Window* window;
SDL_Renderer* renderer; SDL_Renderer* renderer;
SDL_Texture* lettuce_tex; SDL_Texture* mascot_tex;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
SDL_Surface* lettuce_sur; SDL_Surface* mascot_sur=NULL;
reportError("startup purrforce?"); reportError("startup purrforce?");
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
reportError("Error SDL2 Initialization : %s",SDL_GetError()); reportError("Error SDL2 Initialization : %s",SDL_GetError());
return 1; return 1;
} }
window = SDL_CreateWindow("First program", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL); window = SDL_CreateWindow("First program", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL);
if (window == NULL) { if (window == NULL) {
reportError("Error window creation"); reportError("Error window creation");
return 3; return 3;
@ -24,17 +24,17 @@ int main(int argc, char* argv[]) {
reportError("Error renderer creation"); reportError("Error renderer creation");
return 4; return 4;
} }
lettuce_sur = IMG_Load("lettuce.png"); //mascot_sur = IMG_Load("mascot.png");
if (lettuce_sur == NULL) { if (mascot_sur == NULL) {
reportError("Error loading image: %s",IMG_GetError()); reportError("Error loading image: %s",IMG_GetError());
return 5; return 5;
} }
lettuce_tex = SDL_CreateTextureFromSurface(renderer, lettuce_sur); mascot_tex = SDL_CreateTextureFromSurface(renderer, mascot_sur);
if (lettuce_tex == NULL) { if (mascot_tex == NULL) {
reportError("Error creating texture"); reportError("Error creating texture");
return 6; return 6;
} }
SDL_FreeSurface(lettuce_sur); SDL_FreeSurface(mascot_sur);
while (1) { while (1) {
SDL_Event e; SDL_Event e;
if (SDL_WaitEvent(&e)) { if (SDL_WaitEvent(&e)) {
@ -43,13 +43,13 @@ int main(int argc, char* argv[]) {
} }
} }
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, lettuce_tex, NULL, NULL); SDL_RenderCopy(renderer, mascot_tex, NULL, NULL);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
SDL_DestroyTexture(lettuce_tex); SDL_DestroyTexture(mascot_tex);
SDL_DestroyRenderer(renderer); SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window); SDL_DestroyWindow(window);
IMG_Quit(); // IMG_Quit();
SDL_Quit(); SDL_Quit();
return 0; return 0;
} }

View File

@ -1,11 +1,19 @@
copy /B /Y api.h D:\dev\db\purrforce\ set GITDIR=D:\dev\db\purrforce\
copy /B /Y error.c D:\dev\db\purrforce\ copy /B /Y api.h %GITDIR%
copy /B /Y ls.bat D:\dev\db\purrforce\ copy /B /Y error.c %GITDIR%
copy /B /Y main.c D:\dev\db\purrforce\ copy /B /Y ls.bat %GITDIR%
copy /B /Y make.bat D:\dev\db\purrforce\ copy /B /Y main.c %GITDIR%
copy /B /Y Makefile D:\dev\db\purrforce\ copy /B /Y make.bat %GITDIR%
copy /B /Y pull_fromgit.bat D:\dev\db\purrforce\ copy /B /Y Makefile %GITDIR%
copy /B /Y readme.md D:\dev\db\purrforce\ copy /B /Y pull_fromgit.bat %GITDIR%
copy /B /Y rm.bat D:\dev\db\purrforce\ copy /B /Y readme.md %GITDIR%
copy /B /Y sync2git.bat D:\dev\db\purrforce\ copy /B /Y rm.bat %GITDIR%
copy /B /Y touch.bat D:\dev\db\purrforce\ copy /B /Y sync2git.bat %GITDIR%
copy /B /Y touch.bat %GITDIR%
set RETFOL=%~dp0
cd %GITDIR%
git add -u
git add .
git commit -m ok
git push
cd %RETFOL%