This commit is contained in:
2026-04-23 11:33:46 +10:00
parent ddaf8d1003
commit 8d735b57dc
3 changed files with 37 additions and 11 deletions

View File

@@ -29,5 +29,5 @@ void main()
vec3 specular = specularStrength * spec * lightColor;
vec3 result = (ambient + diffuse + specular) * objectColor;
FragColor = vec4(result, 1.0);
FragColor = vec4(result*10, 1.0);
}

BIN
app

Binary file not shown.

View File

@@ -6,10 +6,21 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include <chrono>
#include <random>
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
#define w 1280
#define h 720
int randint(std::mt19937_64& rng, int lbound, int ubound)
{
return rng() % (ubound-lbound + 1) + lbound;
}
void input(GLFWwindow *window);
float vertices[] = {
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,0.0f,-1.0f,
@@ -56,10 +67,6 @@ void input(GLFWwindow *window);
};
glm::vec3 cubePositions[] = {
glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(2.0f, 5.0f, -15.0f),
glm::vec3(-1.5f, -2.2f, -2.5f), glm::vec3(-3.8f, -2.0f, -12.3f),
glm::vec3(2.4f, -0.4f, -3.5f), glm::vec3(-1.7f, 3.0f, -7.5f),
glm::vec3(1.3f, -2.0f, -2.5f), glm::vec3(1.5f, 2.0f, -2.5f),
glm::vec3(1.5f, 0.2f, -1.5f), glm::vec3(-1.3f, 1.0f, -1.5f)};
int main() {
@@ -130,6 +137,25 @@ int main() {
s.use();
s.setInt("texture0", 0);
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 rng(seed);
std::cout << randint(rng,-100,100) << std::endl;
glm::vec3 cubePos[60000];
int x,y,z;
for (int i = 0; i < 5000; i++)
{
x = randint(rng,-100,100);
y = randint(rng,-100,100);
z = randint(rng,-100,100);
std::cout << x << "," << y << "," << z << std::endl;
cubePos[i] = glm::vec3((float)x,(float)y,(float)z);
}
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
input(window);
@@ -144,25 +170,25 @@ int main() {
glm::mat4 view = glm::mat4(1.0f);
glm::mat4 projection = glm::mat4(1.0f);
view = glm::translate(view,glm::vec3(0,0,-3));
projection = glm::perspective(glm::radians(45.0f),(float)w/(float)h,0.1f,100.0f);
projection = glm::perspective(glm::radians(45.0f),(float)w/(float)h,0.1f,200.0f);
s.setMat4("view", view);
s.setMat4("projection", projection);
s.setVec3("lightPos", glm::vec3(cos(glfwGetTime()),0,sin(glfwGetTime())));
s.setVec3("lightColor", glm::vec3(1,1,1));
s.setVec3("objectColor",glm::vec3(0.2,0.2,0.2));
s.setVec3("viewPos",glm::vec3(0,0,-3));
s.setVec3("viewPos",glm::vec3(0,0,-10));
glBindVertexArray(VAO);
for (uint16_t i = 0; i < 20; i++)
for (uint16_t i = 0; i < 5000; i++)
{
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::translate(model, cubePos[i]);
float angle = 24.3f * i;
model = glm::rotate(model,glm::radians(angle),glm::vec3(1,0.3,0.5));
s.setMat4("model",model);
glDrawArrays(GL_TRIANGLES,0,36);
glDrawArrays(0x0004,0,36);
}
s.use();