How to make OpenGL rendering scenes to switch between colors and black and white

xiaoxiao2021-03-06  18

In the first few weeks to a game company to see their game engine, I found a very interesting place. That is, they can make the game screen into black and white. At that time, my first reaction was to use Pixel Shader to make Perpixel's calculations, but I always feel inconvenient. I thought I thought I would like to be a Matrix mode called GL_Color in OpenGL. So, as long as we add the following code, you can immediately let The image rendered is black and white.

GLmatrixmode (GL_COLOR);

GLFLOAT ColorMat [16] =

{

0.3F, 0.3F, 0.3F, 0.0F,

0.5F, 0.5F, 0.5F, 0.0F,

0.2F, 0.2F, 0.2F, 0.0F,

0.0F, 0.0F, 0.0F, 3.3F,

}

GLLoadMatrixf (Colormat);

Glmatrixmode (GL_ModelView);

The code is super simple. Just don't know why, my scene is placed in some places or colored. But the basic places are black and white (add textured). Look back and take a closer look.

The picture is here, only a black and white version. No color.

http://xreal.51.net/game/heibai.jpg

转载请注明原文地址:https://www.9cbs.com/read-63440.html

New Post(0)