From: Srimal J. <sr...@gm...> - 2009-07-27 06:03:24
|
Thanks a lot tom Your right . I've changed everything to C style and , removed the iostream.h and included stdio.h and it works now. Regs Srimal. On Mon, Jul 27, 2009 at 11:02 AM, tom fogal<tf...@al...> wrote: > Srimal Jayawardena <sr...@gm...> writes: >> GLvoid* data; >> data =3D (GLvoid *) malloc (1024*768); >> glReadPixels (0,0,1024,768,GL_RED, GL_UNSIGNED_BYTE, data); >> for(int i=3D0; i<1024*768; i++) >> cout << data[i]; >> free(data); >> >> But it gives this error: >> >> $ make >> g++ -Wall -o render main.cpp -lglut >> main.cpp: In function =E2=80=98void drawScene()=E2=80=99: >> main.cpp:154: error: pointer of type =E2=80=98void *=E2=80=99 used in arith= >> metic >> main.cpp:154: error: =E2=80=98GLvoid*=E2=80=99 is not a pointer-to-object t= >> ype >> make: *** [render] Error 1 >> >> Am I missing something here? > > Yep. In short, your types are wrong. You can't have a void object, so > you can't directly dereference a void pointer. Try a GLubyte instead. > > That said, you might want to read up on C. I suggest the white book: > > http://cm.bell-labs.com/cm/cs/cbook/ > > Though your `cout' implies you actually want to write C++, contrary to > malloc/free. Stroustrup's book is the classic text here: > > http://www.research.att.com/~bs/3rd.html > >> Is there a better way to do this? > > Somewhere in the Mesa demos (IIRC) there's some code for reading the > current image buffer into a ppm file. If not there, some simple > googling should bring up code to do this. > > -tom > -- ~ Srimal Jayawardena BSc (Engineering), BIT, MIET PhD Student, Australian National University. Phone(Offilce): 0011 612 6125 1771 Phone(Home): 0011 612 6125 5413 ANU Contact Info : http://arp.anu.edu.au/user/3788 http://srimal.sri-lankan.net/ http://srimal-techdiary.blogspot.com/ |