WritePixel question

BlitzMax Forums/BlitzMax Programming/WritePixel question

Pineapple(Posted 2009) [#1]
Why does this line of code constantly write a black pixel regardless of what til r,g, and b are?

WritePixel pmap,x+xcoord,y+ycoord,($FF000000) Or (tilr Shl 16) Or (tilg Shl 8) Or (tilb)

EDIT: Problem solved - had to use | instead of Or


Arowx(Posted 2009) [#2]
I think you it depends on the pixel formatting you provide to your pixmap...

Graphics 100,100

SetBlend alphablend

pix = CreatePixmap(10,10, PF_BGRA8888)'PF_RGBA8888) <- This sorts it!

For x = 0 To 9
	For y = 0 To 9
		WritePixel(pix, x,y, $80FF8000)
		Print Hex(ReadPixel(pix, x,y))
	Next 
Next 

Repeat

	Cls
	
	DrawRect(40,40,30,30)
	
	DrawPixmap(pix, 50,50)
	
	Flip

Until AppTerminate() Or KeyHit(KEY_ESCAPE)



ImaginaryHuman(Posted 2009) [#3]
You answered it yourself, but I was also going to mention that if you are on machines with different Endianness, you have to be careful when you are reading and writing color values into pixmaps. The CPU will potentially rearrange the order of the bytes *on the fly* as part of the read/write operations, which will look like it's nothing to do with your code at all.