|
|
Home » Community » Newbie corner » How to configure for SDL2 project?
How to configure for SDL2 project? [message #57014] |
Fri, 14 May 2021 16:03  |
flim
Messages: 5 Registered: May 2021 Location: Hong Kong
|
Promising Member |
|
|
I have no problem in setting up SDL2 in Code::Block and VSCode, but have not idea how to setup SDL2 in TheIDE, any advise?
|
|
|
|
|
|
|
|
Re: How to configure for SDL2 project? [message #57027 is a reply to message #57026] |
Sun, 16 May 2021 13:36   |
 |
Klugier
Messages: 1099 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello Mirek,
Here is patch that fixed SDLPure.upt template. It works fine with SDK2 on POSIX. The library deduction was taken from Synth example.
Some absolute options was removed:
- double buffering - SDL2 do it by default
- fullscreen - up to the programmer whenever he wants to support it in application
- pure SDL template was removed due to lack of POSIX detection. We can not determine whenver this is true
#ifdef PLATFORM_POSIX
#include <SDL2/SDL.h>
#else
#include <SDL.h>
#endif
Klugier
-
Attachment: SDLCore.upt
(Size: 1.78KB, Downloaded 212 times)
U++ - one framework to rule them all.
[Updated on: Sun, 16 May 2021 13:58] Report message to a moderator
|
|
|
|
|
Re: How to configure for SDL2 project? [message #57062 is a reply to message #57027] |
Wed, 19 May 2021 06:01   |
flim
Messages: 5 Registered: May 2021 Location: Hong Kong
|
Promising Member |
|
|
I test the nightly build today, I create a new packagew with SDL in MyApp, the package build successfully.
But when I build this code, the linker failed. Any idea?
(): Linking has failed
(): lld-link: error: undefined symbol: SDL_main
(): >>> referenced by c:\projects\sdl\src\main\windows\sdl_windows_main.c:175
(): >>> SDL2main.lib(SDL_windows_main.obj):(main_getcmdline)
(): clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
#ifdef _WIN32
#include <SDL.h>
#else
#include <SDL2/SDL.h>
#endif
#include <stdbool.h>
#include <stdio.h>
bool is_running = false;
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;
bool initialize_window(void) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0 ) {
fprintf(stderr, "Error initializing SDL.\n");
return false;
}
// Create a SDL Window
window = SDL_CreateWindow(
NULL,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
800,
600,
SDL_WINDOW_BORDERLESS
);
if (!window) {
fprintf(stderr, "Error creating SDL window.\n");
return false;
}
// Create a SDL renderer
renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
fprintf(stderr, "Error creating SDL renderer.\n");
return false;
}
return true;
}
void setup(void) {
}
void process_input(void) {
SDL_Event event;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_QUIT:
is_running = false;
break;
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_ESCAPE)
is_running = false;
break;
}
}
void update(void) {
}
void render(void) {
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
int main(void) {
is_running = initialize_window();
setup();
while (is_running) {
process_input();
update();
render();
}
return 0;
}
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 28 18:00:41 CEST 2025
Total time taken to generate the page: 0.02299 seconds
|
|
|