OpenGL tips

BlitzPlus Forums/BlitzPlus Programming/OpenGL tips

-Use panel gadgets for your viewports. It is best to set the panel class to have no background with SetClassLong hwnd,GCL_HBRBACKGROUND,0. However, this will disable the background on ALL panels. I was told that a future update to BlitzPlus would have a no-brush style flag.

-Compile the following PureBasic code into a DLL. Use InitWindow(hwnd) to enable repaint checking on for viewport. Use WindowPainted(hwnd) to check each viewport and redraw the scene if that viewport has been redrawn. I just tested it with two viewports, and it works perfectly, updating only the viewports that actually get repainted.

Global windowlist
Global windowlistsize

Procedure WindowCallback(hWnd,Mesg,wParam,lParam)
For n=1 To windowlistsize
  If hWnd=PeekL(windowlist+(n-1)*12+0)
    If Mesg=#WM_PAINT
      PokeL(windowlist+(n-1)*12+8,1)
      EndIf
    oldcallback=PeekL(windowlist+(n-1)*12+4)
    ProcedureReturn CallWindowProc_(oldcallback,hWnd,Mesg,wParam,lParam)
    EndIf
  Next
EndProcedure

ProcedureDLL InitWindow(hWnd)
windowlistsize=windowlistsize+1
If windowlist=1
  windowlist=AllocateMemory(windowlistsize*12)
  Else
  windowlist=ReAllocateMemory(windowlist,windowlistsize*12)
  EndIf
oldcallback=SetWindowLong_(hWnd,#GWL_WNDPROC,@WindowCallback())
PokeL(windowlist+(windowlistsize-1)*12+0,hWnd)
PokeL(windowlist+(windowlistsize-1)*12+4,oldcallback)
PokeL(windowlist+(windowlistsize-1)*12+8,0)
EndProcedure

ProcedureDLL.l WindowRepainted(hWND)
For n=1 To windowlistsize
  If hWND=PeekL(windowlist+(n-1)*12+0)
    result=PeekL(windowlist+(n-1)*12+8)
    PokeL(windowlist+(n-1)*12+8,0)
    ProcedureReturn result
    EndIf
  Next
EndProcedure