From 18dbb1576abc6eadd9eeb5b5dd29205d33f8276e Mon Sep 17 00:00:00 2001 From: psperl Date: Mon, 30 Jun 2008 03:04:41 +0000 Subject: [PATCH] Video Echo Classes git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1078 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/VideoEcho.cpp | 90 +++++++++++++++++++++++++++++++ src/projectM-engine/VideoEcho.hpp | 31 +++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/projectM-engine/VideoEcho.cpp create mode 100644 src/projectM-engine/VideoEcho.hpp diff --git a/src/projectM-engine/VideoEcho.cpp b/src/projectM-engine/VideoEcho.cpp new file mode 100644 index 000000000..185103caf --- /dev/null +++ b/src/projectM-engine/VideoEcho.cpp @@ -0,0 +1,90 @@ +/* + * VideoEcho.cpp + * + * Created on: Jun 29, 2008 + * Author: pete + */ +#ifdef USE_GLES1 +#include +#else +#ifdef __APPLE__ +#include +#include +#else +#include +#include +#endif +#endif + +#include "VideoEcho.hpp" + +VideoEcho::VideoEcho(): a(0), zoom(1), orientation(Normal) +{ + // TODO Auto-generated constructor stub + +} + +VideoEcho::~VideoEcho() +{ + // TODO Auto-generated destructor stub +} + +void VideoEcho::Draw(RenderContext &context) +{ + + + glEnable(GL_TEXTURE_2D); + + + float tex[4][2] = {{0, 1}, + {0, 0}, + {1, 0}, + {1, 1}}; + + float points[4][2] = {{-0.5, -0.5}, + {-0.5, 0.5}, + { 0.5, 0.5}, + { 0.5, -0.5}}; + + glEnableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glVertexPointer(2,GL_FLOAT,0,points); + glTexCoordPointer(2,GL_FLOAT,0,tex); + + //Now Blend the Video Echo + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glMatrixMode(GL_TEXTURE); + + //draw video echo + glColor4f(1.0, 1.0, 1.0, a); + glTranslatef(.5, .5, 0); + glScalef(1.0/zoom, 1.0/zoom, 1); + glTranslatef(-.5, -.5, 0); + + int flipx=1, flipy=1; + switch (orientation) + { + case Normal: flipx=1;flipy=1;break; + case FlipX: flipx=-1;flipy=1;break; + case FlipY: flipx=1;flipy=-1;break; + case FlipXY: flipx=-1;flipy=-1;break; + default: flipx=1;flipy=1; break; + } + + float pointsFlip[4][2] = {{-0.5*flipx, -0.5*flipy}, + {-0.5*flipx, 0.5*flipy}, + { 0.5*flipx, 0.5*flipy}, + { 0.5*flipx, -0.5*flipy}}; + + glVertexPointer(2,GL_FLOAT,0,pointsFlip); + glDrawArrays(GL_TRIANGLE_FAN,0,4); + + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + +} diff --git a/src/projectM-engine/VideoEcho.hpp b/src/projectM-engine/VideoEcho.hpp new file mode 100644 index 000000000..13f027e35 --- /dev/null +++ b/src/projectM-engine/VideoEcho.hpp @@ -0,0 +1,31 @@ +/* + * VideoEcho.hpp + * + * Created on: Jun 29, 2008 + * Author: pete + */ + +#ifndef VIDEOECHO_HPP_ +#define VIDEOECHO_HPP_ + +#include "Renderable.hpp" + +enum Orientation +{ + Normal=0, FlipX, FlipY, FlipXY +}; + +class VideoEcho: public RenderItem +{ +public: + VideoEcho(); + virtual ~VideoEcho(); + + float a; + float zoom; + Orientation orientation; + + void Draw(RenderContext &context); +}; + +#endif /* VIDEOECHO_HPP_ */