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
0answers
54 views

C++/OpenGl/SDL/Cmake Beginner curiosity [on hold]

and this is my first time in this forum. I just want to ask for an advise in here, I just dont know where to start. hopefully you can understand and help me. I want to start with a small game project ...
0
votes
1answer
32 views

Zooming In SDL 2.0

I'm currently working on a project in which I render pictures raw. That is I use simple IMG_LoadTexture(), SDL_RenderCopy(). I want the program to be able to zoom in/out and textures to be scaled to ...
1
vote
1answer
20 views

SDL.NET no longer detecting modifier keys

I'm using SDL.NET with C#. Recently, a bug has appeared where the library does not detect if the shift key is held down; although it used to do so. private static void KeyboardEventHandler(object ...
0
votes
0answers
14 views

Strange offset when accessing pixels from an SDL surface

I am using a routine to map a triangle from one surface to another. The problem is that the function below chooses the correct pixel to draw on the destination surface, but the pixel selected from the ...
0
votes
0answers
60 views

Creating A Selectable Object in SDL/C++

I'm trying to create a clickable object. I wrote a pseudo code to try it. When I add a new member to object it works fine, that is when I hold the mouse cursor on the rectangle determined it returns ...
1
vote
3answers
169 views

2D Rendering Based On Y Coordinates

I'm trying to build an RPG worldbuilder. I have seperate classes for images. Like this. Object1::Object1(int x, int y, CSDL_Setup *sdl_set, int *p_CamX, int *p_CamY) { X_pos = x; Y_pos = y; ...
0
votes
2answers
64 views

Getting if a key was released/pressed this frame (C++/SDL2)

Getting if a key is currently down is easy. Just return keys[scancode]: switch (ev.type) { case SDL_KEYDOWN: keys[ev.key.keysym.scancode] = true; break; case SDL_KEYUP: ...
0
votes
1answer
53 views

How to use traditional pixel coordinates system in OpenGL? (with C++/SDL2)

I find the normalized, centralized coordinate system used in OpenGL weird and annoying, is there anything I can do at all to make it work like normal pixel coordinates on everything ever except ...
1
vote
1answer
93 views

Pathfinding with differently-sized objects on tile map [duplicate]

It's my first RTS game and I'm having trouble finding out how to make infantry take less space than tanks. Right now I have 1 tank and 1 infantry type ready with sprites, pathfinding, selection and ...
-2
votes
1answer
116 views

Porting SDL OpenGL Game to Android and IOS

I am currently learning OpenGL (3.0+) with C++. I am using SDL for input handling, window creation, etc., GLEW to use OpenGL and call OpenGL Functions, and GLM for OpenGL Math stuff. If I fully ...
1
vote
1answer
42 views

Fastest way to render image data from buffer

Currently I am doing my rendering by using a 3D array window_width x window_height x rgb as a buffer, then looping through the buffer and plotting pixels on screen using SDL2 (SDL_RenderDrawPoint). I ...
1
vote
1answer
72 views

Keyboard input vs character movement encapsulation

In our game created with c++ and sdl we are having difficulty delegating how the main character should be controlled. We have a keyboard class and a sprite class for the main character, but are ...
1
vote
0answers
58 views

Entity to tile collision detection (C++, SDL)

I'm currently trying to handle collisions between entities and a tilemap, but I've hit a problem. My tiles are stored simply as integer tile IDs in a multidimensional array, and I wanted to perform a ...
0
votes
1answer
29 views

Bouncing projectile off of sprite, the sides work but top and bottom do not

I'm having a problem bouncing a projectile off a sprite, we've been asked to move the projectile using the equations of motions which makes things a little more difficult but as far as I can see what ...
1
vote
1answer
92 views

Should I cull off-screen objects in SDL2

My game will have a large number of objects moving offscreen at any given time, can i just render them all with SDL_RenderCopy even though they are off screen or should I only render them if they are ...
1
vote
0answers
41 views

Passing an SDL KeyboardState(Uint8*) to Lua

I'm working on my first big project and I've decided to integrate Lua with my C++ framework. Everything's worked out so far, but the only way I've managed to pass the SDL_GetKeyboardState(NULL) array ...
1
vote
0answers
62 views

SDL_Mixer - Mix_LoadWav_RW returns NULL (Unrecognized sound file type)

I am loading sounds from resource file (Doom2.wad from game Doom 2: Hell on Earth), converting them into WAVE and then trying to play them using SDL_Mixer. If I save the converted sound into a .wav ...
0
votes
1answer
98 views

Is this a good way to regulate fps?

In all of my tests I always regulate the fps by using this method. const int fps = 30; const int msPerFrame = 1000/fps; // 33 ms per frame, so it's more like 30.3030 fps while(true) { const int ...
0
votes
1answer
46 views

Box platform collision

I'm working on a platform game and my collision code is to picky. I can't exactly do aabb(?) because the map is represented as metatiles. (23-24 16x16 tiles make up a 300ish pixel resolution.) My game ...
1
vote
2answers
102 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 ...
0
votes
0answers
52 views

SDL — What am I doing wrong with SDL_LockTexture()?

I'm trying to use SDL_LockTexture and SDL_UnlockTexture for direct access to pixels in SDL 2.0. When I try to set pixels, I never see anything happen. Here's my code: void *pixels; int pitch; ...
0
votes
1answer
102 views

SDL pixel access very slow

I'm using SDL and need to plot pixels one by one on the screen. When I do this, it's extremely slow. I followed the tutorial here: http://www.programmersranch.com/2014/02/sdl2-pixel-drawing.html ...
0
votes
1answer
90 views

Redefining the SDL rect struct

Upon checking the docs of SDL (1.2) I saw that the SDL_Rect struct defines the x and y as Sint16. I'm making a bitmap font text scroller and I need those specifically to be unsigned ints because the ...
0
votes
0answers
57 views

Pixel buffers in SDL

I'm using SDL and c++ and trying to create a class to work on pixel basics. The buffer is a multidimensional char array. char buff[scW][scH]; The video mode is being set by a ...
1
vote
2answers
151 views

Are SDL games trivially portable from Linux to Windows?

I have a small game made with SDL2 and I want to port it to Windows. Would I hav eto write a lot of #ifdefs to port it or will the very same code work on Windows and Linux? Or is it more complicated? ...
1
vote
1answer
188 views

How do I implement a fixed delta time step with a SDL_Delay(15ms) precision

So I am using SDL2.0 for making a Game Engine. Where I am having a problem is using SDL_Delay(). SDL_Delay's minimum delay time is 15ms, I've tried everything, and my FPS is Stuck at 64 because of ...
0
votes
2answers
183 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 * ...
3
votes
1answer
269 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
31 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 ...
1
vote
1answer
93 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 ...
1
vote
1answer
74 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 ...
0
votes
2answers
64 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 ...
2
votes
1answer
317 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
160 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
55 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
119 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 , ...
1
vote
1answer
205 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 ...
0
votes
2answers
28 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
112 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 ...
3
votes
2answers
190 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
votes
2answers
137 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> ...
0
votes
2answers
110 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
1answer
183 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 ) { ...
3
votes
1answer
78 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
114 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
108 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
1answer
111 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
3answers
293 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
1answer
152 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
0answers
134 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 ...