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
374 questions
0
votes
0
answers
43
views
how to implement event system with SDL2?
I'm writing a C++ game engine using SDL2 and I have an SDL event loop, but I'm not really sure what I want to do with these events. I know that I'll have systems that will be interested in these ...
1
vote
1
answer
143
views
Problem with SDL2 optimization (tree structure)
while I was trying to optimize SDL2 rendering phase as much as possible, I reached a wall. I tried to search on the internet but I could not find any solution. So, I need help.
Let me explain the ...
0
votes
0
answers
109
views
How can I accurately calculate deltatime in SDL2/3?
I have looked up ways to calculate DeltaTime in the past, but the 'solutions' seem to have my program be slightly jittery or not move things correctly. As far as I know, you would calculate it by ...
1
vote
0
answers
187
views
Resolution-independent rendering of crisp 2D graphics (non-pixel-art)
I’m a beginner developing a 2D game in SDL2 using C with a visual style that uses crisp high resolution graphics (like geometry dash and Hollow Knight -- not pixel art). I want the game to scale ...
0
votes
2
answers
160
views
Linked list in C
I only know C, no other language.
How do I use a linked list to store projectiles in sdl2?
My bullet currently has an sdl_image, has been queried and has the following properties:
...
0
votes
0
answers
45
views
Collision detection for a newbie [duplicate]
I am a freshman cs major with an interest in game dev. I know next to nothing and am very new to this so please bare with me.
TLDR; Should I use BSP for detection between moving and static objects as ...
0
votes
1
answer
154
views
Fixing the player movement with SDL2
Whenever I create a project with SDL2, I always encounter the same issue: when I hold down a key (for example, W for upward movement), it moves on the first frame, doesn’t move on the second frame, ...
0
votes
1
answer
116
views
Trouble with Transparent Pixel Blending in PNG
When drawing transparent PNG data on to the renderer, pixel data of any previous drawing (layer beneath) is replaced with the renderer's drawing color (green).
I have tried setting blend mode in the ...
0
votes
0
answers
70
views
Invalid Pixel Offset Calculation Fix?
I am currently using a SDL_Texture *texture as a chunk in my world that is being Perlin noised onto to make terrain.
Using a 2d array of these I tile the plane. But ...
0
votes
0
answers
80
views
Is there more efficient method of terrain rendering in 2D plane than redrawing millions of SDL_FRect each frame
I want to render terrain efficently using perlin nosie and a lots of rects. Should I use rects or is there another way. Following is my implementation.
I use rect size = 1 which is not really ...
3
votes
2
answers
198
views
SDL hello-world program on ArkOS runs without error, but shows no output
I recently bought a R36S retro handheld linux based game console. The system runs ArkOS which is a Ubuntu based OS. On boot, the system launches the program EmulatorStation, but it is possible to exit ...
0
votes
1
answer
99
views
How to get X and Y pixels of a Image in SDL2?
I am trying to create a Voxel Space Engine In SDL2 C++. However the tutorial I am following reads the X and Y pixels of the heightmap image. I can't find a way to do this.
I am following this tutorial:...
0
votes
1
answer
145
views
SDL2 oversized pixels
I pulled my SDL2 game out of cold storage and am working to get it running again. I found a curious thing: graphics primitives based on SDL2_gfx and text based on SDL_ttf are displaying way too big, ...
0
votes
1
answer
220
views
How to render a texture in a unique color using SDL2?
(I apologize in advance for my awful English)
I'm writing a personal UI library in C++ using SDL2, and when came the moment to implement icons, I struggled to find how to render them in a unique color....
1
vote
1
answer
124
views
Reading steering wheel events has 180 degree dead zone. How to remove/reduce dead zone?
I'm making a GUI that can be controlled by a steering wheel. It need only run on Windows.
It works as expected with exception of the fact that the first 90 degrees in either direction seems to be ...
0
votes
1
answer
174
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 ...
1
vote
1
answer
497
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?
0
votes
3
answers
156
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 ...
0
votes
0
answers
111
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:
...
0
votes
1
answer
334
views
How to deploy SDL2 game on Steam/Windows — what do I do with the dll?
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 ...
0
votes
0
answers
71
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 ...
0
votes
2
answers
255
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.
...
0
votes
1
answer
423
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 ...
0
votes
3
answers
964
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 ...
0
votes
1
answer
138
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 ...
1
vote
0
answers
383
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. ...
0
votes
1
answer
86
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 ...
1
vote
2
answers
263
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 ...
1
vote
0
answers
489
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. ...
0
votes
1
answer
563
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 ...
6
votes
3
answers
2k
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 ...
0
votes
1
answer
442
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 ...
0
votes
1
answer
239
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 ...
0
votes
1
answer
352
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 ...
0
votes
1
answer
394
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 ...
0
votes
1
answer
234
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 ...
0
votes
0
answers
109
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 ...
0
votes
1
answer
239
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 ...
0
votes
1
answer
144
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 ...
1
vote
0
answers
82
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 ...
0
votes
1
answer
230
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. ...
1
vote
0
answers
128
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:
...
0
votes
1
answer
119
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 ...
0
votes
0
answers
1k
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 ...
0
votes
1
answer
456
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 ...
0
votes
1
answer
785
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
...
2
votes
1
answer
497
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 ...
0
votes
0
answers
160
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 ...
0
votes
1
answer
130
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 ...
0
votes
0
answers
1k
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 ...