Newbie C++ Problems

First some info:

SDL 1.2.5
Nvidia Geforce 4 (tried with nv and nvidia drivers)
XFree 4.2.0
Gentoo 1.2 (with everything up to date… i love portage)

I’ve been trying out a simple SDL app using C++ and i’ve been running into
some mysterious problems. I have a class called Video that holds functions
related to blitting, initializing the display, etc. but for some reason all i
get is a window with a black background when i try to display a BMP on the
screen surface. (code snippets at the end) To further complicate matters i
tried running the demo game that comes with the Gameblade C++ framework and i
got the same result. Since all my C SDL apps behave perfectly i’m thinking
that SDL isn’t playing nicely with C++ for some reason. Here’s the code:

The Class=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Video {

public:

Video();
~Video();
int init();
void BlitToScreen(SDL_Surface *);

SDL_Surface *screen;

protected:

int x;
int y;
int depth;
int fullScreen;
int doubleBuf;

};

The Function
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Video::BlitToScreen(SDL_Surface *image) {

SDL_Rect src,dest;

src.x=0;
src.y=0;
src.w=image->w;
src.h=image->h;

dest.x=0;
dest.y=0;
dest.w=image->w;
dest.h=image->h;

SDL_BlitSurface(image,&src,Screen.screen,&dest);

}

How i use it.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Screen.BlitToScreen(image);
SDL_UpdateRect(Screen.screen,0,0,0,0);

… As you may have noticed, i’m slightly new at this so if there’s an
extremely obvious solution that has eluded me (i did check the archives),
then sorry about that.

Any thoughts?

KIRT

are you using dubble buffering and OpenGL?
if so, you should try SDL_GL_SwapBuffers().>From: Kirtis Bakalarczyk <kirtis_b at shaw.ca>

Reply-To: sdl at libsdl.org
To: sdl at libsdl.org
Subject: [SDL] Newbie C++ Problems
Date: Sun, 20 Oct 2002 23:32:11 -0400

First some info:

SDL 1.2.5
Nvidia Geforce 4 (tried with nv and nvidia drivers)
XFree 4.2.0
Gentoo 1.2 (with everything up to date… i love portage)

I’ve been trying out a simple SDL app using C++ and i’ve been running into
some mysterious problems. I have a class called Video that holds functions
related to blitting, initializing the display, etc. but for some reason all
i
get is a window with a black background when i try to display a BMP on the
screen surface. (code snippets at the end) To further complicate matters
i
tried running the demo game that comes with the Gameblade C++ framework and
i
got the same result. Since all my C SDL apps behave perfectly i’m thinking
that SDL isn’t playing nicely with C++ for some reason. Here’s the code:

The Class
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Video {

public:

Video();
~Video();
int init();
void BlitToScreen(SDL_Surface *);

SDL_Surface *screen;

protected:

int x;
int y;
int depth;
int fullScreen;
int doubleBuf;

};

The Function
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Video::BlitToScreen(SDL_Surface *image) {

SDL_Rect src,dest;

src.x=0;
src.y=0;
src.w=image->w;
src.h=image->h;

dest.x=0;
dest.y=0;
dest.w=image->w;
dest.h=image->h;

SDL_BlitSurface(image,&src,Screen.screen,&dest);

}

How i use it.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Screen.BlitToScreen(image);
SDL_UpdateRect(Screen.screen,0,0,0,0);

… As you may have noticed, i’m slightly new at this so if there’s an
extremely obvious solution that has eluded me (i did check the archives),
then sorry about that.

Any thoughts?

KIRT


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


MSN Search, le moteur de recherche qui pense comme vous !
http://search.msn.fr/worldwide.asp