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.

learn more… | top users | synonyms

1
vote
2answers
800 views

SDL2 sprite batching and texture atlases

I have been programming a 2D game in C++, using the SDL2 graphics API for rendering. My game concept currently features effects that could result in even tens of thousands of sprites being drawn ...
0
votes
2answers
80 views

Collision detection in seemingly random locations [closed]

I have a square that moves around with user input and should return to top left of screen when it collides with one of the rectangles on the screen. It works fine when the the rectangles are not ...
1
vote
2answers
116 views

SDL sprite animation problem

I'm currently drawing my character from a single file, and my sprite class handles it taking the file path as an argument. Now, I need to add a simple animation, cycling between two frames. The ...
0
votes
1answer
248 views

Why does this code to filter events with SDL not function properly?

According to the SDL2 wiki, SDL_SetEventFilter : Use this function to set up a filter to process all events before they change internal state and are posted to the internal event queue. ...
1
vote
1answer
152 views

How to manage screen and input when using libSDL2 for both desktop and Android?

I have worked on libSDL1.2. Since, the release of 2.0, SDL also supports android. So, I am trying to develop game that can work both on desktop and android. But there are few things that are confusing ...
0
votes
1answer
228 views

Drawing Colored Geometry in OpenGL using SDL

First off, I will confess I have asked the same question on stackoverflow, but I think this forum might be a better fit. I am trying to combine 2 things using SDL: Draw a webcam feed via an ...
0
votes
1answer
137 views

Why does my SDL code crash when I move the mouse over the window?

Whenever I move my mouse below where the image renders in my game, the SDL window crashes and closes down. I have narrowed the crash down to the bit of code where I check to see if the Escape key ...
3
votes
1answer
258 views

How to convert a SDL window to a SDL surface? SDL 2

I am trying to make a paint program and there is a sdl function called IMG_SavePNG() which requires a surface and destination file. How can I turn what I see in the window to a surface?
0
votes
1answer
279 views

Texturing a PyOpenGL 3D Cube with PySDL2

So, I've just started learning OpenGL with PySDL2, and I've created a class that will create a cube to the window that I've created with PySDL2. What I'd like to do now, is to figure out a way to ...
1
vote
1answer
134 views

Update and Render logic with interpolation

I am working with C and SDL2 and just wanted some insight as to how to properly apply interpolation to the rendering. EDIT - some clarification, update() input() and render() are just hypothetical ...
1
vote
0answers
222 views

Im getting LNK2019 errors using SDL 2.0.1 in visual studio 2013 [closed]

Here are the error codes and Here Is the link to all the code: Error 5 error LNK2019: unresolved external symbol WinMain@16 referenced in function __tmainCRTStartup ...
0
votes
1answer
295 views

How to handle simultaneous mouse and keyboard input with sdl?

I'm making a game in SDL2 that so far is basically just a top down shooter, where the player aims at the mouse. When I run the game, you can move properly and shoot properly, and shoot and move the ...
1
vote
1answer
101 views

Multiple keys being pressed, some being ignored SDL

I'm making a two player pong clone and my problem is that when the second player presses both of his/her buttons at once, the first player locks up and cannot move, even though this does not happen ...
1
vote
1answer
95 views

Why do I get an access violation while reading the pixels of an SDL_Surface as follows?

I'm trying to write a software rasterizer and I'm in the step to texture a triangle. I'm trying to get a pixel from an SDL_Surface which is an image, 100x60 at 24 bits of color depth. I got a read ...
0
votes
2answers
129 views

What exactly does SDL_RenderSetClipRect do?

I assumed that this function would move the area which is clipped out of conceptual space and copied onto the renderer (and subsequently drawn to the window) - i.e. change the origin of rendering - ...
-1
votes
1answer
106 views

Starting game development on linux [closed]

So I'm considering beginning doing some game development using Ubuntu, however I'm a bit lost when considering how I'm going to start. When I begun doing it on Windows, the choice was kind-of ...
1
vote
2answers
678 views

How can I rotate a bitmap without D3D or OpenGL?

I've just figured out on my own how to scale a portion of a bitmap using PutPixel. I would like to know the mathematical theory behind rotating a bitmap on my own, using per-pixel operations like ...
1
vote
2answers
552 views

SDL 2.0 filtering mouse events

I have a simple 2-D breakout clone. It works fine, except for one bug. If I move mouse over game window, it will get input from mouse(mouse movement), and event queue will instantly be flooded with ...
0
votes
0answers
48 views

Powder physics, how to efficiently find out where other particles are [duplicate]

You might be familiar with games like powder toy or powder game or some variation of it. I'm working on a very basic and similar game with just sand and water to learn a bit how it on works. I use ...
0
votes
0answers
153 views

C# SDL.NET how to enable vsync

To start, I know that you cannot enable vsync in the application if it is disabled in the driver. My problem is, I cannot get it to work at all, even though it's NOT disabled in my driver. From what ...
0
votes
1answer
78 views

Why, after calling SetVideoMode as in the following, does nothing appear on my screen?

I am trying to create an application that will need to use double buffering (for purpose of vsync). I am using SDL.NET. From what I understood, in order to have double buffering, I have to ...
1
vote
1answer
312 views

Black or White Border/Shadow around PNGs in SDL/OPENGL

having the same issue as this: Why do my sprites have a dark shadow/line/frame surrounding the texture? however, when I do the fix suggested there (changing GL_SRC_ALPHA to GL_ONE) it just replaces ...
5
votes
2answers
638 views

Rotating object around moving object/player in 2D

I am trying to implement a camera which rotates around the world around the player. I have found many solutions online to the task of rotating an object about the origin, or about an arbitrary point. ...
1
vote
1answer
156 views

Brief pause after keypress

After i press and hold the key it goes forward once then pauses for a second or less then goes forward on forever. My problem is the brief pause I cant locate the issue. Thanks for your help. ...
0
votes
2answers
2k views

Altering pixel value in an SDL2 texture

Alright, I have spent a lot of time on this one, so I need some help. I like the ability to draw pixels directly to the screen, sometimes I do this to trace the path of objects for debugging etc. In ...
-1
votes
1answer
207 views

Using interpolation to traverse waypoints

I'm making an isometric turn based strategy. Characters can move between tiles and tiles only, so I made a function for moving one tile in any direction. Regarding path-finding, I implemented A*, ...
2
votes
1answer
215 views

How to implement scripted events?

I'm building a game in C++ (using SDL) for a college project, I'm trying to figure out how to script events that happens when a player does something, or some time passes etc. I have a and idea of ...
1
vote
4answers
354 views

SDL zooming/upscaling without images becoming blurry?

I'm working on a game with 32px tiles and I have one question regarding this and scaling. When I try to see my game fullscreen my image just becomes blurry. I remember playing NES games and when the ...
-1
votes
2answers
220 views

Pixel size for clips in retro NES-like game?

I'm making a retro videogame, currently I'm using 32px x 32px tiles for the map and 64px x 32px for the characters. However the game looks extremely small, I could increase the tile size to something ...
1
vote
1answer
127 views

Sound upsample using SDL

We have managed to play audio files using SDL's Mix_PlayMusic function. The problem now we need to do some upsampling for one audio to match the other so that both have same duration. Any idea how to ...
2
votes
1answer
795 views

How do I access the pixels of an SDL 2 texture?

How exactly can one get to the RGBA pixel arrays of SDL 2.0 textures? Does the texture need to be specially initialized and locked down?
1
vote
2answers
492 views

How do I implement collision detection with a sprite walking up a rocky-terrain hill?

I'm working in SDL and have bounding rectangles for collisions set up for each frame of the sprite's animation. However, I recently stumbled upon the issue of putting together collisions for ...
0
votes
1answer
1k views

SDL2 render to texture support

I'd like to use the function int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) in my 2D game. At this point I am using only the SDL 2.0 API, and using openGL seems overkill to ...
11
votes
5answers
974 views

