Skip to main content

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

Regarding with pixel arrays and textures in SDL2

Currently, the way I render my frames is as follows. I have two arrays of pixels (in SDL_PIXELFORMAT_ABGR8888) called ...
Scene's user avatar
  • 123
0 votes
0 answers
25 views

Use DirectX 11 & HLSL in SDL

I saw Lazy Foo using OpenGL & GLSL in SDL, but I want to use DirectX 11 & HLSL in SDL. Is there a way to do this, and how?
M 027's user avatar
  • 1
0 votes
3 answers
88 views

How to stop scenes from running before switching between them?

So, I've been working on a game dev library using C++ and SDL2 (to test the library out I'm making a Pong clone). And now I'm writing a Scene Manager which is going good, I can switch between scenes ...
reallySmooll's user avatar
0 votes
0 answers
55 views

SDL2 Events how to avoid monolithic control statement?

I'm using SDL2 in my game engine and I'm trying to figure out how I can prevent having a monolithic control statement like this: ...
Konjointed's user avatar
0 votes
0 answers
89 views

What do you do with SDL2 events?

I have the typical/basic event loop for SDL2 and I'm a little confused on what to do with them or how to handle them or I guess more specifically how should I get the data from these events (e.g ...
Konjointed's user avatar
0 votes
0 answers
23 views

Beginner seeking advice: Questions regarding SDL2 setup on Windows using MSYS2 and MinGW, plus concerns about deployment

I'm currently developing a game on Windows using the MSYS2 environment and mingw64. I've successfully installed SDL2 using the msys package manager (pacman) and using CMake, was able to get it up and ...
nz881's user avatar
  • 21
0 votes
0 answers
59 views

Scrolling camera with a tile map stored in JSON and PNG

I'm trying to get a scrolling camera into my SDL2 game and I'd like some advice. The way I'm implementing my map is as follows: I use a tileset to build a map in the Tiled map editor, and I'm ...
Derek Kwon's user avatar
0 votes
0 answers
43 views

non-class type error with SDL_Rect

I am building a pong game in SDL2 as my first assignment for my game development class. I've encountered an error involving SDL_Rect that I can't figure out. I am ...
Derek Kwon's user avatar
0 votes
1 answer
97 views

How to setup a loading screen using SDL_Threads?

I am trying to set up a basic toy example of how a loading screen would work in SDL. Here is my code below. ...
lancen's user avatar
  • 33
0 votes
0 answers
62 views

How to draw a tile placement grid in a 2d isometric place/world?

