Re: Graphics N' Stuff

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ok. It is possible to do this very easily under windows. 

Firstly you must create a "memory device context" and a "compatible bitmap"
and save the handles to these. I do not know which GDI function calls are
implemented under win32lib, which is the Euphoric Windows Library it looks like
you are using. Anyway, these handles can be created at the start of the
program. When painting, you SelectObject the "compatible bitmap" into the
"memory
dc", and can draw to it using all the normal win32 GDI functions specifiying
the memory dc as the dc parameter. However, this does not draw it to the
screen - it just draws "on the bitmap" which is in the memory, changing the
"color bits" of it as if you were drawing to the screen.

I would also far over recommend the function BitBlt() over the normal
windows bitmap static controls. This is simply a "bit block transfer" from one
DC
to the other, ie from the bitmap in memory to the "screen memory" which will
actually display it on the screen. BitBlt, PatBlt, PlgBlt etc are SUPREME, and
I mean the SUPREME Win32 GDI functions. ie, you can actually get your money
worth of performance from them.

I know this may sound confusing, but the Windows Graphics Device Interface
generally is. I would have to recommend you read a book to further your actual
understanding when broaching such a broad topic as graphics - because I
could cut and paste some code which would work in one instance of your program
but not anywhere else, but you would still be in the same position.

Anyway, in generic old-style win32 programming, this (mixed) code would sum
it up if you can (or anyone) convert it to win32lib's standards:

-- variables declared outside the window procedure
atom hdcMem, hMemBitmap

-- local variables within the window procedure
atom hdc
if iMsg = WM_CREATE then
 hdc = GetDC(hwnd)
 hdcMem = CreateCompatibleDC(hdc) -- where hwnd is the first parameter to
the window procedure
 hMemBitmap  = CreateCompatibleBitmap(hdc,<width>,<height>)
 ReleaseDC(hwnd,hdc)
elsif
 iMsg = WM_PAINT
  then
  -- do your drawing operations to the bitmap, or none at all if your
bitmaps are initialized at startup
  hdc = GetDC(hwnd)
 BitBlt(hdc,0,0,<width>,<height>,hdcMem,0,0,SRCCOPY)
  ReleaseDC(hwnd)
   ValidateRect(hwnd,NULL)
elsif
 iMsg = WM_DESTROY then
 DeleteDC(hdcMem)
 DeleteObject(hMemBitmap)
 -- other quit stuff
end if



Sorry it looks like a mess but this is my best attempt at explaining it. You
can perform most animation using this method, especially with sprites.

Probably didn't help, but anyway good luck

Francis

-- 
Sent through GMX FreeMail - http://www.gmx.net

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu