Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×

Comment Should be called (Score -1) 41

slowin.space

The first thing everyone does when they learn OpenGL is texture map a map image in rectangular coordinates to a 3d sphere. Have fun.

/* Apply a texture image, a planetary map in a simple cylindrical
   projection in RGB format*/
static void
texture_map (const char *fname)
{
  GLubyte *image;
  GLint width, height;
  GLenum format;

  /* What are the valid sizes for the texture image? */
  /* glGetIntegerv (GL_MAX_TEXTURE_SIZE) */
  image = LoadRGBImage (fname, &width, &height, &format);

  /* check image size to see if suitable as texmap */
  info ("Texture image: width = %d, height = %d, format = %x\n",
     width, height, format);

  /* texture map is ok to apply */
  glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
  glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, width, height, 0,
        format, GL_UNSIGNED_BYTE, image);
  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glEnable (GL_TEXTURE_2D);
}

static void
solid_sphere (GLdouble radius, GLint slices, GLint stacks)
{
  glEnable (GL_CULL_FACE);
  glCullFace (GL_BACK);

  GLUquadricObj *obj = gluNewQuadric();
  gluQuadricDrawStyle (obj, GLU_FILL);
  gluQuadricNormals (obj, GLU_SMOOTH);
  gluQuadricTexture (obj, GL_TRUE);

  glNewList (Sphere, GL_COMPILE);
  gluSphere (obj, radius, slices, stacks);
  glEndList ();
}

void
define_globe (const char *teximage, float radius)
{
  texture_map (teximage);
  solid_sphere (radius, 36, 18);
}

void
draw_globe ()
{
  glEnable (GL_LIGHTING);    /* in case they aren't already */
  glEnable (GL_TEXTURE_2D);
  glCallList (Sphere);
}

Comment The indolent Greeks (Score -1) 1307

Yes, Greece owes you. The Greeks lied and stabbed Europe in the back. Isn't it interesting and freighting that a society will destroy their own banking system to preserve pensions that pensioners did not earn? It is a sobering lesson for all western democracies that make such absurd promises to their citizens. The best thing for everyone is for the Greeks to walk away from their bonds, reissue the Drachma, and start anew. Greek travel will be a great deal. They can rebuild their economy on that basis. As for the pensioners. Enjoy your Drachmas. They won't be worth the paper they are printed on.

Slashdot Top Deals

The Tao is like a glob pattern: used but never used up. It is like the extern void: filled with infinite possibilities.

Working...