<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>VisionEgg.Core.Stimulus</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="VisionEgg-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://www.visionegg.org">Vision Egg</a></th> </tr></table></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> <a href="VisionEgg-module.html">Package VisionEgg</a> :: <a href="VisionEgg.Core-module.html">Module Core</a> :: Class Stimulus </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> <tr><td align="right"><span class="options" >[<a href="frames.html" target="_top">frames</a >] | <a href="VisionEgg.Core.Stimulus-class.html" target="_top">no frames</a>]</span></td></tr> </table> </td> </tr> </table> <!-- ==================== CLASS DESCRIPTION ==================== --> <h1 class="epydoc">Class Stimulus</h1><span class="codelink"><a href="VisionEgg.Core-pysrc.html#Stimulus">source code</a></span><br /><br /> <pre class="base-tree"> object --+ | <a href="VisionEgg.ClassWithParameters-class.html">ClassWithParameters</a> --+ | <strong class="uidshort">Stimulus</strong> </pre> <hr /> <pre class="literalblock"> Base class for a stimulus. Any stimulus element should be a subclass of this Stimulus class. The draw() method contains the code executed before every buffer swap in order to render the stimulus to the frame buffer. It should execute as quickly as possible. The init_gl() method must be called before the first call to draw() so that any internal data, OpenGL display lists, and OpenGL:texture objects can be established. To illustrate the concept of the Stimulus class, here is a description of several methods of drawing two spots. If your experiment displays two spots simultaneously, you could create two instances of (a single subclass of) Stimulus, varying parameters so each draws at a different location. Another possibility is to create one instance of a subclass that draws two spots. Another, somewhat obscure, possibility is to create a single instance and add it to two different viewports. (Something that will not work would be adding the same instance two times to the same viewport. It would also get drawn twice, although at exactly the same location.) OpenGL is a 'state machine', meaning that it has internal parameters whose values vary and affect how it operates. Because of this inherent uncertainty, there are only limited assumptions about the state of OpenGL that an instance of Stimulus should expect when its draw() method is called. Because the Vision Egg loops through stimuli this also imposes some important behaviors: First, the framebuffer will contain the results of any drawing operations performed since the last buffer swap by other instances of (subclasses of) Stimulus. Therefore, the order in which stimuli are present in the stimuli list of an instance of Viewport may be important. Additionally, if there are overlapping viewports, the order in which viewports are added to an instance of Screen is important. Second, previously established OpenGL display lists and OpenGL texture objects will be available. The __init__() method should establish these things. Third, there are several OpenGL state variables which are commonly set by subclasses of Stimulus, and which cannot be assumed to have any particular value at the time draw() is called. These state variables are: blending mode and function, texture state and environment, the matrix mode (modelview or projection), the modelview matrix, depth mode and settings. Therefore, if the draw() method depends on specific values for any of these states, it must specify its own values to OpenGL. Finally, a well-behaved Stimulus subclass resets any OpenGL state values other than those listed above to their initial state before draw() and init_gl() were called. In other words, before your stimulus changes the state of an OpenGL variable, use glGetBoolean, glGetInteger, glGetFloat, or a similar function to query its value and restore it later. For example, upon calling the draw() method, the projection matrix will be that which was set by the viewport. If the draw() method alters the projection matrix, it must be restored. The glPushMatrix() and glPopMatrix() commands provide an easy way to do this. The default projection of Viewport maps eye coordinates in a 1:1 fashion to window coordinates (in other words, it sets eye coordinates to use pixel units from the lower left corner of the viewport). Therefore the default parameters for a stimulus should specify pixel coordinates if possible (such as for a 2D stimulus). Assuming a window size of 640 by 480 for the default parameters is a pretty safe way to do things. Also, be sure to check for any assumptions made about the system in the __init__ method. For example, if your stimulus needs alpha in the framebuffer, check the value of glGetIntegerv(GL_ALPHA_BITS) and raise an exception if it is not available. </pre><br /><br /> <!-- ==================== INSTANCE METHODS ==================== --> <a name="section-InstanceMethods"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td align="left" colspan="2" class="table-header"> <span class="table-header">Instance Methods</span></td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="VisionEgg.Core.Stimulus-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">**kw</span>)</span><br /> Instantiate and get ready to draw.</td> <td align="right" valign="top"> <span class="codelink"><a href="VisionEgg.Core-pysrc.html#Stimulus.__init__">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="VisionEgg.Core.Stimulus-class.html#draw" class="summary-sig-name">draw</a>(<span class="summary-sig-arg">self</span>)</span><br /> Draw the stimulus.</td> <td align="right" valign="top"> <span class="codelink"><a href="VisionEgg.Core-pysrc.html#Stimulus.draw">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="VisionEgg.ClassWithParameters-class.html">ClassWithParameters</a></code></b>: <code><a href="VisionEgg.ClassWithParameters-class.html#__getstate__">__getstate__</a></code>, <code><a href="VisionEgg.ClassWithParameters-class.html#__setstate__">__setstate__</a></code>, <code><a href="VisionEgg.ClassWithParameters-class.html#get_specified_type">get_specified_type</a></code>, <code><a href="VisionEgg.ClassWithParameters-class.html#is_constant_parameter">is_constant_parameter</a></code>, <code><a href="VisionEgg.ClassWithParameters-class.html#set">set</a></code>, <code><a href="VisionEgg.ClassWithParameters-class.html#verify_parameters">verify_parameters</a></code> </p> <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: <code>__delattr__</code>, <code>__getattribute__</code>, <code>__hash__</code>, <code>__new__</code>, <code>__reduce__</code>, <code>__reduce_ex__</code>, <code>__repr__</code>, <code>__setattr__</code>, <code>__str__</code> </p> </td> </tr> </table> <!-- ==================== CLASS VARIABLES ==================== --> <a name="section-ClassVariables"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td align="left" colspan="2" class="table-header"> <span class="table-header">Class Variables</span></td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="VisionEgg.ClassWithParameters-class.html">ClassWithParameters</a></code></b>: <code><a href="VisionEgg.ClassWithParameters-class.html#__safe_for_unpickling__">__safe_for_unpickling__</a></code>, <code><a href="VisionEgg.ClassWithParameters-class.html#constant_parameters_and_defaults">constant_parameters_and_defaults</a></code>, <code><a href="VisionEgg.ClassWithParameters-class.html#parameters_and_defaults">parameters_and_defaults</a></code> </p> </td> </tr> </table> <!-- ==================== PROPERTIES ==================== --> <a name="section-Properties"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td align="left" colspan="2" class="table-header"> <span class="table-header">Properties</span></td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: <code>__class__</code> </p> </td> </tr> </table> <!-- ==================== METHOD DETAILS ==================== --> <a name="section-MethodDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td align="left" colspan="2" class="table-header"> <span class="table-header">Method Details</span></td> </tr> </table> <a name="__init__"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>, <span class="sig-arg">**kw</span>)</span> <br /><em class="fname">(Constructor)</em> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="VisionEgg.Core-pysrc.html#Stimulus.__init__">source code</a></span> </td> </table> <pre class="literalblock"> Instantiate and get ready to draw. Set parameter values and create anything needed to draw the stimulus including OpenGL state variables such display lists and texture objects. </pre> <dl class="fields"> <dt>Overrides: <a href="VisionEgg.ClassWithParameters-class.html#__init__">ClassWithParameters.__init__</a> </dt> </dl> </td></tr></table> </div> <a name="draw"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">draw</span>(<span class="sig-arg">self</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="VisionEgg.Core-pysrc.html#Stimulus.draw">source code</a></span> </td> </table> <pre class="literalblock"> Draw the stimulus. (Called by Viewport instance.) This method is called every frame. This method actually performs the OpenGL calls to draw the stimulus. </pre> <dl class="fields"> </dl> </td></tr></table> </div> <br /> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="VisionEgg-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://www.visionegg.org">Vision Egg</a></th> </tr></table></th> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%%"> <tr> <td align="left" class="footer"> Generated by Epydoc 3.0beta1 on Sat Jun 7 15:40:10 2008 </td> <td align="right" class="footer"> <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a> </td> </tr> </table> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie() // --> </script> </body> </html>