AnoPlib - Animlets are not Particles library
|
A flashing signal. More...
#include <AnoPflashlight1.h>
Public Member Functions | |
void | addAnimlet (flashSignal1Struct &animlet) throw () |
Adds an animlet to the list of those to render. | |
AnoPflashlight1 (unsigned int bufSize=10) | |
Constructor. | |
void | preRender () throw () |
Pre-rendering step. | |
bool | render (flashSignal1Struct &s, unsigned int timeDiff, void *const something) throw () |
Rendering step. | |
void | renderAll (unsigned int timeDiff, void *const something) |
Renders all stored animlets, passing the given values to these. | |
Methods to override by realisation | |
virtual void | postRender () throw () |
Called after rendering the stored animlets. | |
virtual bool | deleteAnimlet (flashSignal1Struct &which) throw () |
Animlet deletion callback. | |
Data Fields | |
float | redbright [4] |
float | reddark [4] |
float | white [4] |
Used colors. | |
Protected Attributes | |
flashSignal1Struct * | myAnimletBuffer |
The allocated animlets. | |
unsigned int | myAnimletNumber |
The number of currently running animlets. | |
unsigned int | myBufferSize |
The number of allocated animlets. |
A flashing signal.
Definition at line 59 of file AnoPflashlight1.h.
AnoPflashlight1::AnoPflashlight1 | ( | unsigned int | bufSize = 10 | ) | [inline] |
Constructor.
[in] | bufSize | The number of animlets to pre-allocate |
Definition at line 64 of file AnoPflashlight1.h.
void AnoP::AnoPsystem< flashSignal1Struct >::addAnimlet | ( | flashSignal1Struct & | animlet | ) | throw () [inline, inherited] |
Adds an animlet to the list of those to render.
animlet The animlet to add
Definition at line 112 of file AnoP.h.
{ if(myAnimletNumber==myBufferSize) { int add = 10; T *newBuffer = new T[myBufferSize+add]; memcpy(newBuffer, myAnimletBuffer, sizeof(T)*myBufferSize); std::swap(myAnimletBuffer, newBuffer); myBufferSize += add; delete[] newBuffer; } myAnimletBuffer[myAnimletNumber] = animlet; ++myAnimletNumber; }
virtual bool AnoP::AnoPsystem< flashSignal1Struct >::deleteAnimlet | ( | flashSignal1Struct & | which | ) | throw () [inline, virtual, inherited] |
Animlet deletion callback.
If this callback returns true, the animlet is removed from the list of animlets to render. In the case any memory shall be freed, this method is reponsible for doing this.
Nonetheless, there may be some reason for not deleting the animlet but reinitialise it. This can be done in this method, too. false should be returned then, so that the animlet stays in the list of animlets to render.
[in] | which | The animlet to delete |
Definition at line 171 of file AnoP.h.
{ return true; }
virtual void AnoP::AnoPsystem< flashSignal1Struct >::postRender | ( | ) | throw () [inline, virtual, inherited] |
void AnoPflashlight1::preRender | ( | ) | throw () [inline, virtual] |
Pre-rendering step.
Reimplemented from AnoP::AnoPsystem< flashSignal1Struct >.
Definition at line 82 of file AnoPflashlight1.h.
{ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslated(-1,-1,0); glScaled(1./200, 1./200, 1.); glEnable (GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glDepthMask(GL_FALSE); }
bool AnoPflashlight1::render | ( | flashSignal1Struct & | s, |
unsigned int | timeDiff, | ||
void *const | something | ||
) | throw () [inline, virtual] |
Rendering step.
[in] | s | The settings of the animlet to render |
[in] | timeDiff | The time passed since last call |
[in] | something | Not used here |
Reimplemented from AnoP::AnoPsystem< flashSignal1Struct >.
Definition at line 100 of file AnoPflashlight1.h.
References AnoPhelpers::drawOutlineCircle2(), redbright, reddark, s, AnoPhelpers::sintab, and white.
{ s.step += 5; if(s.step>=360) { s.step = 0; } glPushMatrix(); glTranslated(s.pos[0], s.pos[1], 0); double scale = AnoPhelpers::sintab[s.step] / 256. / 100. + .03; glScaled(scale, scale, 1); //glScaled(.05, .05, 05); AnoPhelpers::drawOutlineCircle2(.5, 0, 36, 0, 360, white, reddark); AnoPhelpers::drawOutlineCircle2(1., 0, 36, 0, 360, redbright, reddark); glPopMatrix(); return true; }
void AnoP::AnoPsystem< flashSignal1Struct >::renderAll | ( | unsigned int | timeDiff, |
void *const | something | ||
) | [inline, virtual, inherited] |
Renders all stored animlets, passing the given values to these.
At first "preRender" is called.
Then, for each stored animlet the "render" method is called, passing the current animlet, the given time since last call, and the given additional data. In the case "render" returns false, "deleteAnimlet" is called. If "deleteAnimlet" returns true, the animlet is removed.
At the end "postRender" is called.
[in] | timeDiff | Assumed to be the time since last call |
[in] | something | Further thing that will be passed during the rendering |
Implements AnoP::AnoPsystemBase.
Definition at line 91 of file AnoP.h.
{ preRender(); for(unsigned int i=0; i<myAnimletNumber; ) { T &animlet = myAnimletBuffer[i]; if(render(animlet, timeDiff, something)) { ++i; continue; } // animlet dies... if(deleteAnimlet(animlet)) { myAnimletBuffer[i] = myAnimletBuffer[myAnimletNumber-1]; --myAnimletNumber; } } postRender(); }
flashSignal1Struct * AnoP::AnoPsystem< flashSignal1Struct >::myAnimletBuffer [protected, inherited] |
unsigned int AnoP::AnoPsystem< flashSignal1Struct >::myAnimletNumber [protected, inherited] |
unsigned int AnoP::AnoPsystem< flashSignal1Struct >::myBufferSize [protected, inherited] |
float AnoPflashlight1::redbright[4] |
Definition at line 117 of file AnoPflashlight1.h.
Referenced by AnoPflashlight1(), and render().
float AnoPflashlight1::reddark[4] |
Definition at line 117 of file AnoPflashlight1.h.
Referenced by AnoPflashlight1(), and render().
float AnoPflashlight1::white[4] |
Used colors.
Definition at line 117 of file AnoPflashlight1.h.
Referenced by AnoPflashlight1(), and render().