Closed aescys closed 1 hour ago
You need to install (some of) SDL's dependencies: https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md
okay, I just installed the listed dependencies for ubuntu via their supplied command - sudo apt-get install build-essential git make \ pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \ libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev \ libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev \ libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \ libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
I'm still not getting a window output though. I'm following the guide here: https://www.youtube.com/watch?v=oaKfzpqSHB0 and I've copied the source code near exactly but where he gets a window I do not. Here is my source code:
`#include "../../SDL/include/SDL3/SDL.h"
using namespace std;
int main () {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
SDL_Log("SDL failed to initialize");
return -2;
}
SDL_Window *window = SDL_CreateWindow("main window", 1280, 720, 0);
//SDL_Renderer *render = SDL_CreateRenderer(window, "renderer");
bool running = true;
while(running) {
SDL_Event event;
if (SDL_PollEvent(&event) > 0) {
switch(event.type) {
case SDL_EVENT_QUIT:
running = false;
break;
}
}
SDL_Delay(1000);
}
/*
SDL_SetRenderDrawColor(render, 255, 0, 255, 255);
SDL_RenderClear(render);
SDL_RenderPresent(render);
SDL_Delay(1500);
*/
SDL_DestroyWindow(window);
//SDL_DestroyRenderer(render);
SDL_Quit();
return 0;
}`
I compile using the command: g++ main.cpp -lSDL3 -o main and run with ./main
It runs continuously indicating that the while loop is reached, but the window doesn't show up.
After installing the dependencies, you need to completely rebuild SDL3 (=remove everything from the build directory and configure + build again). The SDL3 binaries you just built do still not support x11 and/or wayland..
@madebr ahh i see, alright ill do that next then thanks. Yeah I'm still getting versed on binaries and compiling from source and such
Also, your test needs to show graphics and read all the events in a loop. I recommend looking at test/testspriteminimal.c for a simple standalone test program.
Alright! The code is now producing a window after a fresh install. I did have to change the above source code up though, as SDL_Init() now returns true for success and false for failure.
SOLVED - SDL is being built without a X11 or wayland video driver. X11 subcase
I'm fairly new to working with filesystems and things of that nature, but I'm trying to get SDL3 implemented so I can work on a new game I'm thinking up. I'm relatively familiar with the command line, but I don't know many of the commands to access hardware specifics and more backend info;
That all being said, sdl3 is installed, but when built it gave the message - "sdl is being built without a x11 or wayland video driver. -- the library will not be able to create windows on most unix environments" I flagged this and thought it was odd, but I didn't/don't know how to enable SDL to use x11, which is the windowing system my linux build is using (figured that out via the command "echo $XDG_SESSION_TYPE"). I saw a similar error here: https://github.com/libsdl-org/SDL/issues/7271, but it was concerned with wayland not x11.
So, how can i link x11 to be used in my SDL build? I'm willing to restart the SDL build from scratch if necessary.
Info on x11 version and such can be provided as requested, but ill need the relevant commands to be inputted to acquire the info.