Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.
Moderator: Coders of Rage
RandomDever
Chaos Rift Regular
Posts: 198 Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++
Post
by RandomDever » Sat Jun 27, 2009 12:30 pm
Code: Select all
SDL_Surface *image;
image = LoadBMP("mount.bmp");
But every time I compile it it says:
error C3861: 'LoadBMP': identifier not found
WTF?
Bakkon
Chaos Rift Junior
Posts: 384 Joined: Wed May 20, 2009 2:38 pm
Programming Language of Choice: C++
Location: Indiana
Post
by Bakkon » Sat Jun 27, 2009 12:44 pm
Code: Select all
SDL_Surface *image;
image = SDL_LoadBMP("mount.bmp");
MarauderIIC
Respected Programmer
Posts: 3406 Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA
Post
by MarauderIIC » Sat Jun 27, 2009 1:11 pm
You might consider SDL_LoadPNG(), but you need sdl_image headers and stuff.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
RandomDever
Chaos Rift Regular
Posts: 198 Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++
Post
by RandomDever » Sat Jun 27, 2009 2:34 pm
I am only testing (I normally use PNG) and SDL_LoadBMP doesn't work.
BTW Where does the BMP have to be for it to load and what X,Y Coord?
Last edited by
RandomDever on Mon Jun 29, 2009 10:39 am, edited 1 time in total.
eatcomics
ES Beta Backer
Posts: 2528 Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois
Post
by eatcomics » Sun Jun 28, 2009 12:18 am
The bmp has to be in the same folder, unless you tell the compiler its somewhere else... but it'll be easier just to put it in the project folder
RandomDever
Chaos Rift Regular
Posts: 198 Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++
Post
by RandomDever » Sun Jun 28, 2009 9:46 am
ok everything loads by my bmp isn't showing up.
Code: Select all
#include "SDL.h"
#include "SDL_image.h"
#include <string>
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
//Make a temporary rectangle to hold the offsets
SDL_Rect offset;
//Give the offsets to the rectangle
offset.x = x;
offset.y = y;
//Blit the surface
SDL_BlitSurface( source, NULL, destination, &offset );
}
int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
SDL_Surface *image;
image = IMG_Load("mount.bmp");
SDL_Surface *buffer;
bool fullscreen = false;
if ( fullscreen == true ) // For fullscreen
buffer = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE |
SDL_FULLSCREEN );
else // For windowed
buffer = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
// Set window caption
SDL_WM_SetCaption( "My Program : )", NULL );
/* End Initialization */
/* Game loop and such would go here */
apply_surface(20, 20, image, buffer );
SDL_Flip(buffer);
while(1){}
/* Free up space afterwards */
SDL_FreeSurface( buffer );
//Quit SDL
SDL_Quit();
return 0;
}
Bakkon
Chaos Rift Junior
Posts: 384 Joined: Wed May 20, 2009 2:38 pm
Programming Language of Choice: C++
Location: Indiana
Post
by Bakkon » Sun Jun 28, 2009 1:02 pm
Works fine for me. Make sure "mount.bmp" is in the same directory as your executable.
Few other problems you have though. SDL_Quit frees buffer for you, so you shouldn't do that manually, but you should be freeing image. Also, use SDL_Delay(milliseconds) until you've learned how to break out of your infinite loop.
RandomDever
Chaos Rift Regular
Posts: 198 Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++
Post
by RandomDever » Sun Jun 28, 2009 1:28 pm
Here's the image:
Sorry when uploaded it converted into JPEG. But it's 60 x 60 and I'm using VC++ 2008
Last edited by
RandomDever on Mon Jun 29, 2009 10:36 am, edited 1 time in total.
MarauderIIC
Respected Programmer
Posts: 3406 Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA
Post
by MarauderIIC » Sun Jun 28, 2009 5:59 pm
RandomDever wrote: I am only testing normally PNG and SDL_LoadBMP doesn't work.
? That's because you have to load a
bmp with it.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
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:
Post
by dandymcgee » Sun Jun 28, 2009 6:35 pm
MarauderIIC wrote: RandomDever wrote: I am only testing normally PNG and SDL_LoadBMP doesn't work.
? That's because you have to load a
bmp with it.
I think he meant:
RandomDever wrote: I am only testing normally [with a bitmap]. SDL_LoadBMP doesn't work with PNG.
Falco Girgis wrote: It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
RandomDever
Chaos Rift Regular
Posts: 198 Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++
Post
by RandomDever » Tue Jun 30, 2009 9:43 am
OK
Code: Select all
#include "SDL.h"
#include "SDL_image.h"
#include <string>
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
//Make a temporary rectangle to hold the offsets
SDL_Rect offset;
//Give the offsets to the rectangle
offset.x = x;
offset.y = y;
//Blit the surface
SDL_BlitSurface( source, NULL, destination, &offset );
}
int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
SDL_Surface *image;
image = IMG_Load("mount.bmp");
SDL_Surface *buffer;
bool fullscreen = false;
if ( fullscreen == true ) // For fullscreen
buffer = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE |
SDL_FULLSCREEN );
else // For windowed
buffer = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
// Set window caption
SDL_WM_SetCaption( "My Program : )", NULL );
/* End Initialization */
/* Game loop and such would go here */
apply_surface(60, 60, image, buffer );
SDL_Flip(buffer);
SDL_Delay(20000);
/* Free up space afterwards */
SDL_FreeSurface( image );
//Quit SDL
SDL_Quit();
return 0;
}
Mount.bmp:
<object width="425" height="344"><param name="movie" value="
http://www.youtube.com/v/BfqzA2QSVzc&hl ... ram><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="
http://www.youtube.com/v/BfqzA2QSVzc&hl=en&fs=1 " type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>[/youtube]
I'm using VC++ 2008 WTF is wrong?!?!?!?!?!?!?!?!?!
Last edited by
RandomDever on Tue Jun 30, 2009 2:19 pm, edited 1 time in total.
JaxDragon
Chaos Rift Junior
Posts: 395 Joined: Mon Aug 04, 2008 2:03 pm
Current Project: Kanoba Engine
Favorite Gaming Platforms: PS3, PC
Programming Language of Choice: C++
Location: Northeast NC
Post
by JaxDragon » Tue Jun 30, 2009 12:16 pm
Put the image in your Debug folder. Look at my image below.
RandomDever
Chaos Rift Regular
Posts: 198 Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++
Post
by RandomDever » Fri Jul 03, 2009 6:08 pm
View above post
MarauderIIC
Respected Programmer
Posts: 3406 Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA
Post
by MarauderIIC » Fri Jul 03, 2009 6:47 pm
Code: Select all
SDL_Surface *image;
image = IMG_Load("mount.bmp");
if (!image)
return -1;
SDL_Surface *buffer;
Try that (or other output) to make sure that the image is loading correctly. Nothing in your code jumps out at me as being wrong. You might try applying the surface to 0,0 too, just to make sure :P
Also check the return value that BlitSurface gives.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.