Re: [Vala] How to bitwise math and implement a jagged array in Vala?
- From: Thomas F Steinhauer <tom_steinhauer hotmail com>
- To: Evan Nemerson <evan coeus-group com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] How to bitwise math and implement a jagged array in Vala?
- Date: Tue, 2 Jul 2013 23:38:16 -0500
for some reason after doing this with your code the quads show up but
the texture does not. if I use a 1D array I can get a stripe to show up
but that is not what I what. I guess I must being doing something wrong.
this code will produce a red stripe with green next to it but still
cannot produce a checker board effect that I am after.
void makeCheckImage()
{
int j = 0;
for (j = 0; j < checkImageWidth; j++) {
checkImage[4*j] = (GLubyte)((j<=4) ? 255 : 0);
checkImage[4*j+1] = (GLubyte) ((j>4) ? 255 : 0);
checkImage[4*j+2] = (GLubyte) 0;
checkImage[4*j+3] = (GLubyte) 255;
}
}
must be something that I am still missing.
Thanks
Tom
On 07/02/2013 07:02 PM, Evan Nemerson wrote:
On Tue, 2013-07-02 at 18:49 -0500, Thomas F Steinhauer wrote:
I tried your code as you suggested however that did not work. I guess
the real question that I am asking here is has anyone successfully
generated a Checker board type texture with OpenGL and Vala and
displayed it on a cube or square. That is the code that I really need.
It seems that because Vala does not supported "jagged" arrays that this
is not possible or did I miss something in the reading somewhere?
Yes. For one thing, there is no reason this needs to be a jagged array.
The C example isn't. The part of the tutorial I linked to explains the
difference.
Here is everything together. I've changed GL.ubyte to uint8 because it
was more convenient (I don't get an opengl vapi), but s/uint8/GL.ubyte/
and it should be exactly what you're after.
private static uint8[,,]
make_check_image (int width = 64, int height = 64) {
uint8[,,] check_image = new uint8[height,width,4];
for ( var i = 0 ; i < height ; i++ ) {
for ( var j = 0 ; j < width ; j++ ) {
uint8 c = (((uint8)((i&0x8)==0))^((uint8)((j&0x8)==0)))*255;
check_image[i,j,0] = c;
check_image[i,j,1] = c;
check_image[i,j,2] = c;
check_image[i,j,3] = 255;
}
}
return check_image;
}
-Evan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]