2dDrawing Coding rulez?

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

[== 2dDrawing Coding rulez? ==]
-------------------------------
When using any 2dDrawing operation like Plot(), Line(), FrontColour() i.e, we have to use StartDrawing() before calling one of the 2dDraw comamnds and finish our operation with StopDrawing() - Up to here it is all ok but does there are any coding rulez using Start-/StopDrawing() ? Please tell me what usage of the following examples is correct... Since i have had the GDI/DDHelp bugs i complete rewrote my code like the first example to be sure that i am not responsible for the problems/bugs! the problems/bugs are not by me! Does both examples are correct of handling the Start/StopDrawing() command?

Code: Select all

;----------------------------------------
; 2dDrawing exampe source 1 - question
;----------------------------------------
;
    For x = 0 to 9
    	StartDrawing(ScreenOutput())
	    FrontColour (255, 255, 255)    	  
	    Line (10*x, 10, 10, 10)
    	StopDrawing()
    Next 
    ;
    a$ = "Just a small question"
    ;
    For y = 0 to 4
    	StartDrawing(ScreenOutput())
	    FrontColour (255, 0, 255)    	  
	    Line (10, 10*y, 10, 10)
    	StopDrawing()
    Next 
;
;----------------------------------------
Here is another coding style (i would like to prefer this...)

Code: Select all

;----------------------------------------
; 2dDrawing exampe source 2 - question
;----------------------------------------
;
    StartDrawing(ScreenOutput())
    	For x = 0 to 9  	
	    FrontColour (255, 255, 255)    	  
	    Line (10*x, 10, 10, 10)
	Next 
    	;
	a$ = "Just a small question"
	;
    	For y = 0 to 4
	    FrontColour (255, 0, 255)    	  
	    Line (10, 10*y, 10, 10)
	Next 
    StopDrawing()
;
;----------------------------------------
Many thanks in advance... I m not really sure if there will be differennts that could be responible for some problems/bugs!? Normaly i think both examples should be ok, but who knows :wink: - Second example is only a bit more optimized...


PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

StartDrawig() must be called before using any 2DDrawing functions. When ALL drawing stuffs are finished, just call StopDrawing(). Both of your examples are right, but the second one is much more optimized ! BTW, you can put the FrontColour() command outside of the loop, as it put the Current Frontcolour....

Optimized code will loks like this:

Code: Select all


StartDrawing(ScreenOutput())	    
FrontColour (255, 255, 255)    	  
For x = 0 to 9    
  Line (10*x, 10, 10, 10)
Next
StopDrawing()


Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

BTW, you can put the FrontColour() command outside of the loop, as it put the Current Frontcolour....

Yes i know :wink: - It was just only a small example of how to use the Drawing() stuff - thanks!

PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten
Post Reply