Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

666_1337

this whole google shit and openGL lighting

This topic is 5577 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 started this google-shit to send up those who keep this formus full with questions like "what means & in C" or "how can i write 3d games in html". i thought it would be funny to see what will be written into something really lame. but i think now it's all getting out of control. ... AND WHO IS "dobeneck" ? now to the question... i wrote a terrain engine that supports lots of nice thingies, so i don't want to rewrite it. i use vertex-, normal-, and tex-coords arrays. all normals are set well, and if i make the lighing calculations with the fpu (yes, i extended my algoritm), anything works fine. but if i use the openGL functions to calculate lighting, only those vertices are lit, that have a z-Coordinate greater or equal to the light source (in the modelview matrix). i have no idea what i'm doing wrong. (is there any way to upload a picture here)??? if i let the light source be a spotlight, that rotates over time, i see those vertices with greater z-coord beeing lit with the usual nasty spotlight (no per pixel lighting) effects to the vertices beeing lit normaly. at those verices that lie on the line (z = lightpos -> z) there are really good looking shades. i use linux 2.4.20, a nVidia geforce 4 ti 4200 and the newest detonator (the older one's show the same thing). somebody has had the same problems before? or knows the errors?
  
  /*intialization*/
  float l[4] = {0.0f, 35.0f, 0.0f, 1.0f};
  glLightfv(GL_LIGHT0, GL_POSITION, l);
  glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 1e-5f);

  /*the drawing function*/
  float spot_dir[3] = {sin(rotation_light0), -1.0f, cos(rotation_light0)};
  glLightf (GL_LIGHT0, GL_SPOT_CUTOFF, 45.0f);
  glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_dir);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);

  /*i think this isn't important here*/
  glClientActiveTextureARB(GL_TEXTURE0_ARB);
  glActiveTextureARB(GL_TEXTURE0_ARB);
  glBindTexture(GL_TEXTURE_2D, texmgr -> terrain_texture);
  glEnable(GL_TEXTURE_2D);  
  
  glClientActiveTextureARB(GL_TEXTURE1_ARB);
  glActiveTextureARB(GL_TEXTURE1_ARB);
  glBindTexture(GL_TEXTURE_2D, texmgr -> detail_texture);
  glEnable(GL_TEXTURE_2D);

  for(int i = 0; i < TERRAIN_GRID_WIDTH * TERRAIN_GRID_HEIGHT / 64; i++)
   {
	if(vf -> sphereIsInside(point3f(occ_nodes[i].xPos, occ_nodes[i].yPos, occ_nodes[i].zPos), occ_nodes[i].radius))
	  glCallList(occ_nodes[i].displayListsID);
   }

  glDisable(GL_TEXTURE_2D);
  glClientActiveTextureARB(GL_TEXTURE0_ARB);
  glActiveTextureARB(GL_TEXTURE0_ARB);
  glDisable(GL_TEXTURE_2D);
  glDisable(GL_LIGHTING);

    
[edited by - 666_1337 on March 17, 2003 1:45:07 PM]

Share this post


Link to post
Share on other sites
Advertisement

  • 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!