Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "glad/glad.h"
- #include <GLFW/glfw3.h>
- #define STB_IMAGE_IMPLEMENTATION
- #include "glm/glm.hpp"
- #include "glm/gtc/matrix_transform.hpp"
- #include "glm/gtc/type_ptr.hpp"
- #include <iostream>
- #include "window.h"
- #include "shader.h"
- #include "buffer.h"
- #include "array.h"
- #include "vector2.h"
- #include "image.h"
- using namespace MyEngine;
- void processInput(GLFWwindow* window,float opacity) {
- }
- int main() {
- Window window;
- window.create("Hello, Triangle!", 700, 700);
- Shader shader("../shaders/shader.vs", "../shaders/shader.fs");
- shader.use();
- float vertices[] {
- -0.5f, 0.5f, 0.0f, 0.0f, 0.0f,
- -0.5f, -0.5f, 0.0f, 0.0f, 1.0f,
- 0.5f, -0.5f, 0.0f, 1.0f, 1.0f,
- 0.5f, 0.5f, 0.0f, 1.0f, 0.0f
- };
- unsigned int indices[] {
- 0, 1, 3,
- 1, 2, 3
- };
- TextureCache cache;
- glActiveTexture(GL_TEXTURE0);
- Texture anime(cache.getTexture("../Textures/anime.jpg"));
- glActiveTexture(GL_TEXTURE1);
- Texture wall(cache.getTexture("../Textures/wall.jpg"));
- VertexArray VAO;
- VAO.bind();
- Buffer VBO;
- VBO.load(vertices, GL_STATIC_DRAW);
- ElementBuffer EBO;
- EBO.load(indices, GL_STATIC_DRAW);
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
- glEnableVertexAttribArray(0);
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3*sizeof(float)));
- glEnableVertexAttribArray(1);
- shader.setInt("ourTexture1", 0);
- shader.setInt("ourTexture2", 1);
- shader.setFloat("kek", 0.5f);
- float kek = 0.5f;
- glm::mat4 trans;
- trans = glm::rotate(trans, glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
- trans = glm::scale(trans, glm::vec3(0.5f, 0.5f, 0.5f));
- unsigned int transformLoc = glGetUniformLocation(shader.getID(), "transform");
- glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(trans));
- shader.use();
- while(window.isOpen()) {
- window.clear();
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
- if(glfwGetKey(window.getWindowPointer(), GLFW_KEY_UP) == GLFW_PRESS && kek < 1.0) {
- kek += 0.01;
- }
- if(glfwGetKey(window.getWindowPointer(), GLFW_KEY_DOWN) == GLFW_PRESS && kek > 0.0) {
- kek -= 0.01;
- }
- shader.setFloat("kek", kek);
- window.pollEvents();
- window.swapBuffers();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement