not sure if i added anything

This commit is contained in:
2026-02-26 21:40:59 -05:00
parent 328f839da8
commit 8f416364c3
131 changed files with 21 additions and 50 deletions

View File

@@ -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);