Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » How to configure for SDL2 project?
How to configure for SDL2 project? [message #57014] Fri, 14 May 2021 16:03 Go to next message
flim is currently offline  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 #57015 is a reply to message #57014] Fri, 14 May 2021 16:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
What is your platform? In Win32 you do not have to configure anything, it comes with SDL2 libs. All you need to do is to choose SDL2 template when creating the project.
Re: How to configure for SDL2 project? [message #57021 is a reply to message #57015] Sat, 15 May 2021 12:50 Go to previous messageGo to next message
flim is currently offline  flim
Messages: 5
Registered: May 2021
Location: Hong Kong
Promising Member
Platform is Windows 10 64-bit

I add -lSDL2 in link options, but I got error:

(): Linking has failed
(): lld: error: unable to find library -lSDL2
(): clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
Re: How to configure for SDL2 project? [message #57022 is a reply to message #57021] Sat, 15 May 2021 13:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
I have just found that supplied templates for SDL2 projects are broken.

Anyway, what you really need to do is to put the library into Package organizer (project menu). Here is screenshot from the setup of my game:

index.php?t=getfile&id=6440&private=0

Re: How to configure for SDL2 project? [message #57024 is a reply to message #57022] Sat, 15 May 2021 14:42 Go to previous messageGo to next message
flim is currently offline  flim
Messages: 5
Registered: May 2021
Location: Hong Kong
Promising Member
I have different errors when I create a new package with SDL template

F:\upp\MyApps\test\test.cpp (5): error: use of undeclared identifier 'SDL_SetVideoMode'
F:\upp\MyApps\test\test.cpp (8): error: use of undeclared identifier 'printf'
F:\upp\MyApps\test\test.cpp (24): error: use of undeclared identifier 'SDL_HWSURFACE'
F:\upp\MyApps\test\test.cpp (24): error: use of undeclared identifier 'SDL_HWACCEL'
(): int videoflags = SDL_HWSURFACE | SDL_HWACCEL | SDL_DOUBLEBUF;
F:\upp\MyApps\test\test.cpp (24): error: use of undeclared identifier 'SDL_DOUBLEBUF'
F:\upp\MyApps\test\test.cpp (43): error: use of undeclared identifier 'SDL_FULLSCREEN'
F:\upp\MyApps\test\test.cpp (56): error: exponent has no digits


Re: How to configure for SDL2 project? [message #57026 is a reply to message #57024] Sat, 15 May 2021 20:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Did not I just said those templates are unfortunately broken?

Meanwhile, there is SDLSoundDemo example. I have just confirmed that it works out of box. Maybe you can use that as starting point for now?

Mirek
Re: How to configure for SDL2 project? [message #57027 is a reply to message #57026] Sun, 16 May 2021 13:36 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1077
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 161 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 #57028 is a reply to message #57027] Sun, 16 May 2021 13:42 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1077
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
And the new SDL template looks as follow:
index.php?t=getfile&id=6447&private=0


U++ - one framework to rule them all.

[Updated on: Sun, 16 May 2021 13:57]

Report message to a moderator

Re: How to configure for SDL2 project? [message #57029 is a reply to message #57028] Sun, 16 May 2021 14:04 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1077
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

In meanwhile Mirek applied his own fix, so mine is no longer needed. Anyway, flim you could check toomorows nighly build and try to create SDL project. Everything should works out of the box.

Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 16 May 2021 14:05]

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 Go to previous messageGo to next message
flim is currently offline  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;
}
Re: How to configure for SDL2 project? [message #57064 is a reply to message #57062] Wed, 19 May 2021 11:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
flim wrote on Wed, 19 May 2021 06:01
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)


int main(void) {


int main(int, char **)


I think that might be it.

Mirek
Re: How to configure for SDL2 project? [message #57065 is a reply to message #57064] Wed, 19 May 2021 14:13 Go to previous message
flim is currently offline  flim
Messages: 5
Registered: May 2021
Location: Hong Kong
Promising Member
After changed that line it works now. Thank you.
Previous Topic: my TCP client/server don't work correctly
Next Topic: Question about TcpSocket::Peek() / Get()
Goto Forum:
  


Current Time: Sat Jun 15 20:27:16 CEST 2024

Total time taken to generate the page: 0.02186 seconds