sdl

Is the callback function in SDL_Audio_Spec called SDLAudio_Spec.freq times a second?

Is the callback function in SDL_Audio_Spec called SDLAudio_Spec.freq times a second? ...

play a waveform at a certain frequency in SDL callback function

I have a waveform 64 samples long. If the sampling rate is 44100 hz, how can I play(loop) this waveform so that it plays arbitrary frequencies? frequency = samplerate / waveform duration in samples Therefore the frequency should be 689hz(44100/64). If I wanted it to be say, 65.41hz(C-2), I would have to do this: 65.41 = 44100 / x Sol...

What is the proper way to use GFX rotozoomSurface with SDL for drawing transparent sprites?

I'm using the latest SDL/GFX libs on Fedora 10 and I'm trying to render a PNG or GIF image onto the screen surface. I could not get transparent PNG's to display at all so I replaced the transparent parts or my sprite with all white (and tried Magenta 255,0,255). The white-transparent PNG displays fine using this code: SDL_Surface *image...

Setting up a camera in OpenGL

I've been working on a game engine for awhile. I've started out with 2D Graphics with just SDL but I've slowly been moving towards 3D capabilities by using OpenGL. Most of the documentation I've seen about "how to get things done," use GLUT, which I am not using. The question is how do I create a "camera" in OpenGL that I could move...

What 3D graphics framework should I use for a real world game engine?

Hello, I'm a C++ programmer with very extensive server programming experience. I'm however fairly bored at the moment and I decided to tackle a new area: 3D game programming, for learning purposes. Additionally I think this learning project may turn out to be good resume material in the future should I decide to work in this area. Inste...

SDL_image/C++ OpenGL Program: IMG_Load() produces fuzzy images

I'm trying to load an image file and use it as a texture for a cube. I'm using SDL_image to do that. I used this image because I've found it in various file formats (tga, tif, jpg, png, bmp) The code : SDL_Surface * texture; //load an image to an SDL surface (i.e. a buffer) texture = IMG_Load("/Users/Foo/Code/xcode/test/lena.bmp")...

How do I correctly use SDL_FreeSurface when dealing with a vector of surfaces.

I have setup a small shooter game as a tutorial for myself in SDL. I have a struct of a projectile struct projectile { SDL_Surface* surface; int x; int y; }; And I put that into a vector. vector<projectile> shot; projectile one_shot; And when I press space I create a new projectile and add it to the vector and then they...

easiest way to port an SDL-1.2-based game to iPhone

I have a SDL-1.2 based game and I want to port this to the iPhone so I want to ask about the easiest way. I am working on MacOSX and have already the iPhone SDK by Apple (so I guess the iPhone Toolchain is not the right thing for me as I am using MacOSX). I know there is the iphone-sdl-1-3 project but I wonder if that is the only SDL po...

SDL_Event.type always empty after polling

I have a general function that is supposed to handle any event in the SDL event queue. So far, the function looks like this: int eventhandler(void* args){ cout << "Eventhandler started.\n"; while (!quit){ while (SDL_PollEvent(&event)){ cout << "Got event to handle: " << event.type << "\n"; switch (event.type){ ...

C lib with Python bindings where both want to render

I'm sketching on some fluid dynamics in Python. After a while, I'm looking for a bit more speed, so I rewrote the actual logic in C and put up some Python bindings (using SWIG). My problem now is that I don't how to render it in a good way. The logic is run pixel by pixel so pixels are what I want to track and render. Python gives my a...

Crash when utilising a std:map

In my SDL program, I am using a map construct to simulate an "infinite" array of objects within a certain class. The code manages to compile fine, but when I run the program, as soon as one of the functions using the maps is trigger, the program crashes, returning a value of 3. So, here's exactly what I'm doing: class MyClass { pu...

Simulated time in a game loop using c++

I am building a 3d game from scratch in C++ using OpenGL and SDL on linux as a hobby and to learn more about this area of programming. Wondering about the best way to simulate time while the game is running. Obviously I have a loop that looks something like: void main_loop() { while(!quit) { handle_events(); D...

how to use SDL in linux?

The linux server at my school is just a bare-bone server, no x-windows, just a command line interface. I tried to make a graphical c program on that server but found much difficulties. I use SDL library but every time compiling with gcc, it complains: testcursor.c:(.text+0x1ad): undefined reference to SDL_Init' testcursor.c:(.text+0x...

How do I determine if an indexed mode SDL_Surface has transparency or not?

I've got code I've been working with to load and convert SDL_Surfaces to OpenGL textures, however I've realized that they only work with RGB(A) surfaces. I need to extend the support onto indexed mode images (with or without transparency). Initially, I was looking into ::SDL_SetColorKey(), however it seems to only work with SDL blits. I...

How to create an SDL pop up menu ?

Hi, I've seached around how to create a pop up menu in a SDL window application using c++ ? I haven't found any clues ! I would like to have something that looks like this : http://www.youtube.com/watch?v=Mc%5FCE9OiHvA I've tried to use glutMenu, but it doesn't work ... Thanks ...

Compiling SDL on OS X with makefile

I'm trying to compile the tetris program I wrote with C++ and SDL on OS X. First I tried doing this: `g++ -o tetris main.cpp `sdl-config --cflags --libs` -framework Cocoa` and got this: Undefined symbols: "Game::startGame()", referenced from: _main in ccQMhbGx.o "Game::Game()", referenced from: _main in ccQMhbGx.o ld:...

Alpha Blending in SDL

I'm trying to find the most efficient way to alpha blend in SDL. I don't feel like going back and rewriting rendering code to use OpenGL instead (which I've read is much more efficient with alpha blending), so I'm trying to figure out how I can get the most juice out of SDL's alpha blending. I've read that I could benefit from using har...

Compiling SDL Games on Mac

I have a mac and I am trying to compile my projects. The standard on the wiki: g++ sdl.cpp -lSDLmain -lSDL -framework Cocoa does not seem to be working it returns that it cannot find -lSDL and -lSDLmain. Any help would be greatly appreciated. ...

Linking to SDL and other libraries in Haskell

How to tell ghc to tell ld to link compiled binaries to SDL library? I have a source.hs : import Prelude import Graphics.UI.SDL as SDL import Data.Maybe import GHC.Word import Control.Applicative ... When I do: ghc source.hs I get a bunch of linking errors similar to this one: pong.o: In function `...

Magick++ animation generation via SDL pixel data

I'm trying to generate ImageMagick images from SDL pixel data. Here's what the GIF looks like so far. (This GIF is slower than the one below on purpose.) Here's what it's supposed to look like. Notice in the above image that the pixels seem to be overlayed on top of other pixels. Here's where the GIF is actually created. void Drv...