Jump to content
  • Advertisement
Sign in to follow this  
McZ

Texture projection for a flashlight

This topic is 4510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have google the net but I can't find any good tutorial or easy explaination for how to create a flashlight using texture projection or something. I don't want to use any hardware specefic extensions. GLSL would be interesting altough I have never used it.

Share this post


Link to post
Share on other sites
Advertisement
Thank you.

if I understand correct it would be something like this to create a flashlight using texture projection:


// Bind texture
...

// Calculate projection matrix
CMatrix texProj, camView, camProj, bias(0.5,0.0,0.0,0.0,
0.0,0.5,0.0,0.0,
0.0,0.0,0.5,0.0,
0.5,0.5,0.5,1.0);

camView = Camera->getMatrix(MODELVIEW);
camProj = Camera->getMatrix(PROJECTION);

texProj = camView * camProj * bias;

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, texProj.getRow(0));
glEnable(GL_TEXTURE_GEN_S);

glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_T, GL_EYE_PLANE, texProj.getRow(1));
glEnable(GL_TEXTURE_GEN_T);

glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_R, GL_EYE_PLANE, texProj.getRow(2));
glEnable(GL_TEXTURE_GEN_R);

glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_Q, GL_EYE_PLANE, texProj.getRow(3));
glEnable(GL_TEXTURE_GEN_Q);

// Draw objects
...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!