Stack Exchange Network

Stack Exchange network consists of 175 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

1
vote
1answer
30 views

2D Circular Distribution Overlap

I'm working with the C# wrapper for SDL and am stumped at how to handle this issue. Right now I have a simple Actor that spawns N number of bullets from himself and fires them circularly outward. The ...
0
votes
0answers
23 views

SDL_WarpMouseGlobal does not work in game

I tried to use SDL to move mouse in game. The function works fine only in menu, when I join a game, the function does not work. I checked coordinates with ...
3
votes
1answer
71 views

SDL render surface from byte array efficiently

In my current project I need to fill a 256x224 screen with the pixel values from an array. The array is declared this way: uint8_t *vram = new uint8_t[7168]; So ...
0
votes
0answers
24 views

Problem with resizing SDL2 Window in C#

how do I resize SDL2 Window correctly? ...
1
vote
1answer
624 views

Why can't this simple SDL app be closed without task manager or rapid clicking of x button?

I wrote a simple app that generates a window, a raster, and redraws the raster once every 16ms. Right now the calculations are empty, it just draws a solid color. I don't know how, but I have created ...
0
votes
0answers
32 views

SDL2-CS and Gtk Sharp like SDL2-CS and WinForms in C#

who knows SDL2-CS embeds in Gtk Sharp 2/3? Similar example by Ethan Lee with Winforms But I really want know how do I fix with SDL2-CS in Gtk Sharp because I am working under Ubuntu 18.04 SDLWidget....
0
votes
0answers
19 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
73 views

SDL2 mouse motion event keeps occuring

The code I'm using is like so: ...
1
vote
1answer
110 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
246 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
1answer
105 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
69 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
140 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
89 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
156 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
1answer
58 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
350 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
362 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
78 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
181 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
84 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
56 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
151 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
22 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 ...
1
vote
1answer
802 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
461 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
214 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
586 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
300 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
171 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
94 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
151 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
1answer
253 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
71 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: ...
3
votes
1answer
1k views

How to properly manage memory in SDL2?

I have yet another question regarding SDL2. I have some drawSprite & drawBackround & ...
1
vote
1answer
305 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
710 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
184 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
327 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
48 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
1k 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
171 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
61 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
781 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
99 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
108 views
1
vote
0answers
130 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
485 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
296 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 ...