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
3
votes
1answer
159 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 ...
2
votes
1answer
161 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
86 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
87 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
93 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 ...
0
votes
1answer
36 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
4answers
3k views

graphical interface when using assembly language

I want to learn a framework to use in assembly. I know that's not possible without learning the framework in C first. So I'm thinking of learning SDL in C and then teach myself how to interpret the ...
0
votes
3answers
3k views

Cannot load png images to textures with SDL2 in Visual Studio 2015

I'm learning SDL2 with Visual Studio 2015 and I'm trying to draw a 16x16 level with a .map file and 32x32 .png images for tiles (that's 256 tiles) on a 512x512 window. I have both SDL2 and SDL2 Image ...
1
vote
2answers
160 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 ...
0
votes
0answers
36 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
149 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 ...
24
votes
8answers
9k views

What advantage do OpenGL, SFML and SDL have over software rendering?

I started watching the Handmade Hero stream, where Casey Muratori creates a game engine without using frameworks or such. Yesterday I got to the part where he showed how an image is drawn onto the ...
1
vote
2answers
1k views

SDL Memory leak with TTF_Font and surface

I am creating 2D game with SDL2, and I have a problem with my label class. Every time I construct new label I have a memory leak, and I don't know what I do wrong! For example, I want to refresh ...
0
votes
1answer
161 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
259 views

SDL2 mouse motion event keeps occuring

The code I'm using is like so: ...
3
votes
1answer
277 views

SDL2_ttf gradient

I want to render some text using a gradient instead of a solid color, but I can't figure out how to. I first load a gradient like this: ...
0
votes
1answer
518 views

SDL Surface clipping mask

I am creating a GUI for my game, so I use some buttons like . So you can see it is only text surrounded by a rectangle. But I currently use a huge png image with all the buttons I need arranged as I ...
1
vote
1answer
40 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
201 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
125 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 ...
8
votes
3answers
19k views

SDL Function for Loading PNGs

I'm learning SDL 2.0 at the moment and I've seen this method for loading BMPs: ...
2
votes
0answers
85 views

Glowing Effect and Blending [duplicate]

I am using C++ and SDL and I am trying to get lines with a glowing effect as provided by the image of the game Defcon on the continental outlines. How could I achieve this glow and blend of the ...
9
votes
2answers
32k views

Making a 2D Platformer in C++/SDL. Looking for tutorials/examples/resources [closed]

I have a lot of experience with C++, but I have no experience with game programming. This summer I plan to create a 2D platformer from scratch using C++/SDL for the learning experience. I am looking ...
1
vote
1answer
663 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
2k views

What's wrong my code to create a GL texture from an SDL_Surface?

I have an issue here with converting an existing SDL_Surface into an OpenGL texture. The texture gets created, but it's a plain white texture, below is a screenshot of the result: It seems to me ...
7
votes
2answers
7k views

How do I modify textures in SDL with direct pixel access?

I'm trying to use SDL_LockTexture and SDL_UnlockTexture for directly editing pixels in a texture. I'm using SDL 2.0. Setting the pixel value using the following code doesn't modify the texture: ...
1
vote
1answer
344 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 ...
-1
votes
1answer
383 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 ...
0
votes
1answer
267 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
1answer
72 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. ...
1
vote
1answer
397 views

How to properly setup unit testing for my c++ game project? [closed]

I'm currently creating a 2d game in C++ using visual studio and utilizing gtest/gmock for my testing framework. The problem I'm having is I'm not sure what my best option is for testing. I'm using SDL ...
0
votes
1answer
333 views

C++ SDL Bullet shooting problems

I'm coding a C++ SDL game and now I got a problem with my bullets. If I shoot, bullets should fly away in a straight line according to the player's angle. That's ok but how can I copy multiple bullets ...
11
votes
2answers
13k views

How to calculate delta time with SDL?

I have heard that you can calculate delta time with two functions called SDL_GetPerformanceCounter and SDL_GetPerformanceFrequency. I'm not sure how they work completely, but I heard it is a bit ...
1
vote
2answers
546 views

SDL draw dynamic select box

This might seem obvious to many, but I'm stuck and I cannot find any tutorial which helped me, so it would be great to find the answer here. I tried to make a rectangle like you have in RTS games, so ...
2
votes
1answer
739 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
1answer
2k views

SDL and software/hardware rendering. How to go about it?

I know that SDL 1.2 does software rendering (CPU) and not hardware rendering (GPU). My question is, how do I use SDL but with hardware rendering? How do I not use its rendering API (software) and ...
0
votes
2answers
1k views

My C++/OpenGL “Hello Triangle” Code Does Not Draw A Triangle When Using SDL As A Window Library

I have been using the website Learn OpenGL but I am using SDL as a window Library. My code seems to builds the window correctly but no triangle appears. I am compiling my code using Visual Studio ...
0
votes
2answers
105 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
92 views

Inverted left & right stick axes in SDL2

I've faced a weird problem with SDL2. ...
0
votes
2answers
523 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
votes
1answer
177 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 ...
0
votes
2answers
2k views

Will using OpenGL for rendering with SDL make my 2D game run smoother?

I've been working on a 2D game using SDL. I've noticed the objects look blurry and glitchy when they're moving, so I was thinking about using OpenGL to render the graphics. Would this help? What ...
1
vote
2answers
3k 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 ...
0
votes
2answers
8k views

making a game in 2D(C++). SDL or openGL? Or, why not both? [closed]

I'm trying to make a platform game in 2D and I want to know what tool should I use to make it happen. I understand that I can use SDL with openGL. However, if I want to make a solid 2D platform game, ...
2
votes
2answers
533 views

SDL_RenderDrawLines isn't drawing complete geometry

So I am trying to draw hexagons with [SDL_RenderDrawLines][]. It looks to be working fairly well, however, it fails to draw some of the lines. So each of the ...
1
vote
1answer
46 views

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

I am sending two messages from server.exe like this: ...
-1
votes
1answer
652 views

How to handle pathfinding and path following with sprites the same size as the grid?

The game I am working on is currently using 32X32 collision boxes. I have implemented a working AI (A* - path finding method) which is based on the Grid Size. Lets say that I use that 16x16 grid , ...
2
votes
1answer
960 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 ...
5
votes
4answers
1k views

Moving one object from one point to another with acceleration

How would someone implement moving an object from one point in 2D space to another using these formulae to update objects: ...
0
votes
1answer
459 views

Simulate Keyboard Button Press [SDL Library]

I am trying to simulate an SDL keyboard button press (using C). I have looked up the SDL info pages online but I still don't have anything that consistently works. I have the following (removed the ...