For your second problem -

In C, an expression such as (i&0x8)==0 evaluates to an integer, 1 for
true and 0 for false. This can then be used for bitwise operations
such as ^ (bitwise XOR). In Vala however, the equality expression
evaluates to a value of the fundamental type bool, "true" or "false",
which have no direct correspondence with integer values.

A quick and dirty way to convert the code would then be to change
"(i&0x8)==0" to "(i&0x8)==0 ? 1 : 0" and likewise for the j variable,
however a more readable version could be something like:

c = (i & 0x8 != j & 0x8) ? 255 : 0;

Regards,
Simon

On Tue, Jul 2, 2013 at 1:36 PM, Thomas F Steinhauer
<[email protected]> wrote:
> Dear members I am new here and I have a couple of questions and they are are
> all centered around this piece of code I found online:
>
> 1. /*  Create checkerboard texture  */
> 2. #define checkImageWidth 64
> 3. #define checkImageHeight 64
> 4. static GLubyte checkImage[checkImageHeight][checkImageWidth][4];
> 5. static GLuint texName;
> 6. void makeCheckImage(void)
> 7. {
> 8.     int i, j, c;
> 9.
> 10.     for (i = 0; i < checkImageHeight; i++) {
> 11.        for (j = 0; j < checkImageWidth; j++) {
> 12.           c = ((((i&0x8)==0)^((j&0x8))==0))*255;
> 13.           checkImage[i][j][0] = (GLubyte) c;
> 14.           checkImage[i][j][1] = (GLubyte) c;
> 15.           checkImage[i][j][2] = (GLubyte) c;
> 16.           checkImage[i][j][3] = (GLubyte) 255;
> 17.        }
> 18.     }
> 19. }
>
> 1st, How can I do that same thing or equivalent from line #4 in Vala or is
> it not possible?
>
> 2nd. When I try to run line #12 in Vala I get an error "Operation not
> supported for types bool and bool. So is there a way to get Vala to evaluate
> this expression correctly?
>
> Any help with this would be greatly appreciated.
>
> Thanks
> Tom
> _______________________________________________
> vala-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/vala-list
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to