I am new to FreeBasic but not programming. I have been re-coding a gaming engine and I have encountered a curious problem.
I use internal DIBs to hold all my sprite animations and graphics. (I use this instead of the GFX library because (1. I am more comfortable with them, 2. I can use all the Windows GDI functions like StretchBlt which can both scale objects and will convert pixel formats automatically.)
Anyway, all my graphics are 24bit RGB and I set the screen to 800x600x24. I composite all my sprites onto an internal 24bit image buffer and them use ScreenPtr to copy the image to the screen.
The problem is the final image does not display properly but rather I see 4 copies next to each other with mixed colors and raster lines. This usually means the display surface is not a match for the image data.
I know the data is correct because when I save it to a BMP on the disk it displays fine.
So is the screen really at 800x600x24? Am I setting the display incorrectly?
Code: Select all
#Define ScreenWidth 800
#Define ScreenHeight 600
Dim wPage As Integer = 1
Dim vPage As Integer = 0
ScreenRes ScreenWidth, ScreenHeight, 24, 2
ScreenSet wPage, vPage
Do
ScreenLock
pScreen = ScreenPtr
If pScreen>0 then
MoveMemory pScreen, BackBuffer.pbits, ScreenBytes
ScreenUnLock
endif
Swap wPage, vPage
Screenset wPage, vPage
Loop While Inkey=""
Screen 0
DestroyMemoryBitmap (BackBuffer)
'***************************