extra commit...

This commit is contained in:
Edward R. Gonzalez 2020-02-21 01:19:30 -05:00
parent 6d7750ebfb
commit da4a38c11f
12 changed files with 0 additions and 84397 deletions

View File

@ -1,19 +0,0 @@
#pragma once
// GLEW
#include <glew.h>
namespace DGL
{
// Fundamental Types
using gChar = GLchar ;
using gBitfield = GLbitfield;
using gFloat = GLfloat ;
using gFloatClamped = GLclampf ;
using gInt = GLint ;
using gUInt = GLuint ;
using gSize = GLsizei ;
}

View File

@ -1,65 +0,0 @@
#pragma once
// OpenGL
#include <glew.h >
#include <glm/detail/type_vec3.hpp>
#include <glm/detail/type_vec2.hpp>
// Duck Tape
#include "DGL_FundamentalTypes.hpp"
// Non-Standard C++
#include "Cpp_Alias.hpp"
namespace DGL
{
namespace Generic
{
template<typename Type>
using Vector3 = glm::tvec3<Type>;
template<typename Type>
using Vector2 = glm::tvec2<Type>;
}
using DataPtr = ptr<GLvoid>;
template<typename ReferenceType>
using ID = gUInt;
// ID Reference Types
class VertexBuffer ;
class NormalBuffer ;
class Vec3 ;
class Matrix ;
class Shader ;
class ShaderProgram;
class VertexArray ;
class TextureBuffer;
class ElementBuffer;
using Matrix4x4 = glm::mat4;
using Vector2 = glm::vec2;
using Vector3 = glm::vec3;
using Vector4 = glm::vec4;
struct LinearColor
{
gFloatClamped Red, Green, Blue, Alpha;
LinearColor(gFloatClamped _red, gFloatClamped _green, gFloatClamped _blue, gFloatClamped _alpha) :
Red(_red), Green(_green), Blue(_blue), Alpha(_alpha) {};
sfn Vector() -> Vector3
{
return Vector3(Red, Green, Blue);
}
};
}

View File

@ -1 +0,0 @@
#pragma once

View File

