Jump to content
  • Advertisement
Sign in to follow this  
lightkuragari

SDL wrapper problem

This topic is 2749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, everyone! this is my first post ever at gamedev.net.

I've known this page for some time now but never actually registered.
Now i have a big doubt about writing a C++ wrapper for SDL.

I wrote this code as a test:

=================================
#include <iostream>
#include <SDL/SDL.h>

using namespace std;

class Proto {
public:
Proto(){
}
virtual ~Proto(){

}
static int initialize(){
int result = SDL_Init(SDL_INIT_VIDEO);
return result;
}
};

int main(int argc, char* argv[]) {

Proto::initialize();

cout << "SDL Initialized!!!" << endl;
return 0;
}
====================================================

However, when i debug and step into Proto::initialize,
the program just freezes in SDL_Init.

If i call SDL_Init directly from the main() function
there's no problem. But if i encapsulate it in another class
whether in a static function or non-static member function,
it doesn't work.

If i continue execution, it never ends. I have to terminate it.

If i just execute the resulting binary(not debug) it starts
and ends without error message from console.

The message is never printed on screen.

What is going on? I'm doing this in eclipse on windows and mingw32.
Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Have you tried using a singleton with lazy initialization? I think that SDL redirects the call to main at the start of the program so it might be related to that.

Share this post


Link to post
Share on other sites
Hi, storyyeller. Thanks for your answer. That's something new to me. Singleton and lazy initialization. Not sure how one implements that, though i read this
(C++ example part).

http://es.wikipedia.org/wiki/Singleton

However, i took my code in a linux VM and guess what? No problems with Linux GCC.
I also compiled my code under Visual C++ 2010 Express, and no problems either.

So i'm starting to think theres something wrong with my Mingw32 config, or with the compiler itself.

What do you think?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!