I'm working on an isometric 2d tile based game in ruby using SLD 2. The tiles are 40px wide and 20px tall. I'm trying to figure out how to draw the grid (where each cell of the grid is a potential ...
Scriptonaut's user avatar
0 votes
1 answer
139 views

Simulated light for a 2D tile-map with just SDL2?

I'm working on a 2D tile-map RPG with C++17 and SDL2 + SDL_Image. There are daily cycles, weekly cycles and seasons. Even a kind of weather engine provides atmosphere. The moods and times of day are ...
El_Codepone's user avatar
0 votes
3 answers
264 views

What is the best way to implement a scene manager?

I'm trying to create a scene manager system for a small framework I'm writing on top of SDL2. I have implemented a scene management system that works, but I am not sure if it is structured how it ...
Sphereishere's user avatar
0 votes
1 answer
65 views

How to render a portion of a texture (upscaled) without affecting the border with SDL2?

I noticed that render a portion of the texture, upscaling it, it affects is border values with the proximity of the outside remaining parts of the texture (when not using Neareast neighbour ...
Raffaello's user avatar
  • 125
1 vote
0 answers
252 views

Selecting tiles with mouse on isometric map with height and slopes

I want to implement an isometric map with rectangular tiles similar to how it was in simcity 2000, where tiles could have different heights and tiles with different heights were connected by slopes. ...
SavedowW's user avatar
0 votes
0 answers
44 views

How can I bulk change sprites for my game object?

I'm using an asset pack that has 4 characters and I want the player to rotate between them whenever they respawn or in other words I wanna be able to bulk change an objects sprites. I've been learning ...
Konjointed's user avatar
0 votes
1 answer
58 views

why One big texture frames is consuming more RAM compared to be divided into single frame ones [closed]

I noticed that composing frames in a big texture will consume more RAM rather than having 1 frame per texture (or sprite if you would like). The renderer is SDL2 backed by Direct3D. Is there any ...
Raffaello's user avatar
  • 125
1 vote
2 answers
139 views

Would it be practical if I used composition for everything?

I've been learning C++ and SDL2 and I'm trying to improve at using composition and for the longest time I thought it was only useful for making things like players, enemies, coins, etc, and I think ...
Konjointed's user avatar
0 votes
0 answers
410 views

Rendering texture as pure white / filled with color with SDL2

I added a glow or shine effect to make character flash with one color for a short period of time, it looks like this. The code in draw function: ...
SavedowW's user avatar
1 vote
0 answers
274 views

How to use SDL_RenderSetLogicalSize() properly in SDL2?

I want to handle different resolutions without altering any game objects. I tried using SDL_RenderSetLogicalSize() but I don't know how to implement it properly. ...
RGthehuman's user avatar
0 votes
1 answer
236 views

How to copy the Renderer Present screen result into a surface or texture?

Is it possible to copy into a SDL_Surface what is displayed in the screen from a SDL_RendererPresent? using ...
Raffaello's user avatar
  • 125
0 votes
0 answers
103 views

How do you handle collision with a sprite?

I'm in the process of learning C++ and SDL2 and I'm trying to add a sprite to my player which is currently a rectangle. I've managed to get the sprite showing on the screen, however, I've run into a ...
Konjointed's user avatar
5 votes
3 answers
1k views

How to install game with dependencies on Linux?

I am creating a game using C and some libraries. I wish to not require my users to download anything but the game as most games are self contained. What is the usual process for compiling and ...
Lead Vaxeral's user avatar
0 votes
1 answer
231 views

Rendering Infinite 2D chunks?

I'm working on a top-down 2D RTS with C++ and SDL2, and have implemented the biome/terrain generation, tile rendering and a rudimentary camera system. I already have the skeleton code in place that ...
ireece1's user avatar
0 votes
1 answer
150 views

glClearColor prevents text from rendering with freetype using SDL2

I'm trying to add text rendering to my rendering project and am following the OpenGL tutorial at https://learnopengl.com/In-Practice/Text-Rendering I'm using SDL2 as my backend so had to make some ...
YamMan's user avatar
  • 49
0 votes
1 answer
196 views

rotating a sprite with 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 ...
user21746705's user avatar
0 votes
1 answer
268 views

Frame duration varies by a millisecond every few frames

When I run the program at 60 fps, I get 0.016 seconds per frame most of the time, then 0.017 s once every few frames. A similar thing happens for 30 fps, varying between 0.033 and 0.034 seconds per ...
Domonicx's user avatar
0 votes
1 answer
133 views

Why might performance of a Rust-sdl2 project be better while profiling?

I'm making a simple SDL2-based Rust game, on an OSX laptop. Graphics mostly involves drawing lots of colored squares to the screen. Performance is really slow for what I'm doing, so I decided to ...
sclamons's user avatar
0 votes
0 answers
83 views

SDL2 Not destroying textures properly when updating text

Im implementing a series of textboxes in sdl2 ,however my program is not working correctly -sdl is not destroying textures when the destroytexture function is callled resulting in a weird overlap of ...
Exiatron00's user avatar
0 votes
1 answer
161 views

How to handle UI when logical and screen sizes are different?

I am programming a game in SDL2 and I am looking for advice on how to handle interactivity of UI components when the screen resolution and logical resolutions are different. Up to now I have been ...
lancen's user avatar
  • 33
0 votes
1 answer
99 views

How to capture consecutive key strokes for different input modes

I'm making an Ultima spinoff which requires a lot of key strokes for actions. For example the arrow keys are for movement BUT once the player presses down the 'T' (talk) key the arrow keys are used ...
Nicholas Humphrey's user avatar
1 vote
0 answers
62 views

Garbled text and music - due to Steam Linux runtime change?

My team and I released our game on Steam last year for Windows, Mac, and Linux. The game is written in C++ and uses SDL2, including SDL2_image, SDL2_ttf, and OpenGL for graphics. Around the middle of ...
Nicolas Ford's user avatar
0 votes
1 answer
155 views

Key presses and game quit sometimes delayed by seconds

U'm currently trying to develop a 2D RPG similar to early Final Fantasy titles for the NES. Up until now I've been reading C++ tutorials on SDL2 and doing my best to convert the concepts into OCaml. ...
Nameless King's user avatar
1 vote
0 answers
89 views

Odd SDL VSYNC behaviour when monitor is set to 50 Hz

I am observing strange behaviour with VSync in SDL. I have this code: ...
arminb's user avatar
  • 201
0 votes
1 answer
91 views

SDL2 - Camera only scrolls in x direction, but not y direction

I'm following along with the LazyFoo tutorial to create the basis for a simple arcade space shooter. I'm trying to get the sprite moving through the map while being tracked by the camera. The code I ...
Kevin Shaughnessy's user avatar
0 votes
0 answers
851 views

how do I chage pixel color? (SDL2)

After a long time away, I'm coming back to SDL, using version SDL2. I have some example code that does pretty much exactly what I want it to do, but I want to change the pixel color. Ive tried ...
j0h's user avatar
  • 101
0 votes
0 answers
315 views

Movement diagonally is not consistent

I am making my own game and this is the first time i'm doing so. so I hope you can forgive stupid mistakes. Im making this in C++ and using the SDL2 framework. Currently, I have a character on my ...
Saksham Goyal's user avatar
0 votes
1 answer
555 views

SDL2 and TmxLite (Tiled) (Reading the actual TILE data from the layer)

I am trying to make use of the Tiled Map Editor for my SDL2 projects. (By using the TMXLITE parser from Fallahn on Github) https://github.com/fallahn/tmxlite ...
I_Keep_Trying's user avatar
2 votes
1 answer
399 views

Memory usage of simple SDL2 program grows linearly

I am a newbie in SDL2 and I was testing an example code of Lazy Foo SDL tutorial just out of curiosity. The program renders an image named x.bmp living in the same folder as the program. Here’s the ...
SuperNoob's user avatar
0 votes
0 answers
86 views

SDL_BlitSurface() 'dstrect' - Not working as I expected

I am new to SDL but have used C++ a fair bit over the years. I'm struggling with displaying sprites with a scale. EG. Here I am trying to draw a grid of squares (ie. Tetris) but the source BMP is ...
I_Keep_Trying's user avatar
0 votes
1 answer
92 views

How can I determine which 2d entity was selected from a overlapping pile

I'm using C++ and SDL2 to learn about coding by creating a clone of a 2d tile-based game I enjoy. To setup my problem; There can be multiple items dropped on a tile by the player or other entities ...
user161794's user avatar
0 votes
0 answers
752 views

OpenGL Multisampling doesn't work

I am trying to get the Antialiasing (multisampling) in OpenGL with SDL to work(as shown here), but the result doesn't change and I still get jaggy edges. Before rendering I call the following ...
TheBaum's user avatar
  • 43
3 votes
1 answer
261 views

How are map/room/world-related game assets usually organised and implemented?

I'm trying to build a simple 2D Shoot 'Em Up type of game in C++ using SDL2 and an Entity Component System, which I've already implemented. The idea is to have different maps/rooms where you have to ...
Nick Román's user avatar
2 votes
1 answer
1k views

SDL2 memory leak

I've been creating a 2D game in sdl2 in C and within my main game loop, I have found a section of code that causes a massive memory leak in my program, roughly leaking 100MB of memory per second. The ...
Bilal Ahmed's user avatar
0 votes
1 answer
1k views

Help with software design of a turn based combat system using SDL2

I have been working on a RPG where the player is free to wander an open world but when a monster is encountered or on keyboard command the game switches to a turn based system. Note this is not like ...
lancen's user avatar
  • 33
1 vote
1 answer
5k views

How to create editable SDL2 text input boxes?

Hi all, I'm working on an SDL2 project and I require multiple editable square textboxes as shown in the image above. Is there any way I can do this?
Bilal Ahmed's user avatar
0 votes
1 answer
148 views

Timestep Jittering

I've been trying to implement the famous Fix your timestep in C++ and SDL2 using a simple example. I have a square that moves around on the screen but I cannot understand why it keeps jittering/...
Nubcake's user avatar
  • 141
0 votes
1 answer
577 views

Does the function SDL_DestroyWindow() free the memory allocated by the renderer(s) in it as well?

I know the renderer frees memory allocated for its textures when destroyed but is this the case with SDL_DestroyWindow() as well?
the_antagonist9509's user avatar
1 vote
1 answer
2k views

How to get the RGB color values of a clicked pixel on a rendered image in SDL2?

In the same vein as this question and this question, I recently ran into a problem in my C++/SDL2 game architecture where I needed to get the R,G,B values from a clicked pixel in an image on the ...
Sciborg's user avatar
  • 594
1 vote
0 answers
345 views

Avoiding jitter when snapping diagonal movement to a pixel grid

Whats the best way to be rendering the locations of objects in box2D in such a way that there no stuttering on movement beyond 8-directions. I'm looking to have object strictly snap to the pixels but ...
Aardhyn's user avatar
  • 11
3 votes
2 answers
323 views

Steam Controller thinks it has 2 hats?

Is there any reason why a Steam Controller would think it has two hats? The pad on the left is HAT 0, as expected. Note that the pad on the right is not a HAT/DPAD, it is two axes (Axis2 and Axis3) ...
Bram's user avatar
  • 3,719

1
2 3 4 5
8