@ -1,203 +0,0 @@
#ifndef SHADER_H
#define SHADER_H
//#include <glad/glad.h>
#include <glew.h>
#include <glm/glm.hpp>
#include "DGL.hpp"
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
class Shader
{
public:
unsigned int ID;
// constructor generates the shader on the fly
// ------------------------------------------------------------------------
Shader(const char* vertexPath, const char* fragmentPath, const char* geometryPath = nullptr)
{
// 1. retrieve the vertex/fragment source code from filePath
std::string vertexCode;
std::string fragmentCode;
std::string geometryCode;
std::ifstream vShaderFile;
std::ifstream fShaderFile;
std::ifstream gShaderFile;
// ensure ifstream objects can throw exceptions:
vShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
fShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
gShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
try
{
// open files
vShaderFile.open(vertexPath);
fShaderFile.open(fragmentPath);
std::stringstream vShaderStream, fShaderStream;
// read file's buffer contents into streams
vShaderStream << vShaderFile.rdbuf();
fShaderStream << fShaderFile.rdbuf();
// close file handlers
vShaderFile.close();
fShaderFile.close();
// convert stream into string
vertexCode = vShaderStream.str();
fragmentCode = fShaderStream.str();
// if geometry shader path is present, also load a geometry shader
if (geometryPath != nullptr)
{
gShaderFile.open(geometryPath);
std::stringstream gShaderStream;
gShaderStream << gShaderFile.rdbuf();
gShaderFile.close();
geometryCode = gShaderStream.str();
}
}
catch (std::ifstream::failure e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}
const char* vShaderCode = vertexCode.c_str();
const char* fShaderCode = fragmentCode.c_str();
// 2. compile shaders
unsigned int vertex, fragment;
// vertex shader
vertex = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex, 1, &vShaderCode, NULL);
glCompileShader(vertex);
checkCompileErrors(vertex, "VERTEX");
// fragment Shader
fragment = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment, 1, &fShaderCode, NULL);
glCompileShader(fragment);
checkCompileErrors(fragment, "FRAGMENT");
// if geometry shader is given, compile geometry shader
unsigned int geometry;
if (geometryPath != nullptr)
{
const char* gShaderCode = geometryCode.c_str();
geometry = glCreateShader(GL_GEOMETRY_SHADER);
glShaderSource(geometry, 1, &gShaderCode, NULL);
glCompileShader(geometry);
checkCompileErrors(geometry, "GEOMETRY");
}
DGL::MakeShaderProgram(ID, vertex, fragment);
// shader Program
/* ID = glCreateProgram();
glAttachShader(ID, vertex);
glAttachShader(ID, fragment);
if (geometryPath != nullptr)
glAttachShader(ID, geometry);
glLinkProgram(ID);*/
checkCompileErrors(ID, "PROGRAM");
// delete the shaders as they're linked into our program now and no longer necessery
glDeleteShader(vertex);
glDeleteShader(fragment);
if (geometryPath != nullptr)
glDeleteShader(geometry);
}
// activate the shader
// ------------------------------------------------------------------------
void use()
{
glUseProgram(ID);
}
// utility uniform functions
// ------------------------------------------------------------------------
void setBool(const std::string& name, bool value) const
{
glUniform1i(glGetUniformLocation(ID, name.c_str()), (int)value);
}
// ------------------------------------------------------------------------
void setInt(const std::string& name, int value) const
{
glUniform1i(glGetUniformLocation(ID, name.c_str()), value);
}
// ------------------------------------------------------------------------
void setFloat(const std::string& name, float value) const
{
glUniform1f(glGetUniformLocation(ID, name.c_str()), value);
}
// ------------------------------------------------------------------------
void setVec2(const std::string& name, const glm::vec2& value) const
{
glUniform2fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void setVec2(const std::string& name, float x, float y) const
{
glUniform2f(glGetUniformLocation(ID, name.c_str()), x, y);
}
// ------------------------------------------------------------------------
void setVec3(const std::string& name, const glm::vec3& value) const
{
glUniform3fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void setVec3(const std::string& name, float x, float y, float z) const
{
glUniform3f(glGetUniformLocation(ID, name.c_str()), x, y, z);
}
// ------------------------------------------------------------------------
void setVec4(const std::string& name, const glm::vec4& value) const
{
glUniform4fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void setVec4(const std::string& name, float x, float y, float z, float w)
{
glUniform4f(glGetUniformLocation(ID, name.c_str()), x, y, z, w);
}
// ------------------------------------------------------------------------
void setMat2(const std::string& name, const glm::mat2& mat) const
{
glUniformMatrix2fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
}
// ------------------------------------------------------------------------
void setMat3(const std::string& name, const glm::mat3& mat) const
{
glUniformMatrix3fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
}
// ------------------------------------------------------------------------
void setMat4(const std::string& name, const glm::mat4& mat) const
{
deduce bullshit = glGetUniformLocation(ID, name.c_str());
glUniformMatrix4fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
}
private:
// utility function for checking shader compilation/linking errors.
// ------------------------------------------------------------------------
void checkCompileErrors(GLuint shader, std::string type)
{
GLint success;
GLchar infoLog[1024];
if (type != "PROGRAM")
{
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(shader, 1024, NULL, infoLog);
std::cout << "ERROR::SHADER_COMPILATION_ERROR of type: " << type << "\n" << infoLog << "\n -- --------------------------------------------------- -- " << std::endl;
}
}
else
{
glGetProgramiv(shader, GL_LINK_STATUS, &success);
if (!success)
{
glGetProgramInfoLog(shader, 1024, NULL, infoLog);
std::cout << "ERROR::PROGRAM_LINKING_ERROR of type: " << type << "\n" << infoLog << "\n -- --------------------------------------------------- -- " << std::endl;
}
}
}
};
#endif

View File

@ -1,46 +0,0 @@
# Blender v2.80 (sub 74) OBJ File: ''
# www.blender.org
mtllib blenderCube.mtl
o Cube
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.625000 0.500000
vt 0.375000 0.500000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.375000 0.750000
vt 0.125000 0.750000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/6/2 7/7/2 8/8/2
f 8/8/3 7/7/3 5/9/3 6/10/3
f 6/10/4 2/11/4 4/12/4 8/13/4
f 2/14/5 1/15/5 3/16/5 4/17/5
f 6/18/6 5/19/6 1/20/6 2/11/6

View File

@ -1,4 +0,0 @@
#
#
#

View File

@ -1,13 +0,0 @@
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
# (assimp v4.1.216079013)
newmtl DefaultMaterial
Kd 0.6000000238418579 0.6000000238418579 0.6000000238418579
Ka 0 0 0
Ks 0 0 0
Ke 0 0 0
Tf 1 1 1
d 1
Ni 1
illum 1

View File

@ -1,41 +0,0 @@
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
# (assimp v4.1.216079013)
mtllib cubeGenNormals.mtl
# 8 vertex positions
v 0.02254099957644939 0 0
v 1.022541046142578 1 0
v 1.022541046142578 0 0
v 0.02254099957644939 1 0
v 0.02254099957644939 1 1
v 0.02254099957644939 0 1
v 1.022541046142578 1 1
v 1.022541046142578 0 1
# 0 UV coordinates
# 6 vertex normals
vn 0 0 -1
vn -1 0 0
vn 0 1 0
vn 1 0 0
vn 0 -1 0
vn 0 0 1
# Mesh 'cube Mesh' with 12 faces
g cube Mesh
usemtl DefaultMaterial
f 1//1 2//1 3//1
f 1//1 4//1 2//1
f 1//2 5//2 4//2
f 1//2 6//2 5//2
f 4//3 7//3 2//3
f 4//3 5//3 7//3
f 3//4 2//4 7//4
f 3//4 7//4 8//4
f 1//5 3//5 8//5
f 1//5 8//5 6//5
f 6//6 8//6 7//6
f 6//6 7//6 5//6

View File

@ -1,13 +0,0 @@
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
# (assimp v4.1.216079013)
newmtl DefaultMaterial
Kd 0.6000000238418579 0.6000000238418579 0.6000000238418579
Ka 0 0 0
Ks 0 0 0
Ke 0 0 0
Tf 1 1 1
d 1
Ni 1
illum 1

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
# (assimp v4.1.216079013)
newmtl DefaultMaterial
Kd 0.6000000238418579 0.6000000238418579 0.6000000238418579
Ka 0 0 0
Ks 0 0 0
Ke 0 0 0
Tf 1 1 1
d 1
Ni 1
illum 1

File diff suppressed because it is too large Load Diff