Questions tagged [sdl]

Simple DirectMedia Layer (SDL) is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.

Filter by
Sorted by
Tagged with
1
vote
0answers
8 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
1answer
19 views

Getting a surface compatible with the texture / renderer

I'm trying to convert my emulator to SDL2 (from SDL 1.2). As I'm drawing pixel per pixel, I follow "If your game just wants to get fully rendered frames to the screen" in the migration guide:...
0
votes
0answers
34 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
3answers
76 views

Should I bother with SDL_WaitEvent?

When I wrote my first application in SDL, it looked like this: while (!quit) { SDL_PollEvent(&event); switch (event) { // ... } } But ...
2
votes
2answers
84 views

SDL_SetColorKey in SDL c++ removes most of the white pixels but there is a border around my character

I have drawn all of the images of my sprite in paint. Is there a way to remove all white pixels? ...
0
votes
1answer
79 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
72 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
47 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
0answers
79 views

SDL2 for hardware accelerated graphics?

I am attempting to make a 3d game using SDL2 just to learn and have a bit of fun. I was wondering if there is any way to get SDL2 do calculations on GPU. I have read that SDL2 Textures uses GPU for ...
2
votes
1answer
78 views

Polling events with SDL results in stuttering response when dealing with multiple objects

I'm new to SDL programming and I'm not quite sure I got how it handles events. Given an instance like this defined in "game.c": ...
0
votes
0answers
87 views

Is making an acceptable 3D engine possible using only SDL_* functions?

I've been watching Javidx9's 3D engine series and I decided to start making it with SDL because it was something I had heard of and seemed simple enough. I'm not going to implement too complex ...
0
votes
0answers
259 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 ...
1
vote
1answer
282 views

In SDL, what is the difference between using a Surfaces and a Renderer?

I am new to SDL and I've been following some tutorials; in one tutorial he used Surfaces (a window surface and image surface) and a BlitSurface function to draw images without using any renderer (used ...
1
vote
1answer
209 views

Rotate Sprite towards mouse cursor SDL

I have trouble to make my sprite(Arrow) to point at the position of my mouse cursor but i don't get the Right results. I've tried this: ...
3
votes
1answer
404 views

C++ Wrapper class for raw pointer to an SDL_Texture

First time in game dev, so go easy on me. I understand it's senseless to copy textures, but I'm trying to see this from a copy/move perspective since there is a lot of that going on in my code and in ...
1
vote
1answer
116 views

The A * algorithm in the map has many moving objects

I am using the A * algorithm for my game, it is a kind of Isometric map with lots of tiles. If all the game objects are trees, rocks, houses and only one game object is a moving hero, the A * ...
2
votes
0answers
170 views

Structure for a strategy game

I am making a strategy game like Age of Empires. It's a pretty big project and I need a clear game structure. I have defined a Game_Object class with variables ...
0
votes
1answer
124 views

Identify an object currently selected in the game

I am making a 2D isometric game that uses the mouse. When I left click on an object, this object should be selected, but how do I determine what object that's currently selected and show a halo around ...
2
votes
1answer
261 views

Making text scroll correctly with a textbox

So let me just get this right out of the way, I'm using SDL1.2 (Lispbuilder-sdl specifically, as I'm using Common Lisp), so on to the problem. I'm trying to make a scrollbar that can scroll text in an ...
0
votes
1answer
298 views

How can I scale my window in SDL 1.2?

I'm trying to scale my window, for example from 440*420 to 320*240. How can I easily do this?
0
votes
0answers
54 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 ...
1
vote
2answers
431 views

C++ OpenGL texture warping

I'm currently doing simple 3D drawing in OpenGL but I have hit a roadblock I just can't seem to get around. The problem is happening with trying to load .obj files. I've written my own .obj reader. I ...
1
vote
1answer
162 views

How to make texture for text displaying using SDL ttf with good performance?

In my game, there are many units and for each units there's an information widget attached next to them. I use SDL as the game rendering engine. I currently want to display their ID for debugging ...
0
votes
2answers
216 views

How can I benefit when I don't use gpu?

I am trying to make a 3D game with C++, SDL, and OpenGL. My program roughly looks like this: control function has only CPU operations. draw function has CPU and OpenGL functions operations. I just ...
0
votes
1answer
361 views

How should rendering be structured using SDL?

This question is probably well documented but I can't find any resources. Basically I'm not sure how to structure rendering with SDL in my code. I made a render class which calls the api and the ...
1
vote
1answer
878 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
1answer
350 views

SDL Sliding Collision

I'm working on a 2D SDL C++ project, and I'm having a bit of trouble with collision detection. Currently the player collides with the edges of the level and with the SDL_Rect objects in the level, ...
3
votes
1answer
707 views

SDL2 mouse motion event keeps occuring

The code I'm using is like so: ...
1
vote
1answer
819 views

OpenGL draw functions and multi-threading. How they work together?

I want to apply multi-thread in a simple way to control and draw 4000 objects. I am using SDL and OpenGL. control : locations, collisions, calculations ... etc draw : OpenGL draw functions ...
0
votes
1answer
508 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
203 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 ...
2
votes
1answer
2k 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
231 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
0answers
157 views

Inverted left & right stick axes in SDL2

I've faced a weird problem with SDL2. ...
0
votes
2answers
1k views

SDL/C++ Keyboard Input

I'm having trouble with key management. Movement works fine but the shooting does stuff that I don't want to happen. Every time I press the arrow keys to shoot it works fine but when I press a key ...
1
vote
1answer
64 views

Why do I only receive the first message I send with SDLNet?

I am sending two messages from server.exe like this: ...
1
vote
1answer
97 views

Is there a way to duplicate the windows desktop zooming in SDL to make low res pixels look like stylyzed cartoon art?

When you hit the Win key and numpad plus key at the same time it opens the desktop magnifying glass and the effect of this on low res pixel art is to make it look like super cool stylized cartoon art. ...
4
votes
1answer
2k 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 ...
0
votes
1answer
817 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
471 views

How can I build DOOM (SDL-Version) with MinGW?

I have recently been trying to build this source code here. I am building the original port with SDL infused, not the linuxdoom port and I’m having some issues. What I have tried first: I've ...
1
vote
1answer
493 views

Change the image of sdl window with a new one

I will make a game and it has 3 buttons on its menu. Those buttons supposed to change the picture the background of the menu When i click on play, another picture should appear like so I found a ...
-1
votes
1answer
181 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
1answer
93 views

Weird issue with Member Initializers C++

I'm making a game with C++ and SDL2. I have a class called "text" and a class called "buttonObj" The constructor of "text" is a void function that takes an SDL_Color variable. The first part of ...
0
votes
1answer
757 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 ...
3
votes
1answer
4k views

How to properly manage memory in SDL2?

I have yet another question regarding SDL2. I have some drawSprite & drawBackround & ...
0
votes
1answer
252 views

Fading in textures at a constant rate over a controlled duration

I'm trying to fade textures onto the screen using SDL2. I've tried some different methods I've looked up, but I always encounter the same problem. It seems that the fading takes longer and longer as ...
0
votes
1answer
823 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 ...
3
votes
1answer
2k views

How can SDL tell what Xbox360 controller is what player?

I init my controllers like this: ...
0
votes
2answers
145 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 ...
2
votes
2answers
6k 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
2 3 4 5
9