EditorSDL
This commit is contained in:
62
editor/main.cpp
Normal file
62
editor/main.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
// #define SDL_MAIN_HANDLED
|
||||
#include "SDL3/SDL_rect.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include "SDL3/SDL_render.h"
|
||||
#include "button.h"
|
||||
|
||||
/*Use This Command to Run:
|
||||
|
||||
g++ main.cpp button.cpp -o main.exe -I"./SDL3-3.3.6/x86_64-w64-mingw32/include" -L"./SDL3-3.3.6/x86_64-w64-mingw32/lib" -lSDL3
|
||||
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
if(SDL_Init(SDL_INIT_VIDEO) == 0){
|
||||
printf("SDL_Init error: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
SDL_Log("Windows Initialized");
|
||||
|
||||
SDL_Window* window = SDL_CreateWindow(
|
||||
"My Window",
|
||||
800, 600,
|
||||
SDL_WINDOW_RESIZABLE
|
||||
);
|
||||
|
||||
if(!window){
|
||||
printf("SDL_CreateWindow Error: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Button
|
||||
Button mybutton(220, 190, 200, 100);
|
||||
// Render
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
|
||||
int running = 1;
|
||||
while(running){
|
||||
SDL_Event e;
|
||||
while(SDL_PollEvent(&e)){
|
||||
if(e.type == SDL_EVENT_QUIT){
|
||||
running = 0;
|
||||
}
|
||||
mybutton.handleEvent(e);
|
||||
if (mybutton.isClicked()) {
|
||||
SDL_Log("Button Was Clicked!");
|
||||
}
|
||||
}
|
||||
SDL_SetRenderDrawColor(renderer, 30, 30, 30, 255); // Background
|
||||
SDL_RenderClear(renderer);
|
||||
mybutton.render(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_Delay(16);
|
||||
}
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user