From: doug s. <hig...@ho...> - 2009-08-29 16:49:11
|
MUFTI, Anaglyph 7 - color2gray interceptor Goal: swap function pointers for glColor/glMaterial/glLight and glTexImage2D/gluBuildMipMaps so as to intercept color settings and apply NTSC lookups from color to gray in a minimally invasive way, and so non-anaglyph modes don't suffer. Then apply glColorMask as in the drawGray method. Implementation in a test program: I found the functions I needed to swap weren't glew pointers. Trying to re-assign a function pointer to a function failed. glColor4fv = myColor4fv; //error left side is a function, not a function pointer What did work: refactoring the code to replace glColor4fv with Pglcolor4fv. Then 1) init(){ Pglcolor4fv = glColor4fv; } //OK 2) swap(){ Pglcolor4fv = myColor4fv; } //OK PglColor4fv(colors); //OK void __stdcall myColor4fv(float *fc) //there's a macro for __stdcall thats portable { float gray; float fv[4]; int i; gray = 0.299f*fc[0] + .587f*fc[1] + .114f*fc[2]; for(i=0;i simple masking, almost^^ == copyTexture * Speed == simple masking (fast) x requires code refactoring in scengraph ^^ By almost I mean in theory if the color interception was applied to lights and materials then the result would be as bright or brighter than the copyTexture (highest quality) method. That's because color2gray(light * material) != color2gray(light) * color2gray(material) the former being proper method - what I'd get with the copyTexture approach, and the latter being what I get with the color interceptor method. -D _________________________________________________________________ Stay on top of things, check email from other accounts! http://go.microsoft.com/?linkid=9671355 |