3D-Pictures

BlitzPlus Forums/BlitzPlus Programming/3D-Pictures

I´m again. I´m not a good programmer you see. But I can´t finde a way to hide a colorchannel (I hope you know what I mean, my english...). I want to crate some 3D-pictures with Blitz? Has everyone an idea?

hm, you mean 3d as in 'just draw something in 2d that looks 3d, like raytracing'? B+ is 2d+gui eh .. for official 3d get Blitz3d or Blitzmax. Blitzmax can change rgb intensities.

I think you mean anaglypic pictures: red/green or red/blue? The gamma commands might help: SetGamma and UpdateGamma.

i mean th 3D pics with the red/cyan glasses you´re right. But The Gamma-Functions bring an useless result.
Here an example: http://www.3d-brillen.de/3d/galerie/oliver/oo-wald.php3

Gamma works only in fullscreen. Else, you might need to use ReadPixel and WritePixel:
Graphics 800, 600, 0, 2
SetBuffer BackBuffer()

For i = 0 To 500
Color 0, 0, Rand($FFFFFF)
Oval Rand(256), Rand(256), Rand(20), Rand(20)
Next

For y = 0 To 256
For x = 0 To 256
WritePixel x, y, ReadPixel(x, y) And $00FF00  ;use $FF0000 for red
Next
Next

Flip
WaitKey()


I tryed some things. Now I know what I´ve to do. But its very complicated. I can use Read/writepixel-functions. Thanks. Now my problem: I have to fill the green colorchannel with write. I´ve worked on this for weeks. Bu now result. When everybody have an idea please poist it! I´m confused!!!!!

can't you just change $00FF00 in the example above to $0000FF? If not, then please post your code so that we can figure out how you did it.

Maybe you could readpixel what is on the screen, add the green and then write it back?
-->WritePixel x, y, ReadPixel(x, y) Or $00FF00
This example combines two black&white images:
	Graphics 800, 600, 0, 2
	SetBuffer BackBuffer()
	Cls
	Flip
	
	;create images
	RED_picture = CreateImage(800, 600)
	GRN_picture = CreateImage(800, 600)
	
	;-----------------------
	;  make red picture
	;-----------------------
	;this picture is a greyscale picture
	Cls
	For i = 0 To 1000
	cc = Rand(255)
	Color cc, cc, cc
	Oval Rand(800), Rand(600), Rand(80), Rand(60)
	Next
	
	GrabImage RED_picture, 0, 0
	
	Locate 0, 0
	Color 255, 255, 255
	Print "RED PICTURE"
	Flip
	
	Delay 500
	
	
	;-----------------------
	;   make green picture
	;-----------------------
	;this picture is a greyscale picture, too
	Cls
	For i = 0 To 1000
	cc = Rand(255)
	Color cc, cc, cc
	Rect Rand(800), Rand(600), Rand(80), Rand(60)
	Next
	
	GrabImage GRN_picture, 0, 0
	
	Color 255, 255, 255
	Locate 0, 0
	Print "GREEN PICTURE"
	
	Delay 500
	
	;-----------------------
	;    blend pictures
	;-----------------------
	
	Cls
	
	;used in combination with Read/WritePixelFast
	LockBuffer()
	LockBuffer(ImageBuffer(RED_picture))
	LockBuffer(ImageBuffer(GRN_picture))
	
	;for every pixel
	For y = 0 To 599
	For x = 0 To 799
	
		;get red from image 1	
		cc_RED% = ReadPixelFast(x, y, ImageBuffer(RED_picture)) And $FF0000
		;get green from image 2
		cc_GRN% = ReadPixelFast(x, y, ImageBuffer(GRN_picture)) And $00FF00
		;blend by adding them, and write result to screen
		WritePixelFast x, y, cc_RED% + cc_GRN%
	
	Next
	Next

	;unlock stuff
	UnlockBuffer(ImageBuffer(RED_picture))
	UnlockBuffer(ImageBuffer(GRN_picture))
	UnlockBuffer()
	
	Locate 0, 0
	Color 255, 255, 255
	Print "MIXED PICTURES"
	
	Flip
	WaitKey()
	
	End


@b32: Nice. It works. I didn´t know Lockbuffer. You´re an expert. Thank you.