Filter2D on GL drawings?

Hey everyone,

I draw some points on screen with the bgl modul. I applied a custom 2D Filter onto my camera, but the GL drawings aren’t effected. My guess is that it has to do something wiht the pipeline of how and when things are calculated.

Anyway, is there a way to apply 2D filters onto GL stuff?

The problem is that are the 2D filters are appied befor you render your points with the bgl modu (post_draw).
It will work if you render your points in pre_draw, but then the scene objects wil be drawn over the points.

The easiest way would be to write a 2D filter which wil draw your points. Then you can apply your other filters on top of it.

You can also make an overlay scene where you apply your 2D Filter.

Hi everyone, i make some rough experiment.

for the blend test :
1)you run the blend file as usual
2)you wait for the red rectangle appear (the bgl one)
3)then you press Space bar for running the 2D filter

bgl library run independantly from bge.

bgl seem to work directly on the graphics card.

we can directly run gl.py in the console witout runing bge
(Ctrl C / Ctrl V the gl.py code in the python console )
(and you crunch blender …)

gl.py code

import bgl
# OpenGL setup 
width = 200
height = 150 
bgl.glMatrixMode(bgl.GL_PROJECTION) 
bgl.glLoadIdentity() 
bgl.gluOrtho2D(0, width, 0, height) 
bgl.glMatrixMode(bgl.GL_MODELVIEW) 
bgl.glLoadIdentity() 


# Draw a 2D rectangle to make the fonts stand out 
bgl.glEnable(bgl.GL_BLEND)# Enable alpha blending 
bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA) 
view_buf = bgl.Buffer(bgl.GL_INT, 4) 
bgl.glGetIntegerv(bgl.GL_VIEWPORT, view_buf) 
view = view_buf 
bgl.glMatrixMode(bgl.GL_PROJECTION) 
bgl.glLoadIdentity() 
bgl.gluOrtho2D(0, view[2], 0, view[3]) 
bgl.glMatrixMode(bgl.GL_MODELVIEW) 
bgl.glLoadIdentity() 
bgl.glBegin(bgl.GL_QUADS) 
bgl.glColor4f(2, 0, 0, 1) 
bgl.glVertex2f(15, (height/2)-22) 
bgl.glVertex2f(width -12, (height/2)) 
bgl.glVertex2f(width - 2, (height/2+22) + 21) 
bgl.glVertex2f(5, int(height/2) + 21) 
bgl.glEnd() 

bgl library : 1705 entry

HG1 do you have .blend example ?

Attachments

test_gl.blend (503 KB)

HG1 do you have .blend example ?

I modified your example.

Attachments

test_gl_ mod_HG1.blend (97 KB)

interesting,

thanks for the rapid answer and the .blend example.

Jolo

Thanks a lot