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
4 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
16 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
36 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
52 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
34 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
101 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
46 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
1answer
57 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
125 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
29 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
0answers
45 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
61 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
48 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
67 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
66 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
45 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
70 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
98 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
27 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
55 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 ...
2
votes
2answers
88 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 ...
0
votes
2answers
74 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
75 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
85 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
46 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
72 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
77 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
75 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
2answers
146 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
114 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
91 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
42 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 ...
0
votes
1answer
84 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
120 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
224 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
188 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
55 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
118 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
61 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 ...
0
votes
1answer
119 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 ...
1
vote
0answers
137 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
128 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 ...
1
vote
2answers
201 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
446 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
46 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 ...
0
votes
2answers
63 views

Is it possible to use an image, sound or font without importing them externally? [SDL2]

It's hard to explain my question, but I will try my best. When loading sounds, images or fonts in SDL2 (with SDL_image, SDL_mixer, SDL_ttf) you need to load them from an external source path. For ...
-1
votes
1answer
294 views

Is SDL2 alone capable of dynamic (or deferred) lighting? [closed]

I'm talking about JUST SDL2, not OpenGL or DirectX. Would drawing deferred lighting bulk the CPU up and how would it be done?
0
votes
1answer
654 views

Scaling an SDL Surface

I want to create a button for a game's UI. The background uses a gradient and then I blit a surface on top of the gradient and use SDL_SetColorKey to delete the unwanted pixels. The surfaces are not ...
2
votes
0answers
64 views

SDL_AddTimer + SDL_GL_MakeCurrent not working on Windows [closed]

I'm messing around with C++, OpenGL and SDL doing a game that should be able to run in Windows and Mac OS X. I have a problem that only happens on Windows. Let me describe the scenario. First I ...