Questions tagged [sdl]

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.

Simple DirectMedia Layer 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.

SDL is written in C, but works with C++ natively, and has bindings to several other languages, including Ada, C#, D, Eiffel, Erlang, Euphoria, Go, Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, Pike, Pliant, Python, Ruby, Smalltalk, and Tcl.

429 questions
11
votes
1 answer

In SDL, what is the difference between using a Surfaces and a Renderer?

I am new to SDL and I've been following some tutorials; in one tutorial he used Surfaces (a window surface and image surface) and a BlitSurface function to draw images without using any renderer (used SDL Image library for JPG, PNG etc.). And in…
alexmoran
  • 111
  • 1
  • 3
10
votes
1 answer

SDL blitting multiple surfaces at once

I'm trying to write a platforming game where the sprites for the level backgrounds are broken up into 512x512 chunks. I keep 3 chunks in memory at a time and I'm trying to write code to blit all three to the screen. Here is the current code I…
n s
  • 603
  • 1
  • 6
  • 17
4
votes
2 answers

How to simply print (write) text on a Surface in SDL.NET?

as i told in previous question, i'm using SDL.NET (wrapper in C# of SDL). Unfortunately the API website is down so i'm trying to learn it by myself. I would like simply to print text on my screen / surface ... i don't know how to do! My goal is to…
stighy
  • 417
  • 6
  • 30
  • 60
3
votes
1 answer

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

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, it seems that a lot of games, both indie and AAA,…
2
votes
1 answer

SDL_GameController automatic detection

Here's something that's been bugging me all day: Controller detection in SDL. First thing is that it doesn't automatically detect when a controller is connected. Finding out when a controller is disconnected is no problem: if(joystick.closed > 0) {…
user39686
2
votes
2 answers

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 - but it doesn't seem to do this. Anybody know how it…
1
vote
1 answer

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 start = SDL_GetTicks(); // do stuff const int…
1
vote
1 answer

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 resolve this issue.
biz14
  • 115
  • 1
  • 5
1
vote
1 answer

Do SDL surfaces get reused?

In SDL, lets say I'm rendering text to a surface. Then I blit it with the scene's main surface to form a composite image to flip. I get the text surface into a class-level member called 'messageSurface': messageSurface = TTF_RenderText_Solid( .....…
Mossen
  • 247
  • 1
  • 9
1
vote
1 answer

SDL surface inside another GUI component?

Is there a way to host an SDL surface inside another GUI component so that SDL is not at the top-level? For instance, could I put an SDL surface inside a Java JPanel or other widget?
Mossen
  • 247
  • 1
  • 9
1
vote
2 answers

Can I create a SDL_Surface as I do with Allegro?

Using allegro I can create a Bitmap to draw just doing: BITMAP* bmp = NULL; bmp = create_bitmap(width,height); // I don't remember exactly the parameters I'm using SDL now, and i want create an SDL_Surface to draw the game level (that is static). I…
1
vote
2 answers

Why do I get a segmentation fault on launch with this code?

I am currently writing a pong clone in C++ with SDL on top. Currently, I have hit a roadblock. If I add a new variable, my game won't launch, and will give "segmentation fault" in the debug terminal. When I comment out a variable, the following code…
earboxer
  • 121
  • 1
  • 3
0
votes
1 answer

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 thus far simply takes the player's x/y coords…
0
votes
2 answers

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 text does need to go offscreen, yet still using…
0
votes
1 answer

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 ) { quit = true; } } If I compile this…
LachoTomov
  • 101
  • 3
1
2