So I'm making a little GUI box that holds an integer and based on that integer it blits a certain amount of images.
However i want all the images to be applied to a SDL_Surface *buffer before being blitted to the screen.
But every time I do that it gives me some random access violation.
Is what i'm trying to do possible?
If so how?
Thanks in advance for any provided help.
SDL HUD Problem
Moderator: PC Supremacists
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
SDL HUD Problem
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
- hurstshifter
- ES Beta Backer
- Posts: 713
- Joined: Mon Jun 08, 2009 8:33 pm
- Favorite Gaming Platforms: SNES
- Programming Language of Choice: C/++
- Location: Boston, MA
- Contact:
Re: SDL HUD Problem
Everything is possible...RandomDever wrote: Is what i'm trying to do possible?
If so how?
Post some code dude, we need a little more to help you out with this.
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
http://www.thenerdnight.com
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: SDL HUD Problem
Just out of curiosity, why would want this? The only two reasons I can think of is to either save the intermediate surface if it won't change in the future, or you're attempting double buffering. In the case of the former, we definitely need to see some code before we can attempt to troubleshoot. In the case of the latter, SDL has double buffering built in, just enable it.RandomDever wrote:However i want all the images to be applied to a SDL_Surface *buffer before being blitted to the screen.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: SDL HUD Problem
Well i will post some code but first an explanation of why.
I want to have images display a count of for instance bullets that the player has in his clip.
But I also want it centered within an SDL_Rect and I already have a function for getting a surface centered withing a Rect.
And the only way I can think of doing that is blitting as many images I need to a buffer and then center blitting the buffer.
But here's the problem:
When I try to do that it fives me some error.
I hope my response was adequate.
I want to have images display a count of for instance bullets that the player has in his clip.
But I also want it centered within an SDL_Rect and I already have a function for getting a surface centered withing a Rect.
And the only way I can think of doing that is blitting as many images I need to a buffer and then center blitting the buffer.
But here's the problem:
Code: Select all
//SDL_Rect temp;
//SDL_Surface *dataType;
//SDL_Surface *dataBuffer;
//int dataNum;
//dataType is loaded with the image to display and dataNum is passed a number in the update function.
for( int i = 0; i < dataNum - 1; i++ )
{
temp.x = 0 + ( dataType->w * i );
temp.y = 0;
SDL_BlitSurface( dataType, NULL, dataBuffer, temp );
}
I hope my response was adequate.
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
Re: SDL HUD Problem
Simple, dataBuffer is never initialized
use:
before any function calls to dataBuffer
use:
Code: Select all
dataBuffer=SDL_CreateRGBSurface(SDL_SWSURFACE,width,height,bpp,0,0,0,0);
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: SDL HUD Problem
Code: Select all
dataBuffer = SDL_CreateRGBSurface( SDL_SWSURFACE | SDL_SRCCOLORKEY, ( dataType->w * data ), dataType->h, 32, 0, 0, 0, 0 );
SDL_FillRect( dataBuffer, NULL, SDL_MapRGB( video->screen->format, 255, 0, 255 ) );
SDL_SetColorKey( dataBuffer, SDL_SRCCOLORKEY, SDL_MapRGB( video->screen->format, 255, 0, 255 ) );
Yeah I don't know why I thought I could blit to a null pointer but yeah. Thanks.
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip