Proxy question from Facebook blender artists group* Does stencil buffer work in BGE?

Does stencil buffer work in BGE? I mean there are functions for it in bgl module but anyone got it working? I’m having problem with it. No matter what value I set the for glStencilFunc, the stencil buffer seems unaffected even if GL_STENCIL_TEST is enabled.

code sample - http://pastebin.com/ha37tKqY

Another question to this thread

Why is texture colour changing in BGL?

I’m loading a texture into a simple GL_QUAD drawn with OpenGL with the help of bgl and bge.texture modules in Blender. The texture loads but the colour of the texture changes, most of the parts are black, blues are rendered red and so on.
Following is the code for loading the texture:
<pre>

import bge
import bgl
from bge import logic, texture

def loadTex():
if objbuf is not None:
bgl.glEnable(bgl.GL_TEXTURE_2D)
texBuf = bgl.Buffer(bgl.GL_INT, 1)
bgl.glGenTextures(1, texBuf)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, texBuf.to_list()[0])
bgl.glTexImage2D(bgl.GL_TEXTURE_2D, 0, bgl.GL_RGBA, 48, 48, 0,
bgl.GL_RGBA, bgl.GL_BYTE, objbuf)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER,
bgl.GL_LINEAR)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER,
bgl.GL_LINEAR)
bgl.glBegin(bgl.GL_QUADS);
bgl.glNormal3f(0, 0, 2)
bgl.glTexCoord2d(1, 0); bgl.glVertex3f(1, -1, 1.2)
bgl.glTexCoord2d(0, 0); bgl.glVertex3f(1, 1, 1.2)
bgl.glTexCoord2d(0, 1); bgl.glVertex3f(-1, 1, 1.2)
bgl.glTexCoord2d(1, 1); bgl.glVertex3f(-1, -1, 1.2)
bgl.glEnd()
bgl.glDeleteTextures(1, texBuf)
bgl.glDisable(bgl.GL_TEXTURE_2D)

obj = logic.getCurrentController().owner
if not obj.scene.post_draw:
# face.png is a 48x48 PNG image
obj[“buf”] = texture.imageToArray(texture.ImageFFmpeg(
logic.expandPath("//face.png")), “RGBA”)
objbuf = obj[“buf”]
obj.scene.post_draw = [loadTex]
</pre>
Here is the original image: /uploads/default/original/4X/4/5/9/459824a460b10f1abd8c58683f06830b61a23619.pngstc=1

and here is the loaded texture:

Excuse the mirroring of texture, I used mirrored textured coordinates. Can anyone help me figure this out? Thanks.

Attachments