Scrolling using bitmap in memory
Posted: Tue May 20, 2003 10:25 am
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!!!
Alberto
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!!!
Alberto