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

0
votes
1answer
40 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: m_position.setX/Y( m_position.X/Y() + m_velocity.X/Y() * dt + 0.5 * m_acc * ...
0
votes
0answers
20 views

SDL won't show images [on hold]

I'm new with C++/SDL and I'm having problems getting textures on screen. I'm trying to make a Tic tac toe as a first project, I know there's probably a lot of bad code but I only want help with the ...
0
votes
0answers
34 views

SDL/SFML if i have only got experience in java? [on hold]

My question is, If i have a reasonable amount of experience in Java, would it be difficult for me to use a library like SDL or SFML. Should I learn more about c/c++ first or should I just jump in ...
0
votes
0answers
95 views

Why must SDL compile as a dll [closed]

I'm using SDL for some small games I work on, and I have tried to no avail to change the compiler settings from compile as a dll to a 'normal' project. So my question is, why must SDL compile as a ...
2
votes
1answer
101 views

How can I optimize per-pixel drawing in SDL?

I've been messing around with C++ the last few days and I'm trying to figure out how to draw the screen pixel by pixel each frame. It sounded simple enough at first, but then I realized for loops ...
0
votes
0answers
27 views

Pseudo 3D questions in SDL/C++ [duplicate]

I'm going for a SNES mode 7 effect. From my understanding you do maths, to grab the current pixel from z values. Resulting from this math you take an image and then transcribe it into the screen for a ...
2
votes
2answers
70 views

Translating an object in the rotation direction

I am creating a graphical scene with OpenGL and SDL, and I'm running into a problem in regards to translating an object in its rotation direction. Each of the graphical objects in the scene has a ...
1
vote
1answer
52 views

How do I compile further libraries into my game? [closed]

This might be vague; I don't know how to search for this. How do I link a GUI framework (in my case, CEGUI) to a graphics framework (in my case, SDL)? I'm using a Mac. My mental model on how to add ...
1
vote
0answers
40 views

Where can I get correct pitch parameter for SDL_RenderReadPixels function in SDL2?

I have a texture created with SDL_TEXTUREACCESS_TARGET access and I want to get all it's pixels with SDL_RenderReadPixels() function. One of the function parameters is pitch and I don't really know ...
0
votes
2answers
43 views

Kerning between glyphs using SDL2_ttf

I'm loading a number of characters (using SDL2_ttf) into a texture atlas to improve performance. The glyphs can be separately rendered correctly, however, how can you find the kerning distance ...
1
vote
2answers
125 views

Problem getting mouse events while keys held down in SDL2

I'm attempting to write input capturing code using SDL2 on Windows. However, I'm running into a problem. Whenever a key is held down, the SDL event queue has no mouse movement, nor will the mouse ...
0
votes
2answers
65 views

Colour values of a pixel array from a spritesheet image wrong (C++, SDL2)

So basically what i want to do is create a 2D tile based rendering system in C++ that renders each pixel on the screen manually. Rendering an individual pixel on the screen works just fine (or render ...
0
votes
2answers
63 views

Segmentation fault adding SDL_Surface

I'm trying to add a new SDL_Surface to my whack-a-mole clone code but even if I set it to null it wont let me. game.h #include<SDL2/SDL.h> #include<SDL2/SDL_image.h> ...
2
votes
0answers
39 views

Rendering text with SDL2 and OpenGL

I've been trying to have text rendering in my OpenGL scene using SDL2. The tutorial I came across is this one Rendering text I followed the same code, and I get text rendering fine. However the issue ...
1
vote
1answer
56 views

Problem with 2D matrix transform og shapes

I have set myself onto the task of creating a class BaseObject, which represents a graphics object with an associated shape as the member variable shape, which is a pointer an object Polygon. I'll ...
1
vote
1answer
83 views

SDL & OpenGL - Artifacts when multisampling

Im trying to render a model with anialiasing using OpenGL and SDL, but when I do I get strange artifacts. When I render with antialiasing disabled everything looks fine. When antialiasing is ...
1
vote
1answer
41 views

How do I destroy a SDL_Finger pointer?

Hello I'm using SDL with C++ and I got this code: void handleEvents() { SDL_Finger* finger = SDL_GetTouchFinger(SDL_GetTouchDevice(0), 0); } I do not know what SDL does inside the GetTouch ...
-1
votes
1answer
56 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 , ...
0
votes
2answers
26 views

Question about where to put a method [closed]

I'm working on a tower defense game as a class project and i got it to a kinda working level(creep spawns, towers can shoot etc), but i have a problem with my classes. Currently the towers shoot but ...
0
votes
1answer
47 views

How to make a stereoscopic 3D Game with SDL for iOS

I was looking up google for an answer the whole night but didn't find anything. Yesterday I found some VR demos and games on the AppStore, with stereoscopig (dual rendered) screens. So you put your ...
0
votes
1answer
68 views

SDL_PollEvent very slow on SDL2, but works fine on SDL1.2

I have this simple app that displays a screen and handles the quit event: while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { ...
2
votes
1answer
41 views

SDL2 jagged/staircase edges

I am using SDL2 and SDL2 Image to render png images. When I rotate the textures, they turn out very ugly, like this: This is the code responsible for the rotation and alpha mod. SDL_Rect srcRect; ...
0
votes
1answer
65 views

Calculate slope for linear interpolated movement

I want to move rectangles to their targets the "smooth" way with linear interpolation. I hope this is right. float slope(float x1, float x2, float y1, float y2) { return std::abs((y2 - y1)) / ...
1
vote
1answer
72 views

Problem with SLD/OpenGL

I've started to do sth. with SDL/openGL, but I haven't managed to get this tutorial running yet (http://www.sdltutorials.com/sdl-opengl-tutorial-basics). Since this tutorial, or most tutorials at ...
1
vote
2answers
5k views

How to implement SDL Button/Menu GUI with callbacks?

I have been reading Bjarne Stroustrup's Programming Principles and Practice Using C++ for a while now and am nearing the end of the book. I have to tried to make a very simple game using the SDL ...
1
vote
1answer
65 views

Reference keyboard keys as “justPressed”, “pressed”, and “justReleased” with SDL in C++

I'm teaching myself 3D graphics with OpenGL and SDL in C++. I'm at a point where I need to be able to query states of individual keys, like so: if (InputManager::justPressed(SDLK_UP)) {} if ...
1
vote
1answer
545 views

How to pick a 3D object with known mouse coordinates if the camera is rotated 60 degrees?

I am making a simple game engine for a simple RTS game and would like to be able to pick a cube and move it around with the mouse coordinates. The problem is that my camera is rotated 60 degrees just ...
1
vote
1answer
101 views

SDL2 Gamepad triggers trigger when disconnecting the pad

I'm using MonoGame and SDL2. I'm having a strange problem with the Gamepad. When I disconnect it during the game, before the disconnected event fires, the left and right triggers return values as if ...
0
votes
1answer
106 views

Rectangle collision in SDL2 partially allowing sliding C++ [closed]

I am working on a game in SDL2, in which the player needs to be able to slide along walls, but NOT go through them. I've read up on things like Quadtrees, and this stackoverflow question ...
0
votes
3answers
280 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.
0
votes
0answers
86 views

Artifacts rendering high-poly procedural meshes with OpenGL

I am having some issues when rendering some procedural generated meshes. There are some really wierd artifacts when rendering high-poly count meshes (not that much actualy). I have been able to ...
1
vote
0answers
41 views

SDL_Mixer .xm file loop not working correctly [closed]

I am working on a little game in my spare time using C++ and SDL and I have encountered a problem with a .xm file playback. The music is supposed to have an intro of a couple patterns and then ...
1
vote
1answer
135 views

How can I perform a masked erase in SDL2?

I'm trying to implement some shadow/lighting effects in my 2D-project, and I've concluded that if there is an easy way to perform a masked erase on an SDL_Texture, it would make the drawing operations ...
0
votes
1answer
80 views

Memory-leak around SDL_FreeSurface

When I call my tile engine function, the amount of memory my program uses begins to spike at about 80 - 90 megabytes per second. The memory use continues to go up until the program crashes. The ...
2
votes
1answer
111 views

How does the SDL dynamic API inject itself in statically linked code

I've been using SDL2 for development almost since it came out. Long story short, I stumbled upon the SDL dynamic api explanation. I've looked in SDL_Dynapi.c to understand how it works. I get that the ...
3
votes
1answer
207 views

Fighting Game Camera Positioning in SDL

I'm working on a 2D fighting game (using SDL) much like the original Killer Instinct on SNES. I want the camera to keep both players an equal distance from the left and right sides of the viewport. ...
0
votes
1answer
178 views

Why does my modern OpenGL heightmap render as line segments instead of faces?

I'm brand new to OpenGL and have been trying my hand modern openGL. A few days ago, I tried to create some terrain by using a heightmap stored in a grayscale 32-bit BMP. I am using SDL 2.0, GLEW and ...
0
votes
0answers
50 views

C++ Visual Studio Sprite Animation Function only setting values for certain Rect structs in SDL

I'm making a game in SDL and I am using an Array of Rects to store values of sprite sheet clip's dimensions. When I call the function and pass in one of my sprite sheet textures with it's ...
1
vote
1answer
115 views

Input processing performance

I'm building a game using SDL in Linux platform. Now I want to read user input with SDL_GetKeyboardState, but my doubt is wich is the best way using a thread or a timer. I tried both and I think ...
1
vote
0answers
59 views

Prebuilt SDL and dependencies for Android? [closed]

I've spent two days trying to build a Hello World project with SDL2 on Android, and I'm now extremely frustrated. I've followed several guides and tutorials and there's always some header missing ...
3
votes
2answers
2k 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
1answer
114 views

OpenGL segfault in DrawElements

I've asked this question on regular StackOverflow but without much success yet. The below program produces a segfault on the call to glDrawElements. I've looked at my max and min index values and they ...
4
votes
3answers
472 views

SDL Multiple keyboard support

I am making a game with multiplayer split screen mode using SDL. Basically, I like the idea of having each player plug in his own keyboard to the PC, set custom controls via options and being able to ...
1
vote
0answers
136 views

OpenGL - Texture disappears

I'm making a simple program with C++, SDL and GLEW. So far it is going great but I ran into a weird problem. One of my four textures would not show up on screen even though it used the same code as ...
0
votes
2answers
114 views

What is the easiest and fastest way to display an SDL_Surface in a window with SDL2?

I would like to have an SDL_Surface representing the contents of the window, just like in the old days with SDL1.2. What is the best and fastest way to do it in SDL2? What I found is that I need an ...
3
votes
3answers
552 views

Should I cap the frame rate in SDL?

I know this question has been asked a lot, but I never found an answer suitable for me. I have a game with a fairly big logic system and the movement system I am currently using is calling ...
1
vote
2answers
170 views

Why can't I load an image with a relative path in SDL2 on Linux?

When loading a texture in SDL2 the general procedure is this: SDL_Texture* texture = IMG_LoadTexture(renderer, "resources/images/image.png); However this doesn't work and I have to supply the WHOLE ...
2
votes
1answer
158 views

What is missing from SDL for it to gain more widespread adoption? [closed]

As I understand, SDL offers abstractions that let you make windows, handle input and audio much easier than doing so directly with the low level APIs provided by several operating systems. However, ...
1
vote
1answer
388 views

SDL render to a texture

I am trying to create a button for my game there are lots of similar buttons so using an image for each one is a bit inefficient. So I want to load an image then copy some text over it and render that ...
2
votes
1answer
42 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: SDL_Surface* gradient = IMG_Load("blue-cian.png"); then I ...