I know that this example is old but I use this one for test double buffering.
This example is part of EB directX examples translated to oxygen.
$ filename "MandelBlue.exe"
include "rtl32.inc"
include "awinh.inc"
#lookahead
INT win,c,r
INT w,h
dim i,y,px as INT
dim Z_re2 as FLOAT
dim Z_im2 as FLOAT
dim Z_re as FLOAT
dim Z_im as FLOAT
dim c_re as FLOAT
dim c_im as FLOAT
INT hdc, hdcMem, hbmMem, oldBmp, oldBrush, oldPen, oldFont, fColor
INT textX,textY,hBrush
INT ImageWidth=640
INT ImageHeight=480
MinRe = -2.0f
MaxRe = 1.0f
MinIm = -1.25f
MaxIm = MinIm+(MaxRe-MinRe)*ImageHeight/ImageWidth
Re_factor = (MaxRe-MinRe)/(ImageWidth-1)
Im_factor = (MaxIm-MinIm)/(ImageHeight-1)
'window
win = SetWindow("Mandel Blue",0,0,ImageWidth,ImageHeight,0,WS_SYSMENU)
InitDrawing()
'---------------------------------------------------------------------
for y = 0 to ImageHeight-1
c_im = MaxIm - y*Im_factor
for px=0 to ImageWidth-1
c_re=MinRe+px*Re_factor
Z_re=c_re
Z_im=c_im
for i = 1 to 50
Z_re2=Z_re*Z_re
Z_im2=Z_im*Z_im
if (Z_re2+Z_im2) > 4
'Pix (win, px, y, 255-(i+5),i*5, i) 'draw to back buffer is faster
Setpixel hdcMem, px, y,RGB(i,i*5,155 -(i+5))
exit for
end if
Z_im=2*Z_re*Z_im+c_im
Z_re=Z_re2-Z_im2+c_re
next i
next px
next y
'----------------------------------------------------------------
Wait()
Function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
Select wmsg
CASE WM_CLOSE
DestroyWindow win
CleanUp()
PostQuitMessage 0
CASE WM_SIZE
'GetSize(win,0,0,w,h)
CASE WM_PAINT
BitBlt(hDC, 0, 0, w, h, hdcMem, 0, 0, SRCCOPY)
End Select
Return DEFAULT
End Function
SUB InitDrawing
''get current size of window
GetSize(win,0,0,w,h)
'get window DC
hdc=GetDC(win)
hdcMem = CreateCompatibleDC(0)
hbmMem = CreateCompatibleBitmap(hdc, w, h)
oldBmp = SelectObject( hdcMem, hbmMem )
oldBrush = SelectObject(hdcMem, CreateSolidBrush( RGB(231,223,231)) )
oldPen = SelectObject(hdcMem, CreatePen(PS_SOLID,1,RGB(231,223,231)))
'fill rectangle memDC with brush color
FillRect ( hdcMem,rc, oldBrush)
SetTextColor( hDC,RGB(0,0,0))
SetBkColor( hDC, RGB(231,223,231))
'blit to memDC
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( win, hdc)
End SUB
SUB CleanUp
DeleteDC(hdcMem)
DeleteObject(SelectObject(hdcMem, oldBrush))
DeleteObject(SelectObject(hdcMem, oldPen))
DeleteObject(SelectObject(hdcMem, oldBmp))
END SUB
Sub Pix(wnd as int,sys x, y, r, g, b)
hdc=GetDC(wnd)
sys pcolor = RGB(r,g,b)
Setpixel hdc, x, y,pcolor
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC(wnd, hdc)
End Sub
X