What are the benefits of capping frames per second? (If any)

I am working on a simple game in OpenGL, using SDL for display initialization and input, and it appears in terms of timing I have two options available to me. Number one being just sleeping for the ...
0
votes
1answer
100 views

Luminance increase in SDL

We have managed to create grayscale picture using the following snippet of codes in SDL. What we need to do now is how to first convert into YUV or YCrCb for it be able to set the luminance value and ...
0
votes
1answer
487 views

SDL gray scale image from a a color image?

I am new to sdl. I have basically have the following codes which can load the images. I know how to access the pixel as below. What I need it to convert the image to 8 bit grey level and 1 bit ...
0
votes
1answer
238 views

SDL tiles rendering

I'm pretty new to SDL and wonder what is better if I have to draw tiled map on screen: to SDL_RenderCopy each tile from texture(which presents tileset) and then SDL_RenderPresent it every frame or to ...
0
votes
2answers
265 views

How to move player based on existing Game state?

I'm trying to build a basic platforming game in C++ using SDL, and I've encountered this issue enough to know that there's something I'm missing. What I'm working with, at the most basic level, is ...
10
votes
2answers
3k views

Input management techniques in large games

Is there a standard technique for managing input in large games. Currently, in my project, all input handling is done in the game loop, like so: while(SDL_PollEvent(&event)){ ...
-1
votes
1answer
917 views

Is SDL a game engine? [closed]

I would like to ask if SDL is considered a game engine, or just a library like Open and Direct3D?
0
votes
2answers
962 views

SDL Function for Loading PNGs

I'm learning SDL 2.0 at the moment and I've seen this method for loading BMPs: SDL_Texture* LoadImage(std::string file) { SDL_Surface *loadedImage = nullptr; SDL_Texture *texture = nullptr; ...
2
votes
2answers
5k views

SDL 2.0 setup on code::blocks using gcc(MinGW) on win7 [closed]

I have recently installed code::blocks on my system running windows 7 home premium 64-bit, and wanted to start learning SDL. The code::blocks executable is the one installed by the ...
-1
votes
1answer
329 views

How is destructable terrain made in SDL?

I'm looking for terrain that gets removed in chunks (like in Worms, of instance). How do you do this in SDL?
2
votes
1answer
358 views

2D Circular View/Background Wrapping SDL for Game

In the games such as Defender (1980 arcade) and Defcon, the player can move/scroll in one direction infinitely because the level/terrain simply wraps over and over again(like if it was wrapped around ...
0
votes
1answer
982 views

OpenGL + SDL Linking Problem [closed]

So I'm trying to write a simple application with SDL 1.2 and OpenGL. This a stripped down version of the code containing the one problem I'm having. //The headers #include "SDL.h" #include ...
0
votes
1answer
128 views

SDL 1.3 on Windows 7. Better hardware,lower FPS [closed]

I've just moved from one PC to another.I've been developing a game in SDL with SDL_image and SDL_ttf for about one year. On my old pc, I had about 90 FPS on my game, but now I have about 30, witch I ...
1
vote
0answers
57 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 ...
2
votes
3answers
380 views

Efficient Collision Detection With Numerous Objects at Once [duplicate]

I am developing a 2D game with very large levels in which two teams(around 200 objects per team) fight against each other in planes, tanks, turrets,...etc. With every entity shooting bullets at their ...
0
votes
1answer
66 views

SDL - BlitSurfaced Background Slowing Time Based Movement

Whenever I use BlitSurface to apply a background image, the movement of my characters is slowed drastically even though I have movement based on time: SDL_BlitSurface( background, camera, screen, ...
-1
votes
1answer
56 views

Reverting the view SDL

So in my SDL application, which I setup for OpenGL, if I were to do the following code: glBegin(GL_QUADS); glVertex2i(0, 0); glVertex2i(50, 0); glVertex2i(50, 50); glVertex2i(0, 50); glEnd(); The ...