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
0answers
63 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
2k 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
70 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
103 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
533 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
1k 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 ...
3
votes
1answer
198 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
112 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
131 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
533 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
101 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
224 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
372 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
109 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
143 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
72 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
179 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
87 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
91 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
547 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
79 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
96 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
116 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
415 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
385 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
131 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
262 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
135 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. ...
-1
votes
1answer
178 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
202 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
votes
2answers
210 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 ...
4
votes
3answers
7k views

How to draw 2D images using OpenGL, in SDL?

After everything, I managed to find a simple piece of code that shows how to draw a 2D image with openGL: #include "SDL/SDL.h" #include "SDL/SDL_opengl.h" #include "SDL/SDL_image.h" ...
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 ...
2
votes
1answer
295 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 ...
-2
votes
4answers
2k views

Trying to figure out SDL pixel manipulation?

Hello so I've found code that plots a pixel in an SDL Screen Surface : void putpixels(int x, int y, int color) { unsigned int *ptr = (unsigned int*)Screen->pixels; int lineoffset = y * ...
11
votes
5answers
872 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
87 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 ...
2
votes
2answers
4k 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 ...
0
votes
0answers
341 views

How do I use Opengl in conjunction with SDL?

I've been using SDL for a while in simple 2D games but have been limited as to what I can do graphics wise. I would like to start using Opengl. Does anyone know of any web tutorials for using Opengl ...
0
votes
1answer
189 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
237 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 ...
4
votes
1answer
1k views

Game class and main function

I have a Game class with my main game functions and instances of game objects like screen, etc. My game is made using C++ and SDL. I was wondering, though, should main be a function of my class? Or ...
-1
votes
1answer
55 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 ...
8
votes
2answers
2k 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)){ ...
2
votes
3answers
1k views

How should I store levels in a C++ game?

I am writing in C++. I am storing game levels as a 2-dimensional int array. This may be a hacky way of doing things, but I am not ready to change it unless I have to. I store values in the array and ...
-1
votes
1answer
720 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
730 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; ...
1
vote
2answers
320 views

Recasting and Drawing in SDL

I have some code that essentially draws a column on the screen of a wall in a raycasting-type 3d engine. I am trying to optimize it, as it takes about 10 milliseconds do draw a million pixels using ...