Allow to set mirror repeat on textures, move texture loading into global scope
This commit is contained in:
parent
4a9653642e
commit
3141f6aca0
|
@ -72,10 +72,11 @@ const float debug_startTime = 45;
|
||||||
double totalElapsedTime = debug_startTime;
|
double totalElapsedTime = debug_startTime;
|
||||||
|
|
||||||
// textures
|
// textures
|
||||||
PNGImage t_charmap;
|
PNGImage t_charmap = loadPNGFile("../res/textures/charmap.png");
|
||||||
PNGImage t_cobble_diff;
|
PNGImage t_cobble_diff = loadPNGFile("../res/textures/cobble_diff.png");
|
||||||
PNGImage t_cobble_normal;
|
PNGImage t_cobble_normal = loadPNGFile("../res/textures/cobble_normal.png");
|
||||||
PNGImage t_perlin;
|
PNGImage t_perlin = makePerlinNoisePNG(1639*2, 44, {0.1, 0.2, 0.3});
|
||||||
|
|
||||||
|
|
||||||
void mouseCallback(GLFWwindow* window, double x, double y) {
|
void mouseCallback(GLFWwindow* window, double x, double y) {
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
|
@ -120,12 +121,6 @@ void initGame(GLFWwindow* window, CommandLineOptions gameOptions) {
|
||||||
Mesh pad = generateBox(padDimensions.x, padDimensions.y, padDimensions.z, false);
|
Mesh pad = generateBox(padDimensions.x, padDimensions.y, padDimensions.z, false);
|
||||||
Mesh sphere = generateSphere(1.0, 40, 40);
|
Mesh sphere = generateSphere(1.0, 40, 40);
|
||||||
|
|
||||||
// textures
|
|
||||||
t_charmap = loadPNGFile("../res/textures/charmap.png");
|
|
||||||
t_cobble_diff = loadPNGFile("../res/textures/cobble_diff.png");
|
|
||||||
t_cobble_normal = loadPNGFile("../res/textures/cobble_normal.png");
|
|
||||||
t_perlin = makePerlinNoisePNG(1639*2, 44, {0.1, 0.2, 0.3});
|
|
||||||
|
|
||||||
rootNode = createSceneNode();
|
rootNode = createSceneNode();
|
||||||
boxNode = createSceneNode(NORMAL_TEXTURED_GEOMETRY);
|
boxNode = createSceneNode(NORMAL_TEXTURED_GEOMETRY);
|
||||||
padNode = createSceneNode();
|
padNode = createSceneNode();
|
||||||
|
|
|
@ -104,13 +104,13 @@ void addTangents(uint vaoID, Mesh& mesh) {
|
||||||
glEnableVertexAttribArray(4);
|
glEnableVertexAttribArray(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint generateTexture(PNGImage& texture) {
|
uint generateTexture(PNGImage& texture, bool mirrored) {
|
||||||
uint id;
|
uint id;
|
||||||
glGenTextures(1, &id);
|
glGenTextures(1, &id);
|
||||||
glBindTexture(GL_TEXTURE_2D, id);
|
glBindTexture(GL_TEXTURE_2D, id);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (mirrored) ? GL_MIRRORED_REPEAT : GL_REPEAT);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (mirrored) ? GL_MIRRORED_REPEAT : GL_REPEAT);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
|
@ -8,4 +8,4 @@ unsigned int generateBuffer(Mesh &mesh, bool isNormalMapped = false);
|
||||||
|
|
||||||
void addTangents(unsigned int vaoID, Mesh& mesh);
|
void addTangents(unsigned int vaoID, Mesh& mesh);
|
||||||
|
|
||||||
unsigned int generateTexture(PNGImage& texture);
|
unsigned int generateTexture(PNGImage& texture, bool mirrored = false);
|
||||||
|
|
Loading…
Reference in New Issue