Advertisement

Lensflares: Object in Space --> 2d ScreenCoord

Started by July 17, 2003 08:01 AM
9 comments, last by stryx 21 years, 7 months ago
hi guys, i got a problem.. I know how to do lensflares.. but i got 1 simple problem.. I got the position of the light in my world but i don''t know how to get the 2d-screen coordinates. somebody pointed me to gluProtect/UnProtect. But I have no idea how to use them. Can anyone help me ? thx in advance. stryx
Anything that requires finding convex hulls in realtime isstarting to sound like a bad idea. -- John Carmack
gluProject discription: http://www.ncart.scs.ryerson.ca/XFree86/4.1.0/gluProject.3.html

for the nessecary matrices use:

GLint view[4];
GLdouble model[16], proj[16];

glGetDoublev( GL_MODELVIEW_MATRIX, model );
glGetDoublev( GL_PROJECTION_MATRIX, proj );
glGetIntegerv( GL_VIEWPORT, view );


this should get you on your way.
don''t piss on an electrical fence
Advertisement
__Corrupt__, I didn''t know this function, it looks very interesting to me (should help for picking) but do you know if it''s fast ? I couldn''t see the equation used to compute the coordinates but it should be something like the vertex coordinates multiplied by the 3 matrix products ?
Yeah its fairly fast. GLunproject is a good way to go for ray picking.
I heard most glu* funcs are pretty slow.
Maybe try out doing your sw transform by the composite modelview-projection matrix. There may (will?) be some minimal differences between the real displayed position and the computed position but this should not be a problem.

Previously "Krohm"

You can do the math manually, but a friend tried this and told me it had the same hit in cpu usage.
Advertisement
the glu(Un)Project functions are pretty fast. you can use them for picking and stuff without any slowdowns/problems/whatever.

a sample implementation of all glu-functions can be found here:

http://sourceforge.net/projects/mesa3d

just download the MesaLib.zip

see: src-glu/project.c for glu(un)project
don''t piss on an electrical fence
THANX 4 your help !
it works !
u don''t believe me ?
here''s a little shot:



thankx once more !
gr33z, stryx

PS: sorry for this 1337 post ) but i''m r34lly h4ppY
Anything that requires finding convex hulls in realtime isstarting to sound like a bad idea. -- John Carmack
Where to find lens flare textures?
I searched for them a lot with no success!

Previously "Krohm"

Lensflare looks very nice

glad i could help.
don''t piss on an electrical fence

This topic is closed to new replies.

Advertisement