Login or Signup

image processing with glsl shaders

BlitzMax Forums/OpenGL Module/image processing with glsl shaders

TWH1+ years ago #1

I've converted the image processing example from the OpenGL Superbible.
Chapter 23 in the 3. edition.
Chapter 17 in the 4. edition.

I removed the teapot from the scene and replaced it with a cone.

I began with Tom Speed / ChrisC's glsl.bmx, but I couldn't get the program to render to texture. So I converted the shaderloaders from the book. glsl.bmx would have worked. The problem was me not setting the texture size properly.. It appeared that I had a 0x512 texture ><

Here all the code is, copy-paste-n-run ;), with a freelook camera I got from this gamedev.net article:


OR. Download a zip file with the code and the 8 shaders

The code would not compile in release mode because of
?debug <- changed to "?" only
This error gave me "expecting expression but encountered end-of-file"

Also, I had commented out 'glClear(GL_COLOR_BUFFER_BIT); when doing the rendering passes for the filters. But this didn't seem to make a change.

Also. I've added an FPS counter

The fragment shader programs:
// pass through a single texel value
uniform sampler2D sampler0;

void main(void)
    gl_FragColor = texture2D(sampler0, gl_TexCoord[0].st);








You can download the orignal source from the books website:

ImaginaryHuman1+ years ago #2
Cool, thanks. The superbible is a great book.

TWH1+ years ago #3
It is!

I've now added a textured quad. "texture.jpg"

Press space (or 1) to toggle filter.

The shaders are the same as before.

Scienthsine1+ years ago #4
Are the OpenGL shader functions like glShaderSourceARB and glGetObjectParameterivARB a part of BMax now?

Been away awhile, and not at home atm.

plash1+ years ago #5
Are the OpenGL shader functions like glShaderSourceARB and glGetObjectParameterivARB a part of BMax now?
A part of pub.glew, so yes.

Scienthsine1+ years ago #6
w00t, yays

FreakForFreedom1+ years ago #7
very nice, thanks for sharing

Uncle1+ years ago #8

Has anyone managed to get this working on a Mac? I've managed to get it rendering but its not working properly. All the shaders seem to do is colour everything blue? Also the program fails on the OpenGL 1.3 check. My Mac should be at least 1.4 compliant, but the check fails.



PS the graphics card is a GMA 950 I think.

RupeB1+ years ago #9
Yep got this working perfectly on a Mac. 6 years later I can confirm this, maybe changes to BlitzMAX through these years have happened to make it so. But it does works now.

Kimor1+ years ago #10
Maybe a VBO would work but Im trying to convert this now,
where GPU is used for the actual tiling in every possible way.

We'll see how that goes.


The primary reason is that ever teeny weeny work is put onto the GPU here, and I kind of like that.

Blitz Social Club