Clearing screen or what is best practice having
I am opening a window with:
If CreateImage(0, 640, 480) And OpenWindow(0,0,0,640,480,"Fractal Lines",#PB_Window_SystemMenu)
...
and do simple 2d drawing (linexy) with
StartDrawing(ImageOutput(0))
StopDrawing()
but how can I clear the window and wait for sync with monitor refresh so I can render an realtime animation without flickering?
actually I need windowed screen where I can simply draw with the basic 2d functions (setting pixels, drawing lines, not sprites etc)... and clear it (without doing a fake BOX draw with background color).
and best... without flickering as waiting for a sync?
Thanks for help here again.
Drawing Window mode & sync
Re: Drawing Window mode & sync
Use a windowed Screen by using OpenWindowedScreen() after your OpenWindow().
Code: Select all
If CreateImage(0, 640, 480) And OpenWindow(0,0,0,640,480,"Fractal Lines",#PB_Window_SystemMenu)
And OpenWindowedScreen(WindowID(0),0,0,640,480)
...
;and with a loop that first checks for WindowEvents then includes:
ClearScreen(RGB(0, 0, 0)) ;background color
;then first do simple 2d drawing (linexy) with
StartDrawing(ImageOutput(0))
StopDrawing()
;then use the following to either DrawImage(ImageID(0)) or do all simple 2d drawing (linexy) instead of using an image
StartDrawing(ScreenOutput())
StopDrawing()
;display results before continuing loop
FlipBuffers()
-
- User
- Posts: 20
- Joined: Mon Jan 26, 2009 1:43 pm
Re: Drawing Window mode & sync
well... actually 5.11 tells me to use initsprite() before?
-
- User
- Posts: 20
- Joined: Mon Jan 26, 2009 1:43 pm
Re: Drawing Window mode & sync
Code: Select all
InitKeyboard()
InitSprite()
CreateImage(0, 800, 480)
OpenWindow(0,0,0,800,480,"Fractal Lines",#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0),0,0,800,480)
;StartDrawing(ScreenOutput())
frame=0
z0.w =100
camx.w=0
camy.w=-40
camz.w=0
Repeat
ClearScreen(RGB(0,255,0))
For i=0 To max_width-1
ybuffer(i)=h
heights(i)=h
Next
draw_grid()
;StopDrawing()
;SaveImage(0,"bars2.bmp",#PB_ImagePlugin_BMP)
FlipBuffers()
;ImageGadget(0, 0, 0, xres, yres, ImageID(0))
camz=camz+1
camz=camz&$00f
Until WindowEvent()=#PB_Event_CloseWindow
-
- User
- Posts: 20
- Joined: Mon Jan 26, 2009 1:43 pm
Re: Drawing Window mode & sync
fcking cool. I overread the startdrawing(screenoutput()) instead of imageoutput... now works!