/¯
Size: a a a
/¯
CC
*texture_data = (char*)malloc(height * width * 3);
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
char* cur_pixel = (*texture_data) + 3 * (i * width + j);
char cur_char = (*normalized)[i * width + j];
int color_to_choose;
switch (cur_char)
{
case 'U':
case 'D':
case 'L':
case 'R':
color_to_choose = 2;
break;
case '#':
color_to_choose = 1;
break;
default:
color_to_choose = 0;
}
for (int k = 0; k < 3; k++)
{
cur_pixel[k] = colors[color_to_choose * 3 + k];
}
}
}
CC
CC
CC
CC
unsigned char colors[12] = {
23, 44, 56, // empty cell
200, 240, 255, // wall
128, 128, 0, // snake
23, 240, 23 // food
};
CC
unsigned char colors[12] = {
23, 44, 56, // empty cell
200, 240, 255, // wall
128, 128, 0, // snake
23, 240, 23 // food
};
CC
CC
CC
glGenerateMipmap(GL_TEXTURE_2D);
CC
CC
CC
A
glGenerateMipmap(GL_TEXTURE_2D);
A
A
CC
unsigned int main_texture;
glGenTextures(1, &main_texture);
glBindTexture(GL_TEXTURE_2D, main_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture_data);
A
A
CC