Scrolling using bitmap in memory

Advanced game related topics
Alberto
User
User
Posts: 25
Joined: Mon May 19, 2003 4:59 pm

Scrolling using bitmap in memory

Post by Alberto »

Hallo,

I'm new to PureBasic and OpenGL.
I've just done some 2D graphichs in OpenGL based on some examples founded here.
Now I thought to realize a scroll of this 2D graphics by using OpenGL that render to a bitmap in the computer memory (not the video graphics memory).
When I have to scroll the screen I move the bitmap in the computer memory without re-rendering the all 2D scene. Then I only re-render the new strip and not the entire screen.

Is this a good idea or is silly? (I'm new to OpenGL)

The bitmap that I point with OpenGL is a 600+600 pixel with 24bit

punt_bmp = AllocateMemory(#Mem_Bmp ,600*600*3+54,0)
;BitmapFileHeader
PokeW(punt_bmp,19778)
PokeL(punt_bmp+2,600*600*3+54)
PokeW(punt_bmp+6,0)
PokeW(punt_bmp+8,0)
PokeL(punt_bmp+10,54)
;Bitmpafileinfo
PokeL(punt_bmp+14,40)
PokeL(punt_bmp+18,600) ;Width
PokeL(punt_bmp+22,600) ;Height
PokeW(punt_bmp+26,1) ;Planes=1
PokeW(punt_bmp+28,24) ;Profondità=8bit
PokeL(punt_bmp+30,0) ;Compressione
PokeL(punt_bmp+34,600*600)
PokeL(punt_bmp+38,0)
PokeL(punt_bmp+42,0)
PokeL(punt_bmp+46,0)
PokeL(punt_bmp+50,0)
;Immagine
contatore.l
For contatore = 0 To 600*600*3
PokeB(punt_bmp+54+contatore,Random(255))
Next

The problem is that when I draw with OpenGL to this bitmap inside the computer memory nothing happens and the bitmap don't change.

I don't give you all my code (is too long). I ask only if

- is correct to scroll using bitmap inside the computer memory or is there a fast way?

- why I can't draw on this bitmap? I use this line of code to define the OpenGL environment
hWnd_Start = punt_Bitmap
pfd.PIXELFORMATDESCRIPTOR
hdc_Start = GetDC_(hWnd_Start)
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW
pfd\dwLayerMask = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 24
pfd\cDepthBits = 24
pixformat = ChoosePixelFormat_(hdc_Start, pfd)
SetPixelFormat_(hdc_Start, pixformat, pfd)
hrc_Start = wglCreateContext_(hdc_Start)
wglMakeCurrent_(hdc_Start,hrc_Start)
glViewport_ (0, 0, WindowWidth-30, WindowHeight-30)


Ciao to everybody and Yatta!!! :D
Alberto
Alberto
User
User
Posts: 25
Joined: Mon May 19, 2003 4:59 pm

Post by Alberto »

I answer to myself (maybe my words can help someone).

It's stupid to render in the computer memory because the operation is too slow.
Is better to use the OpenGL function glCopyPixels_ that scrolls quickly the pixels in the graphic card.

However my program above is wrong because I use the wrong parameter #PFD_DRAW_TO_WINDOW
The right parameter is #PFD_DRAW_TO_BITMAP

Ciao to everybody and Yatta!!! :D
Alberto
Manolo
User
User
Posts: 75
Joined: Fri Apr 25, 2003 7:06 pm
Location: Spain

Post by Manolo »

Como que Yatta???
Return to the forum
Alberto
User
User
Posts: 25
Joined: Mon May 19, 2003 4:59 pm

Post by Alberto »

"Yatta" is an exlamation used by my favourites cartoon heroes.

Legs Weaver says "Yatta!!!!"
Tex Willer says "Tizzone d'inferno!"
Superpippo says "Yuk"
I usually say "Oh pebbacco" that is not so impressive...

Ciao
Alberto
Post Reply