Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / [OpenGL] Cube map bug? Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
cyberquiet

April 20, 2005, 07:27 PM

Hi guys, after an entire day looking at the code, I came to the conclusion that OpenGL must have a bug (probably shown only with old gfx cards, I suppose).
The problem arises when I call glCopyTexSubImage on a cube-map face: the copied face content is what expected, while the other face's content become junk.
This is an outline of the code I used to make the test:

  1.  
  2. //...
  3.        
  4.         GLuint CubeMap;
  5.         glGenTextures(1, &CubeMap);
  6.        
  7.         glBindTexture(GL_TEXTURE_CUBE_MAP, CubeMap);
  8.         //LOAD THE TEXTURE DATA, SET-UP PROJECTION AND PERFORM OTHER INITIALIZATION
  9.         //STUFF
  10.                
  11.         glMatrixMode(GL_MODELVIEW);
  12.         glTranslatef(0.0f, 0.0f, -20.0f);
  13.                
  14.         Rectangle2i ScreenArea(150, 370, 210, 430);
  15.         Vector2i Offset(63, 63);
  16.        
  17.         bool loop = true;
  18.         while(loop)
  19.         {
  20.                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  21.        
  22.                 //DRAW SOMETHING ON SCREEN. THE IMPORTANT THING IS THAT THE QUADS GET
  23.                 //PROJECTED IN AN AREA AROUND (100, 400) (600, 600).
  24.                 glColor3f(1.0f, 0.0f, 0.0f);
  25.                 DrawQuad(2.0, -6.0, 6.0, 0.0, 0.0);
  26.                
  27.                 glColor3f(0.0f, 1.0f, 0.0f);
  28.                 DrawQuad(2.0, -3.0, 6.0, 0.0, 0.0);
  29.        
  30.                 glColor3f(0.0f, 0.0f, 1.0f);
  31.                 DrawQuad(2.0, 0.0, 6.0, 0.0, 0.0);
  32.        
  33.                 glColor3f(1.0f, 1.0f, 0.0f);
  34.                 DrawQuad(2.0, -6.0, 3.0, 0.0, 0.0);
  35.        
  36.                 glColor3f(1.0f, 0.0f, 1.0f);
  37.                 DrawQuad(2.0, -3.0, 3.0, 0.0, 0.0);
  38.  
  39.                 glEnable(GL_TEXTURE_CUBE_MAP);
  40.                 glBindTexture(GL_TEXTURE_CUBE_MAP, CubeMap);
  41.  
  42.                 //COMPUTE WIDTH AND HEIGHT OF AREA TO READ.
  43.                 const int AreaWidth = ScreenArea.Limit().X() - ScreenArea.Origin().X();
  44.                 const int AreaHeight = ScreenArea.Limit().Y() - ScreenArea.Origin().Y();
  45.  
  46.                 //COPY SCREEN PIXELS TO CUBE FACE.
  47.                 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
  48.                                                         0,
  49.                                                         Offset.X(),
  50.                                                         Offset.Y(),
  51.                                                         ScreenArea.Origin().X(),
  52.                                                         ScreenArea.Origin().Y(),
  53.                                                         AreaWidth,
  54.                                                         AreaHeight);
  55.                
  56.                
  57.                
  58.                                
  59.                 glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT);
  60.  
  61.                 glEnable(GL_TEXTURE_GEN_S);
  62.                 glEnable(GL_TEXTURE_GEN_T);
  63.                 glEnable(GL_TEXTURE_GEN_R);
  64.  
  65.                 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
  66.                 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
  67.                 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
  68.  
  69.                         glPushMatrix();
  70.                                 glTranslatef(0.0f, -3.0f, 0.0f);
  71.                                 //SET COLOR TO WHITE, OTHERWISE MODULATION WILL GIVE STRANGE COLORS.
  72.                                 glColor3f(1.0f, 1.0f, 1.0f);
  73.                                 //DRAW A SPHERE OF RADIUS 4.0 WITH 25 STACKS AND SLICES.
  74.                                 DrawSphere(4.0, 25, 25);
  75.                         glPopMatrix();
  76.  
  77.                 glPopAttrib();
  78.                
  79.                
  80.                 glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
  81.                 glDisable(GL_TEXTURE_CUBE_MAP);
  82.                
  83.                 //....
  84.         }
  85.        
  86.         //....
  87.  
  88.  


This is a screenshot of the rendering I got from this code:
http://utenti.quipo.it/cyberquiet/private/cube_map_screwed.jpg

And this, is the same code, with the line which calls glCopyTexSubImage commented out:
http://utenti.quipo.it/cyberquiet/private/cube_map_ok.jpg

I would like to hear your comments about this issue... Bye!!!

 
This thread contains 1 message.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.