Questions tagged [sdl-2]

For questions and issues regarding Simple DirectMedia Layer 2 (SDL2). If you're using SDL 1.2, use tag [sdl-1.2]. If you're questioning the library in general, use tag [sdl].

Filter by
Sorted by
Tagged with
-1 votes
0 answers
27 views

Linker cannot find SDL2_image?

When I add to my project SDL2_Image I get this: ld.exe: cannot find -lSDL2_image My makefile: all: g++ -L"src/SDL2lib" -I"src" -I"headers" -o Main.exe main.cpp -...
Pyjava's user avatar
  • 32
0 votes
1 answer
37 views

Multi-textured floor rendering in 2D raycaster

In this wonderful lodev's raycasting tutorial (https://lodev.org/cgtutor/raycasting2.html), we have a part about floor and ceiling. I bet my problem is simple, but I can't help myself. Using the ...
OrionExp's user avatar
0 votes
0 answers
55 views

Why is SDL2 only presenting the last screen?

I would like to show a rectangle moving across the screen, but only the last screen is rendered. (I don't mind a visual trail, so previous rectangles do not have to be deleted.) Each call to ...
flobacca's user avatar
  • 958
-1 votes
0 answers
31 views

SDL2 Creating weird stretched rectangle over regular window when rendering textures [closed]

Below is code from Lazy Foo' Productions SDL2 tutorial series. I copied it directly to test if this was a problem with my code or if it was something else. This code and my own, which should work as ...
Oliver Green's user avatar
-1 votes
1 answer
53 views

C++ threads cause issues on SDL2 rendering (since Ubuntu 23.10)

I noticed that my SDLD2/C++ application doesn't work properly or I changed nothing. So I tried to execute it on a Ubuntu 22.04 VM and it worked. After few tests, I noticed that if I take out my ...
ISEVEN's user avatar
  • 31
-4 votes
0 answers
30 views

How do i connect the game to the state manager and make it all work? [closed]

I am making a game. I'm currently in the process of making the various states of the game, like the main menu, and such. i currently have it set up like a singleton and i also have a state manager: // ...
user23033721's user avatar
-1 votes
0 answers
56 views

SDL2 crashes midway through rendering fractal

I'm working on a program using SDL2 and C++. It seems to render correctly however midway through rendering, it seems to crash immediately. And the points at which it crashes seem random. #include <...
sambouza's user avatar
1 vote
0 answers
12 views

Check if key is just pressed using sdl.GetKeyboardState() in sdl2-go binding

I'm trying to create an isKeyJustPressed() function in go using the sdl2-go binding. I'm doing this by checking if the previous keyboard state is unpressed, and the current one is I.E. ...
Debuholden's user avatar
-2 votes
0 answers
58 views

Sdl2 Initialization error: “Failed to connect to Mir Server” [closed]

I recently attempted to create a window using SDL2 on my ubuntu but after i compile and run, i get this error during initialization “Failed to connect to the Mir Server” The ubuntu version is 16.04 ...
Luka108's user avatar
-1 votes
0 answers
44 views

Include SDL2 in the project

I have an assignment to write a game in C++. One of the criteria is that it needs to compline and run on the schools computers. Those systems have OpenGL and GLUT installed. I want to use SDL2 instead....
Demir Ince's user avatar
-1 votes
0 answers
30 views

SDL2: Why is the input not working as expected?

So I made this player movement function but for some reason when I press the following combos: left, right, down; left, down, right; right, down left; It's not working as expected. all the combos are ...
Lawrencium's user avatar
-2 votes
0 answers
30 views

Error after adding commands from sdl2 image library

Here's my code #include "Game.h" SDL_Texture* playerTex; Game::Game() {} Game::~Game() {} void Game::init(const char* title, int xpos, int ypos, int width, int height, bool ...
AnthraxFlavouredWax's user avatar
-1 votes
0 answers
54 views

Set up SDL2 libraries for Visual Studio Code?

I am unable to set SDL up (in ANY IDE). Firstly I tried using Code::Blocks since it seemed easier to use (link libraries and compilers and the other stuff I have no idea about). Apparently it didn't &...
saimiftikhar's user avatar
-2 votes
0 answers
54 views

SDL2/SDL.h: No such file or directory gcc my compiler can't find the SDL2 folder and the SDL.h file

SO i wanted to try C++ and SDL2 im actually learning some stuff and i wanted to start creating a game with SDL2 i followed a tuto to install everything, everything seemed fine until the error showed ...
Fibyy's user avatar
  • 1
-1 votes
0 answers
34 views

Unable to set transparency on SDL_Surface

I wrote a simple program using SDL2 with the intention to populate a SDL_Surface pixel by pixel from a 2 dimensional unsigned int array of RGBA values. Header File Sample unsigned int pman[64][64] = {{...
Kevin Mok's user avatar
1 vote
0 answers
28 views

SDL - BlitSurface copies whole source surface onto the whole destination surface even though I specify a destination rectangle

I am trying to understand why SDL_BlitSurface copies the whole source surface onto the destination surface even though I have a destination rectangle smaller than screen width and height. The problem ...
Cristian Cutitei's user avatar
0 votes
0 answers
12 views

SDL2: Is there a way to just extend the default Menu function already implemented in SDL2

Rather than starting from scratch and implementing a new menu treatment, Is there a simple way to just extend the existing menu bar provided in SDL2. On MacOS X I see "Apple, AppName, and Window&...
softeky's user avatar
-2 votes
0 answers
65 views

How to mix sounds

In SDL2, is it possible to mix sound without utilizing SDL2_mixer? I'm currently using SDL_QueueAudio, and I know about SDL_MixAudio. However, it seems that SDL_MixAudio only works with callbacks, ...
Rodrigo's user avatar
  • 43
1 vote
0 answers
46 views

SDL2: Calling cout after Clicking console window causes Freeze

Using SDL2. If I test run in Visual Studio (with Subsystem:Console, so the console will show too) then click the console window, then click back into the SDL window, and call a cout within the ...
user1675016's user avatar
-3 votes
2 answers
322 views

PNG-file with wrong colors because of SDL_RenderReadPixels! Or: Which SDL_PixelFormat does this function return?

In my TexturWrapper class I need a method to save the main-texture or a part of it to a PNG-file. IMG_SavePNG is just able to save a SDL_Surface to a file, not a SDL_Texture. The main-texture of my ...
Brainfog's user avatar
0 votes
0 answers
29 views

How do I manage and present a surface in SDL2's rust bindings?

I'm trying to write a program that works as a whiteboard. However, as I keep drawing, the program has to keep track of more and more points, which slows down the program and causes it to lag. I want ...
Manuel's user avatar
  • 1
0 votes
0 answers
29 views

Small CLion project with C++ and SDL2 crashing with exit code 468

So I've been poking around CLion lately and wanted to set up an example project since I do game dev in my free time, but once I managed to have the CMake file work with SDL2, I ended up hitting the ...
fortwoone's user avatar
1 vote
1 answer
84 views

ImGui, with SDL2 Renderer, what is the point of the three separate NewFrame functions?

I'm trying to set up ImGui with the SDL2 backend and software renderer. In the provided example (./examples/example_sdl2_sdlrenderer2/main.cpp) there are these three calls at the beginning of every ...
Сергей Макеев's user avatar
0 votes
0 answers
47 views

How to create window(CreateWindowEx) which support transparency and hosted by WPF window?

I'm trying to create window which support transparency, and put it in WPF window in .net4.5 I decide use : HwndHost, so I extend HwndHost class and override the BuildWindowCore method in it: protected ...
qakmak's user avatar
  • 1,317
0 votes
1 answer
72 views

I want to zoom in an image in C SDL

I need to take an image m * m and return an image n * n. I have this code: void Zoom_Filter(SDL_Surface* surface) int newsize = 28; Uint32* pixels = surface -> pixels; Uint32* pixels2 = malloc(...
Iupyou's user avatar
  • 37
0 votes
1 answer
43 views

No background in SDL window after first launch

I have a simple program in C using SDL2: #include <stdio.h> #include <SDL2/SDL.h> int main(int argc, char** argv) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { return 1; } ...
lem0nify's user avatar
  • 694
0 votes
1 answer
18 views

How do I copy the data buffer from SDL_LoadWAV to SDL_AudioCVT?

This function should load a wav and convert it to the desired format. My issue is that I can't figure out how to copy the data to the cvt properly. What I'm gathering from the docs is that the audio ...
Jake A's user avatar
  • 85
1 vote
1 answer
48 views

Why is there a double Image when using SDL2?

I have a Mandelbrot set rendering code in c++and I'm using SDL2 to display the image. When I wanted to make my program interactive I reached a problem. By pressing W my code should clear the previous ...
Parsa Eslami's user avatar
1 vote
1 answer
262 views

How do I override the malicious software check for the SDL2 framework on mac?

I have installed the official release of SDL2 from the releases section of the repo. Despite having followed the instructions in the README.txt and installing it into /Library/Frameworks, I get the ...
biscuit's user avatar
  • 115
0 votes
0 answers
51 views

Is there a proper way to create a class that has only one instance and gets used in *almost* every file? [duplicate]

I am creating a game with SDL2, and want to create a display class that contains data about the display that can be used by almost every file for example; I have a class x and class y whose functions ...
Pybyte's user avatar
  • 1
-1 votes
1 answer
76 views

Issue with installing SDL2 using CLion and vcpkg [closed]

====================[ Build | main | Debug ]==================================== C:\Users\Amund\AppData\Local\Programs\CLion\bin\cmake\win\x64\bin\cmake.exe --build C:\Users\Amund\Desktop\main\cmake-...
HacksReported's user avatar
-1 votes
1 answer
178 views

Having a problem with SDL2 and CMake Setup

I am using C++, SDL2 and CMake to create a game (in Visual Studio Code). Sadly I am getting an error, that SDL2 can't be found. I tried multiple ways to do it. My current solution is that I have an ...
Arktikus's user avatar
-1 votes
1 answer
81 views

SDL2 not copying textures to renderer

I've been using SDL2 to make a simple game for a few months. I recently tried to add lighting, but when I try and render the lights or any other layers, the screen is just black. I've tried the same ...
Joeger-Bahar's user avatar
1 vote
0 answers
27 views

Why does QT program crash upon SDL startup (C4Droid)

I'm trying to wrap an SDL2 game I wrote within a QT app, for GUI controls; I'm following an example from GitHub, however it crashes. I've reduced it to find that SDL_Init causes this. Since I'm unable ...
K. Russell Smith's user avatar
0 votes
0 answers
69 views

Can't Compile SDL2 For 32-Bit on 64-Bit Ubuntu Using Arm GNU Toolchain

Background I am trying to cross compile SDL2 using the Arm GNU Toolchain. My host is Ubuntu 22.04.3 LTS running on WSL and my target is a 32-bit Cortex-A7. I have successfully compiled and ran "...
SocialTaco's user avatar
0 votes
0 answers
50 views

Setting up VS Code for Android SDL2 Development

I'm working on deploying SDL2 apps to android, but I'm having trouble getting intellisense working on VS Code, with Microsoft's C/C++ extension pack (which provides C/C++ support, themes, and CMake ...
Unsatisfied Zebra's user avatar
0 votes
2 answers
86 views

case switch alternative for a varying number of items

I want to case switch a varying number of items (a vector), but this method requires constants. I am using SDL2 to read all the inputs, and the method I am using requires a case switch. I need to get ...
Ryan C's user avatar
  • 3
0 votes
1 answer
66 views

Why did my CMake project break after upgrading macOS?

Upgrading to Ventura 13.6 from, I think, 13.5 changed something about how CMake works on my Macbook. I am curious about what changed. Before I had the following setup: a file CMakeLists.txt with ...
Angelos's user avatar
  • 185
1 vote
2 answers
101 views

How do I know which DLLs I need to include to properly build a project on windows using cmake and mingw?

I have a small C++17 program I wrote using a few SDL2 libraries. I created the project using Cmake, ninja, MSYS2, and MinGW. The exe I generate executes as expected when launching through a MSYS/mingw ...
Dan's user avatar
  • 13
0 votes
0 answers
29 views

C++ SDL_ttf cannot find freetype262.dll

i am trying to make a project in SDL2 C++ and use SDL_ttf.h, to draw text, but when i run it (i am only using TTF_Init() here, nothing else) i get the error "could not find "freetype262.dll&...
Substandard tyrant's user avatar
-1 votes
3 answers
63 views

Accessing array in if statement significantly decreases performance

So I am trying to implement a rendering function for my array of squares. Array represents output of raycasted hitbox of explosion: For drawing I am using SDL2 library, but drawing one rect at a time ...
Mirin's user avatar
  • 1
0 votes
0 answers
32 views

SDL2 MessageBox button size

So Im trying to show a messagebox in C++/SDL2 and im doing great but for some reason the buttons are way to small (see screenshot), here is my code: std::string message = "test"; ...
pogrammerX's user avatar
0 votes
1 answer
48 views

Move rectangle in response to keypress?

Is there any way to make the if statement that checks if the 'd' key is pressed to work? #include <iostream> #include <SDL.h> #include <conio.h> using namespace std; void player(...
user22574597's user avatar
0 votes
0 answers
31 views

Audio stops after multiple times of pressing the button SDL C++

I have a problem when i press the button to play the sound clip/fx after couple of tries it just stops playing the sound. I am using SDL for this app bellow is the class sound.h with the sound.cpp ...
Sollekram dakap's user avatar
0 votes
0 answers
47 views

How to fix interop errors in Go?

I'm trying to install SDL2 mapping for Go (https://github.com/veandco/go-sdl2). However, when I build the application, the following error happened : # github.com/veandco/go-sdl2/sdl In file included ...
Jersey591's user avatar
0 votes
1 answer
264 views

SDL2 not showing window in wsl2

I'm using wsl2 Debian. After contemplating my life to install 245 MB of libsdl2-dev apt install, I tried g++ sdl.cpp -lSDL2 -o sdlbasic and I got this huge string of text, all seems to be one combined ...
Eja's user avatar
  • 11
0 votes
0 answers
14 views

Macports, variants, excessive dependencies

I have written a little graphics library for my students and C++. Since Apple has removed the Carbon interface, I am trying to revive its Mac implementation using SDL. So far so good, until I wanted ...
Joymaker's user avatar
  • 943
-4 votes
1 answer
126 views

On Linux, using cmake, SDL, and SDL_Image, I keep getting an undefined referance error to IMG_Load() and I'm not sure why. Can someone help me please? [duplicate]

I'm working on making a C++ project for fun. However I'm stumped by this error. My cmake file builds fine but trying to run things gives me the error: undefined reference to IMG_Load'`. I'm on Arch ...
FatalErrorDriveB's user avatar
0 votes
0 answers
25 views

winmain problem but I both saved and have the files [duplicate]

#include "SDL/include/SDL.h" #include <stdio.h> SDL_Window* window = nullptr; SDL_Surface* sceenSurface = nullptr; SDL_Surface* imgSurface = nullptr; bool init(){ bool flag = ...
Tonestones's user avatar
0 votes
0 answers
45 views

I am making a 3D Engine but even with the correct matrixes but it breaks when rotating

So, I have make a 3d engine and I am trying to make the camera orbit around the player (in this case a cube), I have code for orbiting, 3D Projection, etc. but even with the correct matrixes the ...
user avatar

1
2 3 4 5
59