开发者

glColor3i only drawing black

开发者 https://www.devze.com 2023-01-21 00:07 出处:网络
Why does this only draw black? glPushMatrix(); // Check the current color glColor3i(255, 0, 255); GLint currentColor[4];

Why does this only draw black?

 glPushMatrix();
 // Check the current color
 glColor3i(255, 0, 255);
 GLint currentColor[4];
 glGetIntegerv(GL_CURRENT_COLOR, currentColor);
 //currentColor[0] = 254, 1 = 0, 2 = 254, 3 = doesn't matter

 glBegin(GL_QUADS);
 glLineWidth(1);
  glVertex2f(0, 0);
  glVertex2f(WINDOW_WIDTH * .1, 0);
  glVertex2f(WIN开发者_Go百科DOW_WIDTH * .1, WINDOW_HEIGHT);
  glVertex2f(0, WINDOW_HEIGHT);
 glEnd();
 glPopMatrix();


From memory, I think that glColor3i uses colour values that are scaled to cover the full integer range. Hence your 255 values are approximately equal to zero.....

Try 2147483647 instead.


All typed integral gl entrypoints have this range behavior. Floating point variants use normalized values: 0.0 - 1.0. glColor sets the current vertex color which even affects the output during vertex array processing if glColorPointer is not enabled (if indeed your version of GL uses named vertex attributes and not generic as in OpenGLES 2.x and greater).

Common variants for glColor are glColor{3,4}{u,b} and glColor{3,4}f.

In your case you should stick to your 0xFF values and use glColor3ub(255, 0, 255) or perhaps easier glColor3f(1.0f, 0.0f, 1.0f).

Using an integral value of INT_MAX or ~2 billion in conjunction with glColor3i() doesn't read very well.

0

精彩评论

暂无评论...
验证码 换一张
取 消