not sure if i added anything
BIN
build/main
@@ -4,11 +4,10 @@ out vec4 Colour;
|
||||
in vec3 ourColor;
|
||||
in vec2 TexCoord;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D texture2;
|
||||
uniform sampler2D textureimg;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Colour = texture(texture1, TexCoord) * vec4(ourColor, 1.0f);
|
||||
Colour = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), .5);
|
||||
Colour = texture(textureimg, TexCoord) ;
|
||||
// Colour = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), 1.0f);
|
||||
}
|
||||
|
||||
58
main.cpp
@@ -186,7 +186,7 @@ int main() {
|
||||
|
||||
glViewport(0, 0, 800, 600);
|
||||
|
||||
Shader ourshader("../vertexshader.vs", "../fragmentshader.glsl");
|
||||
Shader ourshader("../vertexshader.glsl", "../fragmentshader.glsl");
|
||||
|
||||
float vertices[] = {
|
||||
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, // cube one
|
||||
@@ -299,7 +299,7 @@ int main() {
|
||||
std::vector<SphereVertex> sphereVerts;
|
||||
std::vector<unsigned int> sphereIndices;
|
||||
|
||||
float ballRadius = 0.1f;
|
||||
float ballRadius = 0.05f;
|
||||
|
||||
generateSphere(ballRadius, 36, 18, sphereVerts, sphereIndices);
|
||||
|
||||
@@ -343,10 +343,11 @@ int main() {
|
||||
GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
unsigned char *image =
|
||||
stbi_load("../container.jpg", &width, &height, &nrChannels, 0);
|
||||
unsigned char *image = stbi_load("../sources/textures/w65b_2.png", &width,
|
||||
&height, &nrChannels, 0);
|
||||
if (image) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
|
||||
GLenum format = (nrChannels == 4) ? GL_RGBA : GL_RGB;
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format,
|
||||
GL_UNSIGNED_BYTE, image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
} else {
|
||||
@@ -363,9 +364,11 @@ int main() {
|
||||
GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
image = stbi_load("../awesomeface.png", &width, &height, &nrChannels, 0);
|
||||
image = stbi_load("../sources/textures/brks_y.png", &width, &height,
|
||||
&nrChannels, 0);
|
||||
if (image) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA,
|
||||
GLenum format = (nrChannels == 4) ? GL_RGBA : GL_RGB;
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format,
|
||||
GL_UNSIGNED_BYTE, image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
} else {
|
||||
@@ -373,8 +376,7 @@ int main() {
|
||||
}
|
||||
stbi_image_free(image);
|
||||
ourshader.use();
|
||||
ourshader.setInt("texture1", 0);
|
||||
ourshader.setInt("texture2", 1);
|
||||
ourshader.setInt("textureimg", 0);
|
||||
|
||||
// defines a model matrix which will rotate the plane
|
||||
// ourshader.setMat4("mvp", glm::mat4(1.0f));
|
||||
@@ -403,10 +405,11 @@ int main() {
|
||||
ballVelocity.x *= 0.9f;
|
||||
ballVelocity.z *= 0.9f;
|
||||
}
|
||||
printf("ball: \nx:%f\ny:%f\nz:%f\n", ballPosition.x, ballPosition.y,
|
||||
ballPosition.z);
|
||||
printf("camera: \nx:%f\ny:%f\nz:%f\n", camera.Position.x, camera.Position.y,
|
||||
camera.Position.z);
|
||||
// printf("ball: \nx:%f\ny:%f\nz:%f\n", ballPosition.x, ballPosition.y,
|
||||
// ballPosition.z);
|
||||
// printf("camera: \nx:%f\ny:%f\nz:%f\n", camera.Position.x,
|
||||
// camera.Position.y,
|
||||
// camera.Position.z);
|
||||
|
||||
// matrix transformations, remember to do them in reverse order to what
|
||||
// you want glm::mat4 trans = glm::mat4(1.0f); trans =
|
||||
@@ -416,14 +419,12 @@ int main() {
|
||||
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_CULL_FACE);
|
||||
// glDisable(GL_CULL_FACE);
|
||||
|
||||
// use our shader program before passing in the uniform
|
||||
ourshader.use();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture1);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, texture2);
|
||||
|
||||
// model = glm::translate(
|
||||
@@ -450,8 +451,7 @@ int main() {
|
||||
if (worldMap[x][y] > 0) {
|
||||
// Set Texture
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D,
|
||||
(worldMap[x][y] == 1) ? texture1 : texture2);
|
||||
glBindTexture(GL_TEXTURE_2D, texture2);
|
||||
if (y + 1 < MAP_HEIGHT && worldMap[x][y + 1] == 0) {
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
model = glm::translate(
|
||||
@@ -514,28 +514,6 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
// for (unsigned int i = 0; i < 10; i++) {
|
||||
//
|
||||
// glm::mat4 model = glm::mat4(1.0f);
|
||||
// model = glm::translate(model, cubePositions[i]);
|
||||
// float angle = 20.0f * i;
|
||||
//
|
||||
// if ((i + 1) % 3 == 0) {
|
||||
// angle = glfwGetTime() * 25.0f;
|
||||
// model = glm::rotate(model, glm::radians(angle),
|
||||
// glm::vec3(0.5f, 1.0f, 0.3f));
|
||||
// } else {
|
||||
//
|
||||
// model = glm::rotate(model, glm::radians(angle),
|
||||
// glm::vec3(0.5f, 1.0f, 0.3f));
|
||||
// }
|
||||
//
|
||||
// glm::mat4 mvp = projection * view * model;
|
||||
//
|
||||
// ourshader.setMat4("mvp", mvp);
|
||||
// glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
// }
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
BIN
sources/textures/bkred_1.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
sources/textures/brik_1.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
sources/textures/brik_2.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
sources/textures/brik_3.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
sources/textures/brik_4.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
sources/textures/brik_5.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
sources/textures/brik_6.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
sources/textures/brik_7.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
sources/textures/brks_00.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
sources/textures/brks_1.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
sources/textures/brks_2.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
sources/textures/brks_3.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
sources/textures/brks_4.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
sources/textures/brks_6.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
sources/textures/brks_7.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
sources/textures/brks_8.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
sources/textures/brks_b.png
Normal file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
sources/textures/brks_g.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
sources/textures/brks_r.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
sources/textures/brks_y.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
sources/textures/con_01.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
sources/textures/con_02.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
sources/textures/con_03.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
sources/textures/con_04.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
sources/textures/door_02.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sources/textures/door_1.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sources/textures/door_3.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
sources/textures/emb_01.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
sources/textures/emb_02.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
sources/textures/lift1.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
sources/textures/lift2.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
sources/textures/marb1.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
sources/textures/marb2.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
sources/textures/marb3.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
sources/textures/marb4.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
sources/textures/plntwtr.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
sources/textures/sky1.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
sources/textures/sky2.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
sources/textures/sky3.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
sources/textures/sky4.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
sources/textures/support2.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
sources/textures/sw11_2.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
sources/textures/sw11_4.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
sources/textures/sw11_5.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
sources/textures/sw12_4.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
sources/textures/sw12_5.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
sources/textures/sw17_4.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
sources/textures/sw17_5.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
sources/textures/sw17_6.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
sources/textures/sw18_5.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
sources/textures/sw18_7.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
sources/textures/sw19_3.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
sources/textures/sw19_4.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sources/textures/sw4s0.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
sources/textures/sw4s1.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
sources/textures/t14_3.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
sources/textures/tech1.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
sources/textures/tomw2_2.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
sources/textures/tscrn2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
sources/textures/tscrn3.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
sources/textures/tscrn4.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
sources/textures/tscrn5.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
sources/textures/tscrn6.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
sources/textures/tscrn8.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
sources/textures/ttall1_2.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
sources/textures/tux.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
sources/textures/vgcrate1.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
sources/textures/w104_1.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sources/textures/w13_1.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
sources/textures/w13_8.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
sources/textures/w13_a.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
sources/textures/w15_4.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
sources/textures/w15_5.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
sources/textures/w15_6.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
sources/textures/w17_1.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
sources/textures/w28_5.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
sources/textures/w28_6.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
sources/textures/w28_7.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
sources/textures/w28_8.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
sources/textures/w31_1.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
sources/textures/w32_1.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
sources/textures/w32_4.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
sources/textures/w33_5.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
sources/textures/w33_7.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
sources/textures/w33_8.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
sources/textures/w46_37.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
sources/textures/w46_38.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
sources/textures/w46_39.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
sources/textures/w64b_1.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
sources/textures/w64b_2.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
sources/textures/w65b_2.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
sources/textures/w67_1.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
sources/textures/wall01_b.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
sources/textures/wall01_c.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
sources/textures/wall02_1.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
sources/textures/wall02_2.png
Normal file
|
After Width: | Height: | Size: 18 KiB |