Re: stereo

New Message Reply Date view Thread view Subject view Author view

Tom McReynolds (tomcat++at++asd.sgi.com)
Tue, 17 Jun 1997 21:12:52 -0700


Lea Wittie wrote:
>
> Hi,
> I was looking at Allan Schaffer's stereo.c and I was wondering if
> he (or anyone else) could explain how these code bits worked:

Don't blame poor Allan for this monstrosity. I'm the guilty one! :-)

>
> static void
> DrawChannel (pfChannel *channel, void *left)
> {
> ......
>
> /* which buffer to draw into ? */
> if(Shared->stereo) { /* if not stereo, draw to left all the time */
> if(*(int*)left) {
> #ifdef IRISGL
> leftbuffer(1);
> rightbuffer(0);
> #else
> glDrawBuffer(GL_BACK_LEFT);
> #endif
> } else {
> #ifdef IRISGL
> leftbuffer(0);
> rightbuffer(1);
> #else
> glDrawBuffer(GL_BACK_RIGHT);
> #endif
> }
> }
> ......
> }
>
> I don't understand what "if(*(int*)left)" does. Does it make left
> into an integer or look to see if it's already one? I was also wondering if
> this meant that the value of left switched between int to non-int every
> time this function is called. If so, what causes this?

I was just being anal. I use channel data so the draw call back
can tell the left channel from the right. If you look up earlier
in the code, I alloc an int of channel data for each channel,
then set the left channel's data to 1, the right to zero.

The callback uses a void* argument, so I just cast it back to
an int * then dereference to get the original 0 or 1 value.

The cast should be free, and it avoids any compiler warnings, or
(unlikely) problems if a void * is a different size from
an int *. To be honest, I didn't put a lot a thought into it :-).

                -Tom

                 

>
> Thanks a bunch for any help you can give,
>
> -Lea Wittie
> lwittie++at++cs.uiowa.edu
> =======================================================================
> List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:28 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.