| 1 | // SPDX-FileCopyrightText: 2000 David Megginson |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "FGDummyTextureLoader.hxx" |
| 5 | #include <string> |
| 6 | using std::string; |
| 7 | |
| 8 | GLuint |
| 9 | FGDummyTextureLoader::loadTexture (const string& filename) { |
| 10 | GLuint texture; |
| 11 | glGenTextures (1, &texture); |
| 12 | glBindTexture (GL_TEXTURE_2D, texture); |
| 13 | |
| 14 | GLubyte image[ 2 * 2 * 3 ]; |
| 15 | |
| 16 | /* Red and white chequerboard */ |
| 17 | image [ 0] = 255; image [ 1] = 0; image [ 2] = 0; |
| 18 | image [ 3] = 255; image [ 4] = 255; image [ 5] = 255; |
| 19 | image [ 6] = 255; image [ 7] = 255; image [ 8] = 255; |
| 20 | image [ 9] = 255; image [10] = 0; image [11] = 0; |
| 21 | |
| 22 | glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, |
| 23 | GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) image); |
| 24 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 25 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 26 | |
| 27 | return texture; |
| 28 | } |