Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sdl2]

SDL2 (Simple DirectMedia Layer 2) is designed to provide platform independent access to various common multimedia devices. It is the new, current and updated version of SDL and recommended for new projects over legacy SDL1.2

0
votes
0answers
16 views

how to register update function in Lua from C game engine?

This is my first attempt to make a SDL2 based 2d game engine in C, i am planning using Lua as scripting language for gameplay purposes. First i learned how to call a C function from Lua: ...
1
vote
1answer
42 views

SDL2 mouse motion event keeps occuring

The code I'm using is like so: ...
-1
votes
0answers
54 views

Why does memory usage increase when using SDL2?

I recently started to explore SDL2, but i had some memory leak somewhere, so i decided to rewrite the program one step at a time and check for leak. I found that SDL_CreateWindow() - SDL_DestroyWindow(...
1
vote
1answer
55 views

How does SDL2 renderer work? Does it make sense to render to only part of a window?

In order to run a game without using the CPU/GPU too much, I want to only update the section of the window that has changed. Does this goal even make sense? How does the texture objects/renderer work ...
0
votes
2answers
153 views

MacOS Mojave makes SDL2 unaccessible

I have some code that worked with no issues on MacOS Sierra, but when I update to Mojave, my compiler always says that it can't find SDL2. Here's the error: ...
0
votes
0answers
49 views

How to correctly implement the ray intersections with blocks as in minecraft with lossless performance?

I am doing minecraft like game. We need an algorithm to find the intersection of the beam emanating from the camera with the block that first intersects and select the distance at which to check as a ...
0
votes
1answer
65 views

Should I call SDL_ConvertSurface right before SDL_CreateTextureFromSurface?

Is there a significant benefit (or any benefit at all), when I convert SDL surface and create a texture from optimized surface? Here is example of what I mean: ...
1
vote
2answers
60 views

Is it possible to make desktop visible behind drawn object using SDL2?

I would like to draw an avatar over the desktop, something similar to those word 97 assistants, my idea so far is to make only the background transparent but I haven't had any luck, any suggestion? is ...
0
votes
1answer
70 views

Why doesn't SDL2 recognize a game controller button press?

SDL2 recognizes my PS4 controller but not the button presses. Here is a minimal code example. ...
1
vote
1answer
73 views

How to implement a camera for a TiledMap with SDL2 and Box2d?

I m writing a game engine using mainly SDL2 and box2D, I implemented TiledMap class that loads a tmx map and everything is fine it even support animation and objects that later will generate Box2D ...
0
votes
2answers
63 views

Removing a pair from array of pairs

Im making a Breakout clone game and im stuck with deleting objects after they are hit. There are 3 rows. Each contains 12 blocks. I'm trying to delete a pair in the array of pairs. The array contains ...
0
votes
0answers
31 views

Is there a way to get SDL to handle more than four gamepads?

My end goal is to have 8 controllers in SDL. I have four Xbox360 controllers and four third party PS3 controllers (with a switch between XInput DirectInput on the back) Windows 10 recognizes the ...
0
votes
1answer
50 views

Transforming 2D viewport coordinates after scaling the viewport (zoom in/out)

I've been getting started with personal experimentation and have been working on a project for a few days now using SDL2. It is a 2D game, and at this stage I have it rendering game objects in a fixed-...
1
vote
1answer
208 views

How can I avoid jittery motion in SDL2?

I am experiencing stutter when I am moving faster than 0.1 units in my program. When doing exactly 0.1 units I get: For test purposes I've made the bot always heading southeast. ...
1
vote
1answer
224 views

How do I check if a window has focus in SDL2?

Is there a replacement for SDL_GetAppState function in SDL2 from older SDL versions? Why was it removed? I want to use it so I can check if the user has focused the ...
0
votes
2answers
71 views

SDL2 only renders a single image

As an attempt to learn SDL on C, I decided to try and create a simple Pong program using it. My problem now is that of the textures I've given it, two paddles and a ball, only the ball is rendered. It ...
0
votes
1answer
144 views

SDL2 reporting 24-bit pixel format on a 32-bit desktop setup

I'm trying to figure out why calling SDL_GetWindowPixelFormat is returning SDL_PIXELFORMAT_RGB888, even though I'm creating the window with the flag "SDL_WINDOW_FULLSCREEN_DESKTOP", and my desktop ...
1
vote
1answer
81 views

Game not responding on different computer with Intel graphics

I have a game that uses SDL2 and OpenGL 3.3 with Visual Studio. It runs fine on the computer that built it, but it did not work on other Windows computers. Initially, it would complain about missing ...
0
votes
0answers
47 views

How to insert the SDL2 library into visual studio for C but not C++

I am a student and want to make an RPG game using visual studio by C programming as my project, so I need to insert some png photo into the game as the background. But I was frustrated to discover no ...
1
vote
1answer
102 views

Why am I getting the error “SDL_Event has not been declared”?

I don't understand what I'm doing wrong. In my game.cpp, I have this: ...
0
votes
0answers
21 views

SetColorMod() with mini delay when the texture is rendered for the first time

I have one image.png that I load using SDL_IMG. I load by creating a surface. Then I create a texture using CreateTextureFromSurface() and I free the original surface. I repeat the same process but ...
0
votes
1answer
559 views

How to get access to framebuffer as a uint32_t * in SDL2?

I am making my first foray into SDL. To do this, I would like to have direct access to the framebuffer on the window as a uint32_t *. This is because I have to pass ...
2
votes
1answer
335 views

Why does SDL2 blur pixel art even with SDL_HINT_RENDER_SCALE_QUALITY set to 0?

I am working on a game with SDL2 and having trouble turning off linear filtering when upscaling textures. My game has a bunch of 32x32 tiles. I used ...
1
vote
1answer
154 views

How to implement circle clipping in SDL2?

In SDL2 there's a function to set a rectangular clip mask: int SDL_RenderSetClipRect(SDL_Renderer* Renderer, SDL_Rect* clip); If i call this function, copied ...
2
votes
2answers
534 views

SDL_image entry point SDL_acosf not found in SDL2_image.dll

I tried using SDL2_image (2.0.3) with SDL2 (2.0.7) to load png files, but when I start the application I get ...
0
votes
1answer
249 views

How to draw geometric shapes to a texture?

How can I create a texture containing a geometric figure using SDL2? I saw there is a way to convert Surface to Texture, and I also saw that there is a way to draw directly to the screen using ...
-1
votes
1answer
169 views

Is my frame rate being calculated correctly?

I'm having a long headache (which may not be that complicated) with this frame rate thing. I already tested several frame rate algorithms, lastly I tested this here and they all gave something strange ...
1
vote
2answers
87 views

How to tell whether the joystick axis is released (not pushed) in SDL2 or in general?

I'd like to implement an event listener that triggers character movement (left/right/up/down or stay) according to the direction of pushed axis on the joystick. Due to jittering, the approach I found ...
0
votes
1answer
122 views

SDL Sprite Customization

I am currently working in C++ with SDL2. I plan on making a game that utilizes character visual customization. More specifically, equipping clothes and items changes the appearance of characters. ...
0
votes
0answers
118 views

Loading png image on SDL2, Png file size is shrinked to 1/4 of its original size

I'm currently trying to draw a cube with a texture from SDL2. Above is the png file that I want to draw per side of my cube. And below is the result of my drawing. This is how I calculated it <...
0
votes
1answer
202 views

How can I read an image from a binary file?

I'm trying to put all the assets inside a binary file and then trying to read them from the file itself, without scattering all them around in separate folders to let them exposed. What I'm trying to ...
0
votes
1answer
57 views

Why isn't SDL displaying my texture?

I am self teaching SDL game programming from SDL Game Development Black and White textbook. I stopped at the second chapter, where I have to display .bmp picture on screen. Given code: ...
2
votes
1answer
867 views

How to properly manage memory in SDL2?

I have yet another question regarding SDL2. I have some drawSprite & drawBackround & ...
1
vote
1answer
257 views

How to use SDL_RWops and SDL_RWseek to read text files, line by line?

I'm right now looking for alternative ways to read text files on a line-by-line basis, for cross-platform compatibility (Windows / Linux). My current solution is to go look for (or seek out) the ...
1
vote
1answer
605 views

libpng warning: iCCP: known incorrect sRGB profile

I was working with SDL2 and when I loaded some textures, I got this warning in the console libpng warning: iCCP: known incorrect sRGB profile Though this doesn't cause any error, everything works ...
2
votes
1answer
149 views

How to handle Japanese on Windows and Linux using SDL_ttf and C++?

In SDL_ttf, there are a few functions provided that handles non-ASCII string literals, such as: TTF_RenderUNICODE_Solid ...
2
votes
1answer
278 views

Good ways to implement cutscenes in 2d RPG

I want to know of some different ways to implement cutscenes in a 2D RPG game with SDL2 and C++. My current idea is creating different functions in different files for different cutscenes and running ...
-1
votes
1answer
47 views

Declare a struct in a function [closed]

I am creating a game that sometimes crashes and i am asking if this could be the cause. Take this code: ...
2
votes
1answer
822 views

Handling variable frame rate in SDL2

i am creating a game with C++ and SDL2 game engine but i noticed this. I used the Vsync option for rendering, so it'll render at 60fps. If i use this game with another monitor, fps are different (for ...
2
votes
1answer
133 views

How to position objects responsively in SDL?

I have an SDL window using SDL_WINDOW_FULLSCREEN_DESKTOP (as opposed to SDL_WINDOW_FULLSCREEN, which doesn't work properly) When I try to place stuff on the screen, it is placed in the wrong location ...
0
votes
2answers
53 views

SDL_TTF Manual Line Ending

With SDL TTF I've already gotten automatic line wrapping down using the built in "wrapped" function. However, now I want to do what I guess you could call manual line wrapping. Basically, at certain ...
1
vote
2answers
2k views

SDL2 GUI (same window)

I have a problem: I working on a simple game and want to use some GUI (think of simple input for player name, etc). I've googled a lot of GUIs that can be used with SDL, but: Most of them are using ...
1
vote
1answer
668 views

Setting Window Icon SDL2

I've been playing around with SDL2 and have made a very nifty little program! Now, I'm trying to set my window icon - for the SDL Window. I have the following code in the main function of my program, ...
1
vote
1answer
78 views

Zooming in so a smaller portion of the game scene fills the entire screen

so i am creating a game similar to super-smash-bros, in which the camera should zoom in on players when they are close together, and scale back when they are apart. I create a window for my game via <...
0
votes
0answers
97 views
1
vote
0answers
115 views

How do I detect collision between an ellipse and a rhombus?

I'm building a game in C/C++ (been alternating between the two), but one of the biggest problems I've run into is collision detection. The game is isometric and exists on a 2x1 grid (e.g. the base ...
-1
votes
1answer
426 views

Save game feature in SDL 2?

I am making a 2D action-adventure platformer video game using the C++ computer programming language and the Simple DirectMedia Layer 2.0 (SDL 2.0.5) development library. So far I have created over ...
1
vote
1answer
219 views

SDL 2.0 OpenGL not drawing anything except background

My 'hello triangle' compiles well, no errors, but doesn't drawing anything. Here's my code: main.cpp ...
2
votes
1answer
98 views

C++11 & Efficient Networking Client<->Server<->“Zone(s)”

I am building both an engine and a networked game at once because I'm completely insane. The original design/plan was to use internal Unix sockets for each "zone" for server<->zone communication, ...
0
votes
1answer
2k views

C++ and TinyXML2 Error: **this** was nullptr

I'm trying to make a video game using Microsoft Visual Studio Community 2017 and Simple DirectMedia Layer 2 (SDL 2.0.5, and SDL image loading file version 2.0.3). A map editor called 'Tiled!' was ...