PDA

View Full Version : Replacement of glFeedbackBuffer in ogl 3.3 nd abve



mobeen
01-17-2011, 09:53 PM
Hi all,
What is the replacement of glFeedbackBuffer in opengl 3.3 since the core profile has removed it. I want to obtain the screen space position of my mesh. From my survey it seems that I would need to do it manually which shouldn't be difficult. Multiply the objects geometric center by the MVP matrix and then do the homogeneous division and finally viewport transform to get the screen coordinate. Am I correct. So putting it in GLSL syntax, it should be this,


vec3 center = GetCenter(pMesh);
vec4 center_clip_space = MVP*vec4(center,1);
center_clip_space.xyz/=center_clip_space.w;
vec2 half_dim = vec2(viewport.width,viewport.height)*0.5;
vec2 screen_space = (center_clip_space.xy * half_dim) + half_dim; //brings the screen space coord. to viewport size in XY


One more thing, is there any place which list the deperecated/removed func. and their replacements?

Thanks,
Mobeen

mobeen
01-18-2011, 12:35 AM
OK i am not getting the correct result. I give an example here:


os_pos = (-10,0,-30,1);
MVP=[ 1.8107 0 0 0
0 0.0001 -1.0010 -1.0000
0 -2.4142 0 0
-18.1066 0 20.0250 30.0000];
cs_pos = MVP*os_pos; //which is
cs_pos = (-18.106602, 29.030016, 0.0013448675,-389.68439);
ndc = cs_pos.xyz/cs_pos.w;// which is
ndc = (0.046464786, -0.074496225, -3.4511711e-006, 1.0);

after viewport transform I get (335,222) pixel coordinates

Now doing the same calc. with another object at


os_pos=(10,0,-30,1);
MVP=[1.8107 0 0 0
0 0.0001 -1.0010 -1.0000
0 -2.4142 -0.0000 -0.0000
18.1066 0 20.0250 30.0000]
gives me clip space pos (18.106602,29.030016, 0.0013448675,-389.68439) and after homogenous division gives me,
-0.046464786,-0.074496225,-3.4511711e-006,1.0).


After viewport transform, I get pixel coordinates(305,222). So i suspect there is something wrong. Any ideas?
Note that my viewport size is 640 x 480. I expect the coordinates to be closer to (120,240) for the first object and (520,240) What Am i doing wrong?

mobeen
01-18-2011, 02:36 AM
OK got it working. My vector matrix multiplication func. was multiplying the matrix wrongly. It works fine now.