DrawingBuffer() and Brushes

Just starting out? Need help? Post your questions and find answers here.
User avatar
Michael Vogel
Addict
Addict
Posts: 2676
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

DrawingBuffer() and Brushes

Post by Michael Vogel »

I found out, that on some graphic cards there is an impact, when the DrawingBuffer() command is used (should only return a memory value)

On a Mobility Radeon, the polygon in the following is not seen, only when removing the three DrawingBuffer lines...

On other graphic cards I did not have this effect, so I don't know if I wrote some wrong code, it's a hardware or software bug?!

Code: Select all

Global Dim Polygon(8)

InitSprite()
win=OpenWindow(1,0,0,600,600,"3D-View",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
	OpenWindowedScreen(win,0,0,600,600,0,0,0)

	polygon(0)=0
	polygon(1)=0
	polygon(2)=500
	polygon(3)=0
	polygon(4)=500
	polygon(5)=500
	polygon(6)=0
	polygon(7)=500

Repeat
windc=StartDrawing(ScreenOutput())

	DxMem=DrawingBuffer()
	DxMul=DrawingBufferPitch()
	DxPix=DrawingBufferPixelFormat()

DrawingMode(#PB_2DDrawing_Transparent)

winbrush=CreateSolidBrush_($ffff)
SelectObject_(windc,winbrush)
Polygon_(windc,@Polygon(),4)
DeleteObject_(winbrush)
StopDrawing()
FlipBuffers()

Until WaitWindowEvent(10) = #WM_CHAR
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I also have this effect on a ProSavage DDR.
thefool
Always Here
Always Here
Posts: 5881
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Same on radeon 9600 xt 256
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

and same on Radeon X800GTO²
0
Der Vorgang wurde erfolgreich beendet.
87
Falscher Parameter.
87
Falscher Parameter.
183
Eine Datei kann nicht erstellt werden, wenn sie bereits vorhanden ist.
87
Falscher Parameter.
0
Der Vorgang wurde erfolgreich beendet.
2
Das System kann die angegebene Datei nicht finden.
0
Der Vorgang wurde erfolgreich beendet.
maybe someone could post the error codes in english :idea:

Code: Select all

ProcedureDLL.s GetLastError()
  err=GetLastError_()
  Debug err
  buffer.l=0 
  ferr=FormatMessage_(#FORMAT_MESSAGE_ALLOCATE_BUFFER|#FORMAT_MESSAGE_FROM_SYSTEM,0,err,0,@buffer,0,0)
  If buffer<>0
    errormsg$=PeekS(buffer)
    LocalFree_(buffer)
    errormsg$=RemoveString(errormsg$,Chr(13)+Chr(10))
    ProcedureReturn errormsg$
  EndIf
EndProcedure

Global Dim Polygon(8) 

InitSprite() 
win=OpenWindow(1,0,0,600,600,"3D-View",#PB_Window_ScreenCentered|#PB_Window_BorderLess) 
   OpenWindowedScreen(win,0,0,600,600,0,0,0) 

   polygon(0)=0 
   polygon(1)=0 
   polygon(2)=500 
   polygon(3)=0 
   polygon(4)=500 
   polygon(5)=500 
   polygon(6)=0 
   polygon(7)=500 

Repeat 
 windc=StartDrawing(ScreenOutput()) 

   DxMem=DrawingBuffer() 
   err$=GetLastError()
   debug err$
   CallDebugger
   ;DxMul=DrawingBufferPitch() 
   ;DxPix=DrawingBufferPixelFormat() 

   ;DrawingMode(#PB_2DDrawing_Transparent) 

   ;winbrush=CreateSolidBrush_($ffff) 
   ;old=SelectObject_(windc,winbrush) 
   ;Polygon_(windc,@Polygon(),4) 
   ;DeleteObject_(winbrush)
   ;SelectObject_(windc,old) 
 StopDrawing() 

 FlipBuffers() 

Until WaitWindowEvent(10) = #WM_CHAR
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Not sure it's actually a bug, Fred need to clarify this.
My guess is that it's a documentation error regarding DrawingBuffer()

This example works. (sorry, quick and dirty just to show the difference)

Code: Select all

Global Dim Polygon(8)

InitSprite()
win=OpenWindow(1,0,0,600,600,"3D-View",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
   OpenWindowedScreen(win,0,0,600,600,0,0,0)

   polygon(0)=0
   polygon(1)=0
   polygon(2)=500
   polygon(3)=0
   polygon(4)=500
   polygon(5)=500
   polygon(6)=0
   polygon(7)=500

Repeat
windc=StartDrawing(ScreenOutput())
If windc

   DxMem=DrawingBuffer()
   DxMul=DrawingBufferPitch()
   DxPix=DrawingBufferPixelFormat()
 StopDrawing()

 windc=StartDrawing(ScreenOutput())
 If windc
  
  DrawingMode(#PB_2DDrawing_Transparent)
  
  winbrush=CreateSolidBrush_($ffff)
  SelectObject_(windc,winbrush)
  Polygon_(windc,@Polygon(),4)
  DeleteObject_(winbrush)
  StopDrawing()
 EndIf
EndIf
FlipBuffers()

Until WaitWindowEvent(10) = #WM_CHAR
Yep! StopDrawing() must be done then drawing has to be restarted again to do/use other gfx functions.
The reason for this is that I supect PB enteres into direct buffer manipulation,
so you must do StopDrawing() so PB can go back to normal buffering.

You also have to take great care exactly "when" you edit the graphics memory buffer directly.
You either should do it at the very start of your routine before any other gfx effects,
or at the very end when you are done with your gfx functions.

If you place DrawingBuffer() after all your other processing so that only StopDrawing is next your code works.
I have no idea why it behaves like this, but as I said. I'm unsure if this is a bug or a windows "feature"
User avatar
Michael Vogel
Addict
Addict
Posts: 2676
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post by Michael Vogel »

Start/StopDrawing costs a lot of time, I'll try to do a fast 3D rotation, so I needed to reduce these commands when possible.

I think I've solved it (at least for my special case), now the polygon (press 'c' in view mode to change color themes), boxes, text and lines ('a' changes the antialiasing mode) live all together in one StartStop Drawing code segment...

If you like to see the result...
>>> http://sudokuprogram.googlepages.com/forerunner.exe
you may also need
>>> http://sudokuprogram.googlepages.com/MichaelVogel.hst
Post Reply