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

2
votes
2answers
70 views

Make openGL program only update every 1/60 seconds

I'm learning C++ and openGL and have this program as a result from tutorials and playing around. The problem is that the main loop is running at "full speed", making the program unnecessarily cpu ...
1
vote
1answer
81 views

SDL_GameController automatic detection

Here's something that's been bugging me all day: Controller detection in SDL. First thing is that it doesn't automatically detect when a controller is connected. Finding out when a controller is ...
-1
votes
1answer
71 views

C++ SDL2 OpenGL Rendering Problems [closed]

I just started with SDL2 and OpenGL in C++ and I am having some trouble rendering a triangle. The triangle I want to draw renders on the screen, but it is black. I tried added some shaders, but they ...
-1
votes
0answers
25 views

What are my choices in low level joystick APIs under Linux? [closed]

I am looking to add joystick support under Linux. Currently I use SDL 2, but this limits you to also using an SDL 2 window. What other options exist, and how common are they across each distribution?
5
votes
2answers
208 views

Do I really need to clear the renderer every iteration?

Just a quick question about fine-tuning/optimization. If I'm making a 2D platformer with a parallax-scrolling background (meaning no two frames are the same) do I really need to clear my renderer for ...
2
votes
0answers
76 views

How can I implement a dialogue where the words appear as if they were being typed?

I'm planning on putting a dialogue system into my game, I don't really work with surface so my way of implementing SDL_Ttf is by turning it into a texture, in other words, every paragraph would be ...
2
votes
1answer
151 views

sdl: unlock mouse in fullscreen mode and make it useable on another monitor

Is it possible to unlock the mouse in fullscreen mode so that you can use it on a another monitor? I read trough the SDL documentation, but I couldn't find anything related to my problem.
1
vote
1answer
79 views

When to use color keying vs PNG transparency?

With (SDL in this case) one can use color keying to make a certain color in an image transparent. Images in .png format can have transparency, and can be loaded with SDL. When is it better to use a ...
1
vote
3answers
185 views

How can I implement a main menu?

I have been following the tutorials at http://lazyfoo.net/tutorials/SDL/index.php and although they are all very well written and I have learned more than I would have on my own, I am not sure how to ...
1
vote
2answers
70 views

How can I render a texture to the screen in SDL2?

I've recently started upgrading my SDL version from 1.2 to 2.0.3, and while on the SDL Wiki, I've come across SDL_Renderer, SDL_Window, and SDL_Texture. I did some research and found a link at ...
0
votes
1answer
19 views

Can I create relative filepaths to images in an XCode SDL project?

Can I create relative filepaths to images in an XCode SDL project? I have to use absolute filepaths as it is, but it would be much easier if I could make the filepaths relative.
1
vote
1answer
150 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 ...
1
vote
0answers
73 views

Scrolling with SDL2 & Box2d - My Camera isn't keeping up with my player

I'm trying to get a game on the google play store before I'm 40 (long held dream to publish a game since the days of the speccy), I have just over a month to go so it's not looking good! Foolishly I ...
0
votes
1answer
105 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. ...
0
votes
1answer
75 views

Render two images to an SDL_window

I want to create a menu for an SDL game, so I load an Image to an SDL_Window as the background, then I try to load the next image which will be a button but it doesn't display the button to the ...
1
vote
1answer
38 views

Background color gradient with SDL

I want to create a menu for a game using a color gradient as the background. Is there a way to create a gradient background instead of using an image for it (since I don't know what size the window ...
4
votes
3answers
3k views

Trap mouse in SDL

How can I trap the user's mouse inside my game? It's not a fullscreen game, but I want it so that the user cannot drag the mouse to outside the screen. Do I have to check the coordinates of the mouse ...
1
vote
0answers
48 views

How do I make a game object move at an angle in an integer-indexed grid? [duplicate]

I'm making a game in SDL2 and C++. I want a way to make any game object move in a specific direction. I've thought of assigning each object a direction in radians, from 0 until 2 PI where 0 would ...
0
votes
1answer
45 views

Events management using SDL 2.0

I wrote a simple SDL program using SDL 2.0. I have a little problem when I want to check the mouse wheel events. Actually, in the version 2.0 the flags SDL_BUTTON_WHEELDOWN and SDL_BUTTON_WHEELUP no ...
1
vote
0answers
44 views

SDL_FillRect() causes access violation on palletized surface with specific inputs [closed]

SDL2-2.0.1, Windows 7, MSVC 2008. Originally saw this problem with the release SDL libs, debugging now with the development libs. Following is the entire program I'm running, minus error checking for ...
1
vote
4answers
1k views

Rendering multiline text with SDL_TTF

Can you use any function to render more than a line of text in a surface? If you can't do this, what whould be the way to go? I am doing the following: Create a surface (not sure if should be a ...
0
votes
2answers
64 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 ...
0
votes
3answers
121 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
vote
2answers
83 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 ...
1
vote
2answers
328 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 ...
0
votes
2answers
867 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 ...
2
votes
1answer
118 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?
1
vote
1answer
50 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 ...
8
votes
3answers
4k views

What animation technique is used in 'Dont Starve'? [closed]

While playing a few games in my personal time off development I've stumbled across a survival 2D/3D survival game. The game was apparently made in SDL and GLUT (Dont starve) but what really amazed me ...
0
votes
1answer
104 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 ...
5
votes
2answers
427 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. ...
0
votes
1answer
72 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 ...
0
votes
1answer
139 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 ...
0
votes
1answer
305 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 ...
1
vote
1answer
83 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
83 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
60 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 ...
0
votes
1answer
90 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
70 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
84 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 ...
2
votes
1answer
320 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?
0
votes
2answers
61 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
87 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
1answer
95 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 ...
1
vote
2answers
335 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 ...
1
vote
2answers
262 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
47 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
97 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 ...
1
vote
1answer
192 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 ...
1
vote
1answer
114 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. ...