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
31 views

Setting up SDL with Visual Studio 2015 [closed]

I am trying to enter the community of game devs. I have found SDL2 to be a helpful tool. However, I can't figure out how to get it to work in Visual Studio 2015 (community). Can you tell me how to do ...
0
votes
3answers
84 views

Cannot load png images to textures with SDL2 in Visual Studio 2015

I'm learning SDL2 with Visual Studio 2015 and I'm trying to draw a 16x16 level with a .map file and 32x32 .png images for tiles (that's 256 tiles) on a 512x512 window. I have both SDL2 and SDL2 Image ...
0
votes
1answer
25 views

SDL Combining text and Geometry Rendering to one texture

Basically I'm trying to end up with a Texture class that can take in text and have it be drawn over simple geometry (such as a letter 'A' over a filled rectangle). However I'm running into issues when ...
1
vote
1answer
75 views

Fixed-Timestep still updating too fast

I'm trying to figure out if I'm approaching my simple fixed-timestep implementation correctly, following examples such as: Gaffer (without RK4), and DeWitters Currently, I have a game object which ...
0
votes
0answers
16 views

How to parse a and displat TMX map object in SDL using tmxparser ?/How to make a platform game using tiled editor and SDL?

I am newbie in this field getting too much trouble in simple platform game for one of my project module if you guys could help or share some code. This is what I have done till now. I could parse a ...
-4
votes
1answer
57 views

Can we port any game written in C++ with SDL to Android platform or we would need to change some codes too? [closed]

Just wanted to lean a cross-platform library!! Since SDL library supports iOS too..
0
votes
1answer
45 views

SDL2 and density-independent pixel

I'm currently using SDL2 on Android and that's my first experience with that library (to be honest, mainly chosen because I'd like to learn it). What is puzzling me is how to deal with different ...
1
vote
1answer
107 views

Why does SDL_RenderCopy result in a blank screen?

I'm trying to render a texture(picture), but SDL_RenderCopy keeps the window's background black. Here's the relevant code: SDL_Rect rect; rect.x = 0, rect.y = 0; while(!quit) { ...
1
vote
1answer
80 views

Version 320 is not supported, SDL C++

I have the following four lines before I create the window. SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); ...
1
vote
0answers
46 views

SDL-2.0 library not working with codeblocks-13.12-mingw-tdm [closed]

I started following lazyfoo's sdl 2.0 tutorials. This is the very first tutorial that explains how to set up SDL 2.0 with code::blocks - SDL 2.0 with code::blocks setup. I am doing exactly what it ...
2
votes
1answer
75 views

OpenGL not rendering textures

i'm using OpenGL 2.1 with SDL2.0 and i'm trying to render a texture, using this steps: load the image: Image* image = new Image(); image->image = SDL_LoadBMP(path.c_str()); if ...
3
votes
1answer
106 views

How can I separate processing input and update?

I know that game loop is broken up into three distinct phases: processing inputs, update, and render, but I just can't see how I can make processing input and update independent of each other. Let's ...
2
votes
0answers
120 views

OpenGL textures make very low fps

I loaded some textures just one time before I go to my mainloop(glutMainLoop). I am using SDL for the texture loading. However, when I compile, my game is running at 6-10 fps. When I don't load the ...
2
votes
1answer
114 views

How to calculate delta time with SDL?

I have heard that you can calculate delta time with two functions called SDL_GetPerformanceCounter and SDL_GetPerformanceFrequency. I'm not sure how they work completely, but I heard it is a bit ...
1
vote
2answers
117 views

OpenGL SDL Texture doing really weird things

I am trying to render a .png image to the screen using C++, SDL and glut. This the texture I made using paint This is what I get on the screen: Does anyone have an idea what could cause this? ...
2
votes
1answer
79 views

Texture Not Rendering in C++ SDL OpenGL(glut)

I don't understand why my texture("texture.bmp"), is not showing on the screen. Please help me. The whole drawing function: ///HERE EVERYTHING IS BEING RENDERED void Main::display(){ int ...
4
votes
0answers
64 views

OpenGL: Frame partially jumps back and forth

I'm working on a project with SDL and OpenGL. The game works great on Windows, Linux, OS X and iOS. However, the Android version is showing a problem on my phone in particular. I have tested another ...
2
votes
2answers
66 views

Unable to move character to right position using SDL?

I am currently having problem moving a character right and showing him like he's running but after i press right key it moves right for one time and then when i enter left it goes left again but ...
1
vote
1answer
96 views

Why am I getting these artifacts when rendering polygons with OpenGL and SDL from far distance?

I'm working in a toy BSP (quake3 version) renderer. I started creating the context and handling the input with GLFW but then I switched over SDL. The performance change was amazing with SDL leading ...
0
votes
1answer
62 views

Handling input in ECS for multiple characters

I've been reading into Entity-Component-Systems, and they seem rather handy. However, I don't quite understand how input should be handled and after googling and looking thru GDSE posts, I've become ...
0
votes
1answer
76 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
37 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
28 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
102 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
199 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
114 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
166 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
141 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
801 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
86 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
107 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
1answer
111 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
35 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
165 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
1answer
93 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 ...
0
votes
1answer
125 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
49 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
142 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
1answer
179 views

How do I modify textures in SDL with direct pixel access?

I'm trying to use SDL_LockTexture and SDL_UnlockTexture for directly editing pixels in a texture. I'm using SDL 2.0. Setting the pixel value using the following code doesn't modify the texture: void ...
0
votes
1answer
161 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
153 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
84 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
204 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
370 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
319 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
545 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
35 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
212 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
96 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
69 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 ...