Ye Olde Blah

ShiningSource.org => General Programming Forum => Topic started by: Akir on December 04, 2005, 06:02:55 am



Title: Fix this stupid display for SDL!
Post by: Akir on December 04, 2005, 06:02:55 am
I am having one heck of a time with SDL. I've tried everything that I can think of, but I can't get it to even display a simple image! I'm going to just put the source out here, and hope someone knows what the problem is.
(language is FreeBasic.)

Code:
'$INCLUDE: "SDL/SDL.BI"


'init:def
const SCR_WIDTH = "640"
const SCR_HEIGHT = "480"
dim bitmap AS SDL_Surface ptr
dim video AS SDL_Surface ptr

'init:act
SDL_Init ( SDL_INIT_VIDEO )
video = SDL_SetVideoMode( 640, 480, 32, 0 ) 'sets the video mode to 640x480x32

'Init ended
MenuScreen = SDL_LoadBMP("bitmap.bmp")


SUB BlitImage(x as integer, y as integer, image as sdl_surface ptr)
    DIM Rectangle as SDL_Rect
    DIM Rectangle2 as SDL_Rect
   
    Rectangle.x = 0
    Rectangle.y = 0
    Rectangle.w = image->w
    Rectangle.h = image->h
    Rectangle2.x = x
    Rectangle2.y = y
   
    SDL_BlitSurface image, @Rectangle, ScreenSurface, @Rectangle2
   
   

END SUB

SLEEP 1000

SDL: SDL_Quit ()


Title: Fix this stupid display for SDL!
Post by: Ty on December 04, 2005, 12:08:58 pm
I can see a few:

1) BlitImage is never called. You need to call it in your main display loop. If it's never called, nothing will happen.
2) I can't find the main display loop. Related to above. This is the place where the BlitImage functions would be called.

You might want to check out the examples in the examples/SDL folder. In particular, image_test1.bas seems to have what you're looking for. It has a good example of a main display loop, and also shows how to double buffer. It's certainly a much better example than the tutorial you got this code from ;)


Title: Fix this stupid display for SDL!
Post by: Devlyn on December 04, 2005, 06:17:55 pm
Actually, this language looks 00gly :s

Like Basic and stuff :s


Title: Fix this stupid display for SDL!
Post by: Rockin Needlepin on February 27, 2006, 07:50:01 pm
Kill the bastich