in source/viewer/MenuScreen.h [72:128]
void setupShaders() {
static const GLchar* VertexShaderSrc =
"#version 150\n"
"uniform mat4 matWVP;\n"
"in vec4 Position;\n"
"in vec4 Color;\n"
"in vec2 TexCoord;\n"
"out vec2 oTexCoord;\n"
"out vec4 oColor;\n"
"void main()\n"
"{\n"
" gl_Position = (matWVP * Position);\n"
" oTexCoord = TexCoord;\n"
" oColor.rgb = pow(Color.rgb, vec3(2.2));\n" // convert from sRGB to linear
" oColor.a = Color.a;\n"
"}\n";
static const char* FragmentShaderSrc =
"#version 150\n"
"uniform sampler2D Texture0;\n"
"in vec4 oColor;\n"
"in vec2 oTexCoord;\n"
"out vec4 FragColor;\n"
"void main()\n"
"{\n"
" FragColor = oColor * texture2D(Texture0, -oTexCoord + vec2(0.5, 0.5));\n"
"}\n";
GLuint vshader = CreateShader(GL_VERTEX_SHADER, VertexShaderSrc);
GLuint fshader = CreateShader(GL_FRAGMENT_SHADER, FragmentShaderSrc);
static const std::string kLogoFilename = "logo.png";
static const int kDstChannels = 4;
int width, height, channels;
uint8_t* textureBytes =
stbi_load(kLogoFilename.c_str(), &width, &height, &channels, kDstChannels);
if (!textureBytes) {
std::cout << "ERROR LOADING LOGO TEXTURE: " << kLogoFilename << std::endl;
static uint8_t dummy[] = {
255,
0,
0,
0,
};
textureBytes = dummy;
width = 1;
height = 1;
channels = 4;
}
TextureBuffer* generated_texture =
new TextureBuffer(false, Sizei(width, height), 4, (unsigned char*)textureBytes);
gridMaterial = new ShaderFill(vshader, fshader, generated_texture);
glDeleteShader(vshader);
glDeleteShader(fshader);
}