My routine is *not* pretty, but it works for my app. It uses fixed filter settings and a macro that clamps to my fixed texture size of 128x128. Again, not pretty and certainly not flexible. I have posted a quick executable up also for you to see this routine in action and the effect you can get (B for blur/W wireframe/PgUp/Dn to move). I *highly* recommend you write something better and use this only as a guide ;-)
hth
F451
// macro to keep gaussian blur array elements in fixed image range (128x128)#define ac(c) ((c<0)?(c+1):((c>127)?(c-1):c))// filter for gaussian blur functionfloat filter[3][3]={{0.1f,0.3f,0.1f}, {0.3f,4.0f,0.3f}, {0.1f,0.3f,0.1f}};// struct for storing RGB values of a pixel when blurringstruct RGB { float redRGB; float greenRGB; float blueRGB;};// array for storing current pixel and surrounding pixel RGB valuesRGB currRGB[3][3];// Gaussian Blur of one pixelvoid CIMAGE::GaussianBlurPixel(int x, int z){ // accumulators for RGB values float newR, newG, newB; // store current RGB values for 8 surrounding pixels plus the pixel we are working on for (int ii=-1; ii<2; ii++) { for (int jj=-1; jj<2; jj++) { GetColor2(ac(x+ii),ac(z+jj),currRGB[ii+1][jj+1].redRGB,currRGB[ii+1][jj+1].greenRGB,currRGB[ii+1][jj+1].blueRGB); } } // work neighbour pixels blending as we go for (int ii=-1; ii<2; ii++) { for (int jj=-1; jj<2; jj++) { // adjust pixels using stored values and the formula : orig+((current-orig)*filter) newR=(float)currRGB[ii+1][jj+1].redRGB+((currRGB[1][1].redRGB-currRGB[ii+1][jj+1].redRGB)*filter[ii+1][jj+1]); newG=(float)currRGB[ii+1][jj+1].greenRGB+((currRGB[1][1].greenRGB-currRGB[ii+1][jj+1].greenRGB)*filter[ii+1][jj+1]); newB=(float)currRGB[ii+1][jj+1].blueRGB+((currRGB[1][1].blueRGB-currRGB[ii+1][jj+1].blueRGB)*filter[ii+1][jj+1]); // assign new color SetColor(ac(z+jj),ac(x+ii),(unsigned char)newR,(unsigned char)newG,(unsigned char)newB); } }}// Gaussian blur of a texture or image// fixed 1 pixel blur ratio and filter settingsvoid CIMAGE::GaussianBlur(){ // blur entire image if loaded if (m_bIsLoaded) { // traverse image blurring each pixel based on neighbours for (unsigned int x=0; x<m_uiWidth; x++) { for (unsigned int z=0; z<m_uiHeight; z++) { GaussianBlurPixel(x,z); } } // remake the texture if not new if (m_ID > 0) { glBindTexture(GL_TEXTURE_2D,m_ID); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,m_uiWidth,m_uiHeight,0,GL_RGB,GL_UNSIGNED_BYTE,m_imgData); } }}