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].

Simple DirectMedia Layer 2.0 (SDL2) is the second generation of a popular open source cross-platform library that provides a simple interface to graphics, sound, and input devices. The new version comes with lots of new features such as full 3D hardware acceleration and the less restrictive zlib license.

Resources:

2910 questions
0
votes
2 answers

Steam Input causes SEGFAULT whenever I call GetAnalogActionData

I'm making a game using SDL2, with controller support through Steamworks, and my program SEGFAULTs whenever GetAnalogActionData is called. I'm compiling with MinGW g++ through MSYS2, using Steamworks API version 157. I know I should store the…
addiment
  • 45
  • 6
0
votes
1 answer

Basic question about C, SDL2 and pointers

I am trying to learn SDL2 by using C. My problem is that I am trying to avoid creating a global SDL_Window by doing this: void init(SDL_Window *win){ SDL_Init(SDL_INIT_EVERETHING); win = SDL_CreateWindow("PONG", SDL_WINDOWPOS_UNDEFINED,…
evolhart
  • 1
  • 1
0
votes
1 answer

SDL2 library inclusion

VS Code keeps displaying an error: fatal error: SDL2/SDL_image.h: No such file or directory This is my code: #include #include const int WIDTH = 800, HEIGHT = 600; int main( int argc, char *argv[] ) { SDL_Init(…
MrRooby
  • 9
  • 1
0
votes
1 answer

How does the SDL_RenderCopy determine where to draw?

I need to render something based on the map. Now SDL_RenderCopy accepts negative value for it's co-ordinate. If I use SDL_RenderCopy with a dstrect={0,-16,32,32}, it would render the bottom half of the rectangle on the Top left of the window. In my…
0
votes
1 answer

SDL2 not showing contents of Window (C++)

I have the following code to create a window, fill it with red, and display it. This was mostly taken directly from some other answer on here, so should be perfectly fine. // test.cpp #include int main(int argc, char** argv) { …
Jo Mo
  • 155
  • 7
0
votes
1 answer

Game controller button number incompability between SDL2 and other tools (Windows' and online tools)

I'm trying to make a 1 to 1 mapping between physical game controller device and virtual device (vJoy). What I want to achieve is when button no X is pressed on physical device, make button no X pressed on virtual device. Since I'm trying to map 1-1…
Yunus Yurtturk
  • 509
  • 1
  • 8
  • 26
0
votes
0 answers

SDL2_image C# Couldn't open file.png

When trying to load a texture into the console, the output is: Couldn't open lettuce.png I tried to upload both jpg files and webp. Changed SDL flags. But nothing helped. There are no problems with initializing SDL enter image description here If…
OZYREO
  • 1
0
votes
1 answer

SDL_Vulkan_GetInstanceExtensions fails with "The specified window isn't a Vulkan window" on Linux

I am trying to init Vulkan on Linux. I do pass SDL_WINDOW_VULKAN flag to SDL_CreateWindow and call to SDL_Vulkan_GetInstanceExtensions fails with error "The specified window isn't a Vulkan window". I cannot find any specific info on what is the…
vocasle
  • 799
  • 8
  • 11
0
votes
0 answers

SDL 2 undefined reference to `Window::Window(std::__cxx11::basic_string, std::allocator >, int, int)'

//To note I just started learning SDL2 from 30th April so please be considerate of my lack of knowledge I made a header file called "window.h" as a class. And when I recall that window class in the main.cpp open a window with the input that i have…
Nathan
  • 1
  • 1
0
votes
1 answer

How To display the time passed in an SDL Window using SDL2_TTF Library?

I am programming a simple window-based game using SDL2 libraries in C++. With the help of the SDL2_ttf library, I have no trouble displaying static fonts to my SDL_Window like the name of the game. But I also want to display to the user how many…
0
votes
0 answers

How to prevent the disappearing of an object when it goes out the window in SDL2?

For a school project, we are asked to use the graphics module SDL2 and I'm trying to learn the basic concepts of it. I can add texts and images, create rectangles and move them, but ,because I have never written the condition to reappear from the…
0
votes
0 answers

rotating a sprite component with the mouse cursor

i am learning how to make a 2d game using sdl and c++ and am currently trying to rotate the sprite so that is always facing the cursor, my game is set up with an entity component system, i have a keyboardcontroller component where the game will use…
0
votes
1 answer

What Win32 drawing function does SDL2's software renderer use under the hood?

There are many GDI functions, such as SetPixel(), but it is very expensive to set each pixel to a certain color, so I wonder what function does the library use. Searched the SDL2 source code, didn't find the drawing function.
MY-97
  • 1
0
votes
0 answers

Pyo3 library using sdl2

I was gonna create a Pyo3 library which implements some RL environments. I had been using Pyo3 for other tasks. I was gonna use also SDL2 rendering, however it gives me an error. #[pyclass] pub struct FirstEnv { pos: f32, renderer:…
0
votes
1 answer

Re - LINK : fatal error LNK1561: entry point must be defined while compiling SDL2 project with VS2022 Buildtools

I am trying to compile this code - //main.cpp #include int main(int argc,char* argv[]) { if(SDL_Init(SDL_INIT_VIDEO)) { return 1; } SDL_Window* window=SDL_CreateWindow("Project…