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

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
1answer
2k views

SDL2, OpenGL, Nvidia laptop screen tearing

EDIT 2017-05-14 dvb. Issue still active to this very day, see geforce forum link in main question. Note 3: "Stoltverd" has posted a "fix guide" on geforce forum. It has workarounds for non-OpenGL ...
4
votes
0answers
198 views

Sizing a Box2D ground object

I am developing a platformer game using SDL2 for graphics and Box2D for physics. I am currently designing my levels and would like to know if it is better to make the static part of each level (ie: ...
3
votes
0answers
153 views

Bitmap font engine: When is color modulation not supported?

I am developing a bitmap font renderer for a 2D game using SDL 2. (If it matters, I'm using Debian 8 "jessie".) I had planned on storing the glyphs as a grayscale image, translating gray levels to ...
2
votes
0answers
84 views

Are there any good techniques for reducing or smoothing stutter after a longer frame?

I've been using SDL2 with OpenGL to play around with some very basic game engine development. I'm running everything on a newer laptop with Linux and Intel integrated graphics. Regardless of whether ...
2
votes
0answers
364 views

SDL2 SDL_CreateTexture returns pointer to existing texture

I have an initialized renderer in SDL2 that works fine. I create some textures from images using SDL_CreateTextureFromSurface and store them in a vector. ...
1
vote
0answers
37 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 ...
1
vote
0answers
51 views

In what ways does SDL add value beyond just graphics?

I'm in the process of learning SDL. On their webpage, they tout that commercial games (like Valve's Humble Bundle) use the SDL libraries. However, it seems like most of these games have more advanced ...
1
vote
0answers
46 views

SDL2 - Updating part of a texture is slower than updating all of it

I'm programing a kind of cellular automaton in which each pixel is an automaton. I'm using a SDL2 streaming texture with the SDL_LockTexture() and ...
1
vote
1answer
274 views

Delta Time FPS with SDL 2 in C++

I have tried achieving a good delta time and fps counter over the last few days, read and watched a lot about it, but still can't seem to get it to work. Here is an example: ...
1
vote
1answer
101 views

How can I directly write pixel data in an SDL window using surfaces?

I'd like to directly modify pixels in my window in SDL 2. I expect this code to display an entirely red window, but instead I'm getting an all black window. I'm able to get it working if I directly ...
1
vote
0answers
135 views

Will using a fixed point library in C++ give me 100% deterministic replays?

I'm working on a scrolling arcade shooter in C++ with SDL2 and I'd like to have a replay function so players can save, share, and replay good runs. I understand that floating point math is not ...
1
vote
0answers
45 views

SDL Texture not scaling to the renderQuad

I'm building a Space Invaders clone and using a sprite sheet for my invaders, but when I grab the texture from the sprite sheet, it doesn't scale to the renderQuad that I set. This is the original ...
1
vote
0answers
1k views

How to make a really high performance like factorio in SDL2?

i tried to make a 2D game engine for my game, used SDL2 as framework, C++ as language, and MSVC as compiler, using the graphics api and accelarated renderer. However, this still not enough. The game, ...
1
vote
0answers
122 views

Manual per-glyph rendering with SDL_TTF

I'm trying to create a font atlas with SDL_TTF. My idea was to create an SDL_Surface for every character using ...
1
vote
0answers
328 views

Sprite batching and dealing with isometric depth sorting

So I'm using Love2D which uses SDL2* as far as I'm aware and I have a question about texture atlases & spritebatching. I have an isometric chunk, with 2 layers, terrain and objects (trees, ...
1
vote
2answers
466 views

How to render a bevel effect with SDL2 Texture?

I develop 2D games using CodeBlocks (C++) with SDL2. I can load a texture (ex. a gray square) and render it to the screen. All is fine. If I want to change the color of the square? Yes, I can do it. ...
1
vote
0answers
227 views

Default with SDL_RendererFlip Horizontal (SDL, C ++)

When I execute my sprite sheet animation and apply renderer_flip_horizontal, a line appears in the sprite. Without the flip render, everything works fine. Example image: Note: The sprites are ...
1
vote
0answers
550 views

GuiSan | SDL2 - Setting colour key of render target results in having an black screen

At the moment i am experimenting with guisan within my little project. Everything is done sofar with SDL_Texture except Guisan which utilize SDL_Surfaces instead SDL_Texture for rendering itself. Per ...
1
vote
0answers
532 views

2D Voxel isometric rendering with non grid-aligned objects

I'm currently working on making a simple SDL2 game (written in C++) where the maps are comprised of sprite voxels (essentially just a png of an isometric cube). Game entities move in 3D space. The ...
1
vote
0answers
275 views

Get modified key with SDL2

If I poll keyboard events with SDL2 all I get is the pressed key and the modifiers. But I am using Neo and have some keys like Esc and arrow keys on a different layer which means that e.g. ...
1
vote
0answers
1k views

How to draw 2D pixel data with OpenGL

I am fairly new to OpenGL. I have a 2D game in SDL2 that uses currently works by creating a SDL_Surface from the pixel data, copying it into a ...
1
vote
2answers
1k views

Creating texture and palette modification

I need to create a texture from a surface with indexed color palette and alter the colors. However, after I set new colors, the rendered texture gets blank. ...
1
vote
0answers
88 views

Awesomium custom surface scroll

I have a custom Awesomium::Surface implementation, and I need to create a Scroll function for it. The function asks me to manually move some pixels of my texture by the indicated X and Y offset. How ...
1
vote
0answers
229 views

SDL and smooth transition between changed movement direction

I have an object at position (x,x). Using SDL keyboard events every time the user presses one of the arrow keys the objects is to be translated (via a glTranslatef()...
0
votes
0answers
24 views

Detect If Mouse/Keyboard Is Connected

Is there a way to detect if a mouse and keyboard are connected to a device? Looking through the SDL source code, I can see there are internal functions that could provide this information, but cannot ...
0
votes
0answers
44 views

SDL 2 SDL_BLENDMODE_BLEND way faster. Why?

I was just tinkering around with a simple ecs, when I noticed drawing like 20,000 rectangles killed my framerate (~10 FPS). I thought ok, maybe it's just too many. Later I wanted to draw them ...
0
votes
0answers
87 views

Drawing pixels with SDL2 advice, is it fine to draw them one by one on the CPU?

I want to make a raycaster and I figured out how to open a window and draw pixels to it with SDL2, but the way I am doing it now just doesn't seem very efficient, I figured out how to do it from ...
0
votes
0answers
63 views

State machine in C for SDL game

I want to create a state machine for menu in my SDL game. So this is my code without the SDL I just want to ask if this is a good way to create it. here is a code: ...
0
votes
2answers
131 views

How to process events as well as do OpenGL rendering using multithreading?

I am working on a very complicated graphics rendering, using OpenGL, and it is very time consuming, in the sense that it creates a delay in the event handling, of my application to an extend that, the ...
0
votes
0answers
62 views

Fixing the frame rate for SDL2 2D game

Working on a 2D game with SDL2, for now on Window, but I'd like to dream and imagine that if I finish it, I could run it on other platforms that SDL2 games can target. A core part of which is GGPO ...
0
votes
0answers
77 views

How to create same paradigm of monobehaviour and processing in C++

Having worked with monobehaviour and processing before, is it possible to create the same paradigm both frameworks use which basically is writing all code in two main functions, start/setup and update/...
0
votes
0answers
101 views

How to implement jumping on the left and right?

I am trying to make a platform game in C++ and SDL2. I tried to add a jump in the update() function of the main code below , but it does not work as expected, as you can see in the video: Note: I did ...
0
votes
0answers
131 views

SDL_Init segfault on linux

I am using Manjaro linux and SDL 2. However, when I build the application in debug mode and use gdb or something like qtcreator with gdb, to debug it, it gives me a segfault, when the function ...
0
votes
0answers
32 views

SDL Audio/Mixer cannot initialize with 2 channels only

From the documentation using SDL2 Mixer to init the soundcard with 2 channels. It will return 8 channels (7.1) and seems there is no way have just 2 channels. here the snippet that i used simple as ...
0
votes
0answers
68 views

SDL2 - show a tooltip at the cursor that displays RGB of the pixel under the cursor?

I'm writing an SDL2 program, in which I create a SDL_CreateWindow and get its SDL_GetWindowSurface, then I prepare some pixel ...
0
votes
1answer
232 views

Collision between a player and a solid block C++ SDL2

I am trying to implement a collision between a player and a solid e.g. a solid box. ...
0
votes
0answers
385 views

Creating a game on Linux with SDL and distributing it

TL, DR: Will I be able to get a single .exe file which will work smooth in a PC which does not have SDL or so installed ever. If not, how close will be the closest ...
0
votes
0answers
180 views

How efficiently use SDL_RenderFillRects?

For the sake of learning C++, I would like to optimize a "Game of life" project I made. In my first attempt, I used a bunch of SDL_RenderFillRect to draw the board squares. In my second attempt, I ...
0
votes
0answers
130 views

Scene management system for simple terraria-like game

I am building the engine for a terraria-like 2D sandbox game using SDL2. Currently, I am working on a scene management system. I was wondering if just having a single local variable in main called <...
0
votes
0answers
48 views

SDL & Image quality on iOS

We are just finishing a mobile game for Android and iOS. The image quality on iOS is subpar, and we are trying to understand why. We are currently having two problems: the background, which is a ...
0
votes
1answer
58 views

Update TTF Texture for Score

I have a little problem with Updating my Score with TTF. Im a neewbie so dont blame me :P I Try to Update my Score But the Buffer Get too small after a while and my Game Crashes. ...
0
votes
0answers
125 views

Can't load textures to the game

I am making a game with SDL and C++. I am trying to render simple image to the screen but I can't. I don't know why, I am not getting any ERROR but I see only black screen. Here is my code: game.h <...
0
votes
0answers
57 views

Blitting multiple SDL_Surface texts on top of an empty SDL_Surface results in strange outlines

I'm trying to create a single SDL_Surface that has multiple lines of texts stacked on top of each other using SDL2. When I create a single ...
0
votes
0answers
410 views

What is the most efficient way of rendering a large number of SDL2 objects?

I'm trying to find the most efficient way of rendering a large number of SDL2 objects to the screen. Each of my objects have their own sprite sheets which are stored as SDL_Texture*. Currently my ...
0
votes
2answers
109 views

SDL2 Block collision with player Bug

I am currently working on a small 2D Games Engine with SDL2 for fun. The engine works in a way, that you can define a tileset, which accesses the engine and allows you to place tile by tile on the ...
0
votes
0answers
205 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
31 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
votes
1answer
57 views

Trouble destroying an SDL2 texture from another class

In my main class (game loop) I have created a couple of object textures: //main game class SDL_Texture* objectTexture; SDL_Texture* objectTexture2; If I ...
-1
votes
1answer
183 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
votes
1answer
655 views

Rendering with sdl_gfx is so slow, any alternative?

I have been using sdl_gfx ( sdl2 extension library https://github.com/ferzkopp/SDL_gfx ) to make Android games, I have always noticed that rendering primitives is so slow. So I was rendering it once ...