#include <FFGL.h>
#include <FFGLLib.h>
#include "FFGLTime.h"
#include <stdio.h>
static CFFGLPluginInfo PluginInfo (
FFGLTime::CreateInstance, "GTME", "FFGLTime", 1, 000, 1, 000, FF_EFFECT, "Sample FFGL Time plugin", "by Trey Harrison - www.harrisondigitalmedia.com" );
FFGLTime::FFGLTime()
: CFreeFrameGLPlugin()
{
SetMinInputs(1);
SetMaxInputs(1);
SetTimeSupported(true);
}
FFGLTime::~FFGLTime()
{
}
DWORD FFGLTime::SetTime(double time)
{
m_curTime = time;
return FF_SUCCESS;
}
DWORD FFGLTime::ProcessOpenGL(ProcessOpenGLStruct *pGL)
{
glColor4f(1.f,1.f,1.f,1.f);
if (pGL->numInputTextures<1 || pGL->inputTextures[0]==NULL)
{
glClearColor(0.f,0.f,0.f,0.f);
glClear(GL_COLOR_BUFFER_BIT);
}
else
{
FFGLTextureStruct &Texture = *(pGL->inputTextures[0]);
glBindTexture(GL_TEXTURE_2D, Texture.Handle);
glEnable(GL_TEXTURE_2D);
FFGLTexCoords maxCoords = GetMaxGLTexCoords(Texture);
glBegin(GL_QUADS);
glTexCoord2d(0.0, 0.0);
glVertex2f(-1,-1);
glTexCoord2d(0.0, maxCoords.t);
glVertex2f(-1,1);
glTexCoord2d(maxCoords.s, maxCoords.t);
glVertex2f(1,1);
glTexCoord2d(maxCoords.s, 0.0);
glVertex2f(1,-1);
glEnd();
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
}
glScalef(0.25,0.25,1.0);
glTranslatef(-2.5,-1.0,0.0);
glLineWidth(4.0);
glPointSize(4.0);
char timeString[32];
sprintf(timeString, "%.2f", m_curTime);
char *c = timeString;
while (*c)
{
switch (*c)
{
case '0': Draw0(); break;
case '1': Draw1(); break;
case '2': Draw2(); break;
case '3': Draw3(); break;
case '4': Draw4(); break;
case '5': Draw5(); break;
case '6': Draw6(); break;
case '7': Draw7(); break;
case '8': Draw8(); break;
case '9': Draw9(); break;
case '.': DrawDecimal(); break;
}
glTranslatef(1.25, 0.f, 0.f);
c++;
}
glLineWidth(1.0);
glPointSize(1.0);
glLoadIdentity();
return FF_SUCCESS;
}
void FFGLTime::Draw0()
{
glBegin(GL_LINE_LOOP);
glVertex2f(0,0);
glVertex2f(0,2);
glVertex2f(1,2);
glVertex2f(1,0);
glEnd();
}
void FFGLTime::Draw1()
{
glBegin(GL_LINE_STRIP);
glVertex2f(1,2);
glVertex2f(1,0);
glEnd();
}
void FFGLTime::Draw2()
{
glBegin(GL_LINE_STRIP);
glVertex2f(0,2);
glVertex2f(1,2);
glVertex2f(1,1);
glVertex2f(0,1);
glVertex2f(0,0);
glVertex2f(1,0);
glEnd();
}
void FFGLTime::Draw3()
{
glBegin(GL_LINE_STRIP);
glVertex2f(0,2);
glVertex2f(1,2);
glVertex2f(1,1);
glVertex2f(0,1);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(1,1);
glVertex2f(1,0);
glVertex2f(0,0);
glEnd();
}
void FFGLTime::Draw4()
{
glBegin(GL_LINE_STRIP);
glVertex2f(0,2);
glVertex2f(0,1);
glVertex2f(1,1);
glVertex2f(1,2);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(1,1);
glVertex2f(1,0);
glEnd();
}
void FFGLTime::Draw5()
{
glBegin(GL_LINE_STRIP);
glVertex2f(1,2);
glVertex2f(0,2);
glVertex2f(0,1);
glVertex2f(1,1);
glVertex2f(1,0);
glVertex2f(0,0);
glEnd();
}
void FFGLTime::Draw6()
{
glBegin(GL_LINE_STRIP);
glVertex2f(1,2);
glVertex2f(0,2);
glVertex2f(0,1);
glVertex2f(1,1);
glVertex2f(1,0);
glVertex2f(0,0);
glVertex2f(0,1);
glEnd();
}
void FFGLTime::Draw7()
{
glBegin(GL_LINE_STRIP);
glVertex2f(0,2);
glVertex2f(1,2);
glVertex2f(1,0);
glEnd();
}
void FFGLTime::Draw8()
{
glBegin(GL_LINE_LOOP);
glVertex2f(0,2);
glVertex2f(1,2);
glVertex2f(1,1);
glVertex2f(0,1);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(1,1);
glVertex2f(1,0);
glVertex2f(0,0);
glVertex2f(0,1);
glEnd();
}
void FFGLTime::Draw9()
{
glBegin(GL_LINE_LOOP);
glVertex2f(0,2);
glVertex2f(1,2);
glVertex2f(1,1);
glVertex2f(0,1);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(1,1);
glVertex2f(1,0);
glVertex2f(0,0);
glEnd();
}
void FFGLTime::DrawDecimal()
{
glBegin(GL_POINTS);
glVertex2f(0.5, 0);
glEnd();
}