SDL wont work
im working under mandrake 10.0 under kdevelop.
my code will compile but for some reason tha is unknown to me it SDL_LoadBMP just wont work.
heres my code:
/* Simple blitting with SDL */
#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
SDL_Surface *screen;
SDL_Surface *image;
SDL_Rect src, dest;
/* Initialise and check for errors */
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
printf("Could not initialise SDL: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* Ensure SDL_Quit is called when the program ends */
atexit(SDL_Quit);
/* Attempt to set a 1024 x 768 32 bit video mode. */
screen = SDL_SetVideoMode(1024, 768, 32, 0);
if (screen == NULL)
{
printf("Could not set video mode: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* Load the bitmap file. */
puts("got to image load");
image = SDL_LoadBMP("camp.bmp");
if (image == NULL)
{
printf("Unable to load bitmap\n");
exit(EXIT_FAILURE);
}
/* Setting the Rect's */
src.x = 0;
src.y = 0;
src.w = image->w; // copy the entire image
src.h = image->h;
dest.x = 0;
dest.y = 0;
dest.w = image->w;
dest.h = image->h;
/* Blit the bitmap to the screen. */
SDL_BlitSurface(image, &src, screen, &dest);
/* Ask SDL to update the entire screen */
SDL_UpdateRect(screen, 0, 0, 0, 0);
/* Pause for a bit */
SDL_Delay(3000);
/* Free memory */
SDL_FreeSurface(image);
}
it also gives mt the following error -
Xlib: extension "GLX" missing on display ":0.0"
Xlib: extension "GLX" missing on display ":0.0"
any help ?
Well, your missing return 0; at the end of int main, and I don't see any declaration of LoadBMP.
October 17, 2004 10:25 AM
What do you mean by "it won't work"?
If yout program doesn't start, you could try to replace this line:
screen = SDL_SetVideoMode(1024, 768, 32, 0);
with this one:
screen = SDL_SetVideoMode(1024, 768, 0, 0);
If yout program doesn't start, you could try to replace this line:
screen = SDL_SetVideoMode(1024, 768, 32, 0);
with this one:
screen = SDL_SetVideoMode(1024, 768, 0, 0);
what i mean by it dosen't work is that it dosent diplay the picture.
for output it write's :
got to image load
unable to load bitmap
which means that everything's good but the LoadBMP function.
for output it write's :
got to image load
unable to load bitmap
which means that everything's good but the LoadBMP function.
try:
screen = SDL_SetVideoMode(640, 480, 0, SDL_ANYFORMAT);
screen = SDL_SetVideoMode(640, 480, 0, SDL_ANYFORMAT);
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Quote: Original post by teamonkey
What does SDL_GetError() tell you?
Behold the power of google/cheese
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement