[Vala] How to bitwise math and implement a jagged array in Vala?
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 = i0x8)==0)^((j0x8))==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 vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to bitwise math and implement a jagged array in Vala?
For your second problem - In C, an expression such as (i0x8)==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 (i0x8)==0 to (i0x8)==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 tom_steinha...@hotmail.com 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 = i0x8)==0)^((j0x8))==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 vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] How to prevent gee.HashMap.set from copy the memory and only return the pointer?
Hello when I try to set an object to HashMap gee.HashMap.set try to copy the memory of it with _vala_array_dup1 and it not allowed in my case. public class pcapNode { public uchar[] packet; public PCap.packet_header* header; } var node = new pcapNode(); node.packet = packet; node.header = header; this.map[i] = node; _tmp34_ = pcap_node_new (); node = _tmp34_; _tmp35_ = node; _tmp36_ = packet; _tmp36__length1 = packet_length1; _tmp37_ = (_tmp36_ != NULL) ? _vala_array_dup1 (_tmp36_, _tmp36__length1) : ((gpointer) _tmp36_); I guess I should define packet as pointer to uchar[] but I didn't success to do it. Thanks Nadav -- הבלוג שלי: http://nadavvin.com ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] How to re-use external C function with pointer
Hi, I find this code in Vala program [1]. But under FreeBSD, prctl() doesn't exist. So I use setproctitle(3) [2] (see attachment), but I get this error message: /usr/ports/x11-toolkits/granite/work/granite-0.2/lib/Application.vala:95.67-95.6 7: error: syntax error, expected `)' protected extern static void setproctitle (const char *fmt); ^ Compilation failed: 1 error(s), 0 warning(s) *** Error code 1 [1] http://bazaar.launchpad.net/~elementary-pantheon/granite/0.2/view/head:/lib/Application.vala#L70 [2] http://www.freebsd.org/cgi/man.cgi?query=setproctitlesektion=3apropos=0manpath=FreeBSD+9.1-RELEASE -- olivier patch-lib__Application.vala Description: Binary data ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] RELEASE: Vala 0.20.1 + GTK 3.6.4 for Mac OS X
Hi jm, Thanks ! I'd be very thankful if you can let me know how it behaves on 10.8. At least it shouldn't break anything ;-). Regards, Tarnyko j...@shabb.com writes: I can't thank you enough for your build Windows, and now OS X! I have access to OS X 10.8 that I can try on. on Jun 30, 2013, tarn...@tarnyko.net wrote: Hello people, I'm pleased to announce the availability of a Mac OS X bundle for Vala 0.20.1. Download link here : http://www.tarnyko.net/en/?q=node/36 or soon here : http://www.tarnyko.net/dl/vala.htm It contains GTK+ 3.6.4 and 2.24.18. It has only been tested against Leopard (10.5) so far, so if someone is interested and has a more recent OS version, I would be very interested to have some feedback. Regards, Tarnyko ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to re-use external C function with pointer
Hi Olivier, Try it this way : protected extern static void setproctitle (string fmt); I seem to remember Vala doesn't treat the const keyword well in parenthises. Regards, Tarnyko Olivier Duchateau writes: Hi, I find this code in Vala program [1]. But under FreeBSD, prctl() doesn't exist. So I use setproctitle(3) [2] (see attachment), but I get this error message: /usr/ports/x11-toolkits/granite/work/granite-0.2/lib/Application.vala:95.67-95.6 7: error: syntax error, expected `)' protected extern static void setproctitle (const char *fmt); ^ Compilation failed: 1 error(s), 0 warning(s) *** Error code 1 [1] http://bazaar.launchpad.net/~elementary-pantheon/granite/0.2/view/head:/lib/Application.vala#L70 [2] http://www.freebsd.org/cgi/man.cgi?query=setproctitlesektion=3apropos=0manpath=FreeBSD+9.1-RELEASE -- olivier ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to bitwise math and implement a jagged array in Vala?
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)((i0x8)==0))^((uint8)((j0x8)==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 ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to prevent gee.HashMap.set from copy the memory and only return the pointer?
2013/7/2 Nadav Vinik nadav...@gmail.com Hello when I try to set an object to HashMap gee.HashMap.set try to copy the memory of it with _vala_array_dup1 and it not allowed in my case. public class pcapNode { public uchar[] packet; public PCap.packet_header* header; } var node = new pcapNode(); node.packet = packet; node.header = header; this.map[i] = node; _tmp34_ = pcap_node_new (); node = _tmp34_; _tmp35_ = node; _tmp36_ = packet; _tmp36__length1 = packet_length1; _tmp37_ = (_tmp36_ != NULL) ? _vala_array_dup1 (_tmp36_, _tmp36__length1) : ((gpointer) _tmp36_); I guess I should define packet as pointer to uchar[] but I didn't success to do it. Thanks Nadav -- הבלוג שלי: http://nadavvin.com ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list Hi, it's not the HashMap trying to copy your array, but simply Vala syntax. When you assign the array packet to node.packet, Vala treats this array as a value type, meaning assignment equals copying. To stop it from doing that, try defining the 'packet' field in pcapNode as unowned. Jonas ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to bitwise math and implement a jagged array in Vala?
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) ((j4) ? 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)((i0x8)==0))^((uint8)((j0x8)==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 ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list