[CSC 315] Mouse Input Example Code
Andrew J. Pounds
pounds_aj at mercer.edu
Tue Sep 16 11:29:17 EDT 2014
On 09/16/14 10:46, wrote:
>
> Okay!
>
>
> For displayFunc(), can we only call that once?
>
>
Generally yes -- you should only have one display function -- BUT --
your display function can have multiple functions/methods etc. Most of
the code in your programs will be tied to the display func. Once we hit
animation the linkages between all of these glut functions will become
clearer.
> For the interact.c, why is it necessary to erase the box? Why can't we
> run the initializing functions again?
>
In this particular program eraseBox sets the color back to white (the
background color) and replaces the selected pixels with that color.
I've never tried calling init again. Give it a shot. In general,
however, you only want to initialize your environment once and then do
all of the manipulations within your code. Later on, when we start
talking about all of the buffers and matrix stacks, if you reinitialize
these you will throw away information related to the transforms on which
you are working. Let's say you have a matrix stack that has transformed
you into a new coordinate system for your viewport and another matrix
stack that has transformed your model into a different orientation. If
you reinitialize you would typically (at least in earlier versions of
GL) loose all of the information stored in your matrix stacks -- and you
have no way to re-create it.
>
> How exactly does the glutMainLoop work?
>
>
glutMainLoop runs the "callback processor". It is what looks for events
that change in the state of the system and then calls the appropriate
glut function (glutKeyboardFunc, glutDisplayFunc, etc., to process the
event.)
> For the rastered black box in parts 1 and 2 for the assignment,
> assuming its a function, would we call the rastering function in the
> initializing function or use the DisplayFunc? Why?
>
I personally would call it in the displayFunc. Again, this is my
preference because I like to separate out the pieces of the code to
things that I am "initializing" and things that I am responsible for
doing myself. As you will see later, I generally have individual
functions for all of these things. I have had students set up the black
box in both locations.
Great questions! Keep 'em coming!
--
Andrew J. Pounds, Ph.D. (pounds_aj at mercer.edu)
Professor of Chemistry and Computer Science
Mercer University, Macon, GA 31207 (478) 301-5627
http://faculty.mercer.edu/pounds_aj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://theochem.mercer.edu/pipermail/csc315/attachments/20140916/37924d56/attachment.html>
More information about the csc315
mailing list