#Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include
#Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include
#Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include #Include
h>
#include <GLFW/glfw3.h>
#include "Renderer.h"
#include "VertexBuffer.h"
#include "IndexBuffer.h"
#include "VertexArray.h"
#include "Shader.h"
#include "VertexBufferLayout.h"
#include "Texture.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
int main(void)
{
srand(static_cast<unsigned int>(time(0)));
GLFWwindow* window;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwSwapInterval(1);
if (glewInit() != GLEW_OK) {
std::cout << "Error!";
}
//std::cout << glGetString(GL_VERSION) << std::endl;
{
float positions[] = {
-1.5f, -1.5f, 0.0f, 0.0f, // 0
0.5f, -0.5f, 1.0f, 0.0f, // 1
0.5f, 0.5f, 1.0f, 1.0f, // 2
-0.5f, 0.5f, 0.0f, 1.0f // 3
};
GLCall(glEnable(GL_BLEND));
GLCall(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
/* Construct a vertex buffer object and set the coordonates into the buffer */
VertexBuffer vb(positions, 4 * 4 * sizeof(float));
Shader shader("res/shaders/Basic.shader");
shader.Bind();
shader.SetUniform4f("u_Color", 0.0f, 0.8f, 0.2f, 1.0f);
shader.SetUniformMat4f("u_MVP", proj);
shader.PrintShaderCode();
Texture texture1("res/textures/profir.jpg");
Texture texture2("res/textures/rainbow.jpg");
texture1.Bind(0);
texture2.Bind(1);
shader.SetUniform1i("u_Texture1", 0);
shader.SetUniform1i("u_Texture2", 1);
/*
Texture texture("res/textures/profir.jpg");
texture.Bind();
shader.SetUniform1i("u_Texture", 0);
*/
va.Unbind();
shader.Unbind();
vb.Unbind();
ib.Unbind();
Renderer renderer;
float r = 0.0f;
/*
int randomX = rand() % 2 + 1;
int randomY = rand() % 2 + 1;
renderer.Clear();
shader.Bind();
shader.SetUniform4f("u_Color", r, 0.4f, 0.8f, 1.0f);
shader.SetUniform4f("c_Position", 0.0f, 0.0f, 0.0f, 0.0f);
/*
if (r > 1.0f)
increment = -0.01f;
else if (r < 0.0f)
increment = 0.01f;
r += increment;
texCoordX += incrementX;
texCoordY += incrementY;
*/