sdl

C++ - SDL not working

I've tried to follow this tutorial on the basics of displaying an image with SDL. But, when I run the program, it returns a blank screen. The image is in the correct directories, but it doesn't display in the program. Am I doing something wrong? I'd really like SDL to work. EDIT Here is my code: #include <SDL/SDL.h> using namespac...

C++: Maybe you know this pitfall?

Hi, I'm developing a game. I have a header GameSystem (just methods like the game loop, no class) with two variables: int mouseX and int mouseY. These are updated in my game loop. Now I want to access them from Game.cpp file (a class built by a header-file and the source-file). So, I #include "GameSystem.h" in Game.h. After doing this I...

SDL_ttf and Numbers (int)

int score = 0; char* fixedscore=(char*)score; . . . imgTxt = TTF_RenderText_Solid( font, fixedscore, fColor ); ^^ This doesn't work - looks like fixedscore is empty or doesn't exists. int score = 0; char* fixedscore=(char*)score; . . . imgTxt = TTF_RenderText_Solid( font, "Works fine", fColor ); ^^ Works fine, but... I guess conver...

Writing JPEG image from BLOB field

Hi, I've got a BLOB field in a MySQL database that I need to fetch and write into a .jpg file. I already know how to query the database and get the result, but I can't write it into a valid .jpg file. Anyone got any help? Thanks ...

Haskell SDL on OS X

SDL on OS X uses preprocessor tricks to overload main() with their own entry point, written in Objective C, which calls the user's main. These tricks make the lives of non-C SDL users (e.g: the Haskell bindings) very difficult. Is there a good reason for this? Why couldn't SDL do the objective-C Cocoa initialization in SDL_init? ...

C++: How to add external libraries

I'm trying to add SVL to my project. Without it I'm getting hundreds of errors (undefined reference...). After adding -lSVL all errors are gone, but gcc says: "cannot find -lSVL". Everything else (SDL, SDL_TTF, SDL_Mixer...) works fine. ...

Drawing list of points in SDL?

If i have an array of coordinates for a path(Such as in a paint program), what is the best way to render the entire path with SDL? I looked at setting pixels individually, but from what i've seen that's a bad idea. I also thought about drawing all the coordinates as SDL_Rect's, but rendering a large list of rect's each frame sounds sl...

when returning by address, doesnt this go out of scope? ( SDL question)

Hi there, this is a code example from lazyfoo's SDL tutorials. SDL_Surface *load_image( std::string filename ) { //Temporary storage for the image that's loaded SDL_Surface* loadedImage = NULL; //The optimized image that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = SDL_LoadBMP( filename.c_str()...

C++: Strange behaviour of `new`

Hi, SDL provides me this struct: typedef struct SDL_Rect { Sint16 x, y; Uint16 w, h; } SDL_Rect; I want to create a new SDL_Rect on the heap as class variable: // Forward declaration private: SDL_Rect *m_pcScreenRect; And in the constructor I do this: /* Screen Rectangle (for clearing) */ m_pcScreenRect = new SDL_Rect...

In SDL, does SDL_Quit() free every surface?

Basically, on surfaces that are going to exist right until the program terminates, do I need to run SDL_FreeSurface() for each of them, or would SDL_Quit() take care of all this for me? I ask mainly because the pointers to a number of my surfaces are class members, and therefore I would need to keep track of each class instance (in a g...

SDL: Performance SPriG vs SDL_gfx

Hi, I need to draw a polygon with thick lines. Now I have two possibilities: Draw them with the library SPriG, which provides line thickness. Split up the polygon in all it lines and draw them as polygons with a modified thickness (like explained in this tutorial (1 tutorial on the page).) with the SDL_gfx library. I'm not sure abou...

SDL support on Android Based and Windows Phone

Where can i find information about Windows Mobile OS or Android.I need to know, if they support SDL or not. Does all android phone support SDL? ...

OpenGL 2d example game

Im beginning to learn SDL and OpenGL to start off game programming. I can load sprites and stuff in SDL but I want to learn to use OpenGL to load sprites and make the sprites move. I cant seem to find a single tutorial on 2D OpenGL game programming. From what I've read there are many advantages to using 2D with OpenGL rather than strictl...

Multiple animation at a time

I'm making a Asteroids game but I can not get to play more than one explosion at a time. Just get to do one at a time ... This is my code I call in the main loop: for(i = 0; i < MAX_SHOTS; i++) { for(j = 0; j < MAX_ASTEROIDS; j++) { if(shot[i].CheckCollision(asteroide[j])) { shot[i].SetPos(-100, 0); ...

Is it possible to create a GetOpenFileName dialog in a fullscreen app?

I have a fullscreen application wrtten in C++ and would like to open a dialog window so the user can select a file to be opened without the app breaking out of fullscreen mode. On Windows, to run in fullscreen mode, I call ChangeDisplaySettings(&settings, CDS_FULLSCREEN). (Technically, I am using SDL, but this is the call it uses.) To ...

In SDL do I need to free the surface if I re-render text?

if I use the following code... message = TTF_RenderText_Solid( font, "Lorem Ipsum", textColor ); Do I need to free message before I can do this message = TTF_RenderText_Solid( font, "Lorem Ipsum part 2", textColor ); i.e. does it give me a new surface (and so I have to clean up the old one) or does it just blit over the old one? ...

SDL + SDL_ttf: Transparent blended text?

Hi, This is a many discussed topic. But after searching for hours, I still could find how to do it... So, what I want is to render an anti-alias string on an SDL_Surface with a given alpha channel. It is possible to render: an anti-alias string with the Blended variant of the string render method. But then I can't make it transparen...

What package should I be using for 2d animation?

I am working with a client on a 2d map. The map is centered on the user's position and marks various headings and points of interest. As the user moves, the headings change and the points of interest move. My client is insistent on using OpenGL for this, but this seems like overkill. He has mentioned he thinks GDI+ and SDL are too slow...

how much c programming should I know before indulging into sdl programming

I have programmed in c and I know about data structures and algorithms, but It has been a while since I programmed in c. I forgot things like how function pointers and some advanced stuff in c work. I want to try graphics programming using sdl. my question is how much of c should I know (for example should I know function pointers) befor...

Calling SDL_SetVideoMode several times

Is it ok to do the following? SDL_Surface* screen; screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE | SDL_RESIZABLE | SDL_FULLSCREEN ); screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE | SDL_RESIZABLE ); screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, ...