alas, i am still ill, and therefor still playing about with any code i find. here''s the radial blur stuff:
// Radial.h
#ifndef __Radial
#define __Radial
#include <windows.h>
#include <gl\glut.h>
void radInit (int texWidth, int texHeight, int winWidth, int winHeight);
void radUninit ();
void radBegin ();
void radEnd ();
void radDraw (int texRepeat, float texIncrement);
void _radViewOrtho ();
void _radViewPerspective ();
#endif
// Radial.cpp
#include "Radial.h"
unsigned int _radTexID = 0;
int _radTexWidth = 0;
int _radTexHeight = 0;
int _radWinWidth = 0;
int _radWinHeight = 0;
void radInit (int texWidth, int texHeight, int winWidth, int winHeight)
{
unsigned int* texData;
int texSize = (texWidth * texHeight) * 4 * sizeof (unsigned int);
texData = new GLuint[texSize];
ZeroMemory (texData, texSize);
glGenTextures (1, &_radTexID);
glBindTexture (GL_TEXTURE_2D, _radTexID);
glTexImage2D (GL_TEXTURE_2D, 0, 4, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
delete [] texData;
_radTexWidth = texWidth;
_radTexHeight = texHeight;
_radWinWidth = winWidth;
_radWinHeight = winHeight;
}
void radUninit ()
{
glDeleteTextures (1, &_radTexID);
}
void radBegin ()
{
glViewport (0, 0, _radTexWidth, _radTexHeight);
}
void radEnd ()
{
glBindTexture (GL_TEXTURE_2D, _radTexID);
glCopyTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, _radTexWidth, _radTexHeight, 0);
glClearColor (0.0f, 0.0f, 0.0f, 0.5);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport (0, 0, _radWinWidth, _radWinHeight);
}
void radDraw (int texRepeat, float texIncrement)
{
if (texRepeat <= 0)
return;
float spost = 0.0f;
float alphainc = 0.9f / texRepeat;
float alpha = 0.2f;
glDisable (GL_TEXTURE_GEN_S);
glDisable (GL_TEXTURE_GEN_T);
glEnable (GL_TEXTURE_2D);
glDisable (GL_DEPTH_TEST);
glBlendFunc (GL_SRC_ALPHA,GL_ONE);
glEnable (GL_BLEND);
glBindTexture (GL_TEXTURE_2D, _radTexID);
_radViewOrtho ();
alphainc = alpha / texRepeat;
glBegin (GL_QUADS);
for (int i = 0; i < texRepeat; i++)
{
glColor4f (1.0f, 1.0f, 1.0f, alpha);
glTexCoord2f (0 + spost, 1 - spost); glVertex2f (0, 0);
glTexCoord2f (0 + spost, 0 + spost); glVertex2f (0, _radWinHeight);
glTexCoord2f (1 - spost, 0 + spost); glVertex2f (_radWinWidth, _radWinHeight);
glTexCoord2f (1 - spost, 1 - spost); glVertex2f (_radWinWidth, 0);
spost += texIncrement;
alpha = alpha - alphainc;
}
glEnd ();
_radViewPerspective ();
glEnable (GL_DEPTH_TEST);
glDisable (GL_TEXTURE_2D);
glDisable (GL_BLEND);
glBindTexture (GL_TEXTURE_2D, 0);
}
void _radViewOrtho ()
{
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
glOrtho (0, 640 ,480 , 0, -1, 1);
glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity ();
}
void _radViewPerspective ()
{
glMatrixMode (GL_PROJECTION);
glPopMatrix ();
glMatrixMode (GL_MODELVIEW);
glPopMatrix ();
}
instructions:
radInit (blah, blah, blah, blah);
radBegin ();
//draw stuff
radEnd ();
//draw same stuff
radBlur (bleh, 0.02f);
makes life much easier
.
MENTAL