
Byte VS Unsigned Byte
Posted Friday, 10 February, 2012 - 22:46 by flopoloco inI had vertex buffer object for color information setup like this.
byte[] dataColor = { 255, 0, 0, 255, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 255, 255, 0, 0 }; GL.GenBuffers(1, out bufferColor); GL.BindBuffer(BufferTarget.ArrayBuffer, bufferColor); GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(dataColor.Length * sizeof(byte)), dataColor, BufferUsageHint.StaticDraw);
For initializing the color information I had this
GL.EnableClientState(EnableCap.ColorArray); GL.BindBuffer(BufferTarget.ArrayBuffer, bufferColor); GL.ColorPointer(3, ColorPointerType.Byte, 0, 0);
But the result was a pitch black 3D object, after experimentation I had to change this line to display colored 3D object.
GL.ColorPointer(3, ColorPointerType.UnsignedByte, 0, 0);
What is the difference between ColorPointerType.Byte and ColorPointerType.UnsignedByte?
Thanks! :)


Comments
Re: Byte VS Unsigned Byte
ColorPointerType.Byte is signed and C# byte is unsigned.
OpenGL
ColorPointerType.Byte = signed byte = -128 to 127
ColorPointerType.UnsignedByte = unsigned byte = 0 to 255
C#
byte = unsigned byte = 0 to 255
sbyte = signed byte = -128 to 127
Re: Byte VS Unsigned Byte
Oh, thanks. :)