lmao
This commit is contained in:
parent
6c47960b69
commit
c3e49cd78e
|
@ -20,6 +20,7 @@ file(GLOB_RECURSE source_files
|
||||||
add_library(openglu SHARED
|
add_library(openglu SHARED
|
||||||
${include_files}
|
${include_files}
|
||||||
${source_files}
|
${source_files}
|
||||||
|
"cpp.hint"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(openglu PRIVATE OGLU_BUILD_DLL)
|
target_compile_definitions(openglu PRIVATE OGLU_BUILD_DLL)
|
||||||
|
|
6
cpp.hint
Normal file
6
cpp.hint
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||||
|
// such as names of functions and macros.
|
||||||
|
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||||
|
#define OGLU_API __declspec(dllexport)
|
||||||
|
#define OGLU_API __declspec(dllimport)
|
||||||
|
#define OGLU_API
|
|
@ -13,4 +13,5 @@ target_link_libraries(debug PRIVATE
|
||||||
|
|
||||||
add_custom_command(TARGET debug POST_BUILD
|
add_custom_command(TARGET debug POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:debug>
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:debug>
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:debug>/shaders
|
||||||
)
|
)
|
|
@ -47,7 +47,9 @@ int main(int argc, char** argv)
|
||||||
{ 0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0 }
|
{ 0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
oglu::Object(vertices, sizeof(vertices), nullptr, 0, topology, sizeof(topology));
|
oglu::Object triangle(vertices, sizeof(vertices), nullptr, 0, topology, sizeof(topology));
|
||||||
|
|
||||||
|
oglu::Shader shader("shaders/vertexShader.vert", "");
|
||||||
|
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
|
|
7
examples/debug/shaders/vertexShader.vert
Normal file
7
examples/debug/shaders/vertexShader.vert
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#version 330 core
|
||||||
|
layout (location = 0) in vec3 aPos;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace oglu
|
namespace oglu
|
||||||
{
|
{
|
||||||
typedef struct {
|
typedef OGLU_API struct {
|
||||||
GLuint index;
|
GLuint index;
|
||||||
GLint size;
|
GLint size;
|
||||||
GLenum type;
|
GLenum type;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "color.hpp"
|
#include "color.hpp"
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
|
#include "shader.hpp"
|
||||||
|
|
||||||
namespace oglu
|
namespace oglu
|
||||||
{
|
{
|
||||||
|
|
22
include/shader.hpp
Normal file
22
include/shader.hpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef SHADER_HPP
|
||||||
|
#define SHADER_HPP
|
||||||
|
|
||||||
|
#include <core.hpp>
|
||||||
|
#include <glad/glad.h>
|
||||||
|
|
||||||
|
namespace oglu
|
||||||
|
{
|
||||||
|
class OGLU_API Shader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Shader(const char* vertexShaderFile, const char* fragmentShaderFile);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void LoadShaderSource(const char* filename, char** buffer);
|
||||||
|
|
||||||
|
private:
|
||||||
|
GLuint vertexShader, fragmentShader;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -13,9 +13,9 @@ namespace oglu
|
||||||
VAO(0)
|
VAO(0)
|
||||||
{
|
{
|
||||||
GLuint VBO;
|
GLuint VBO;
|
||||||
glGenBuffers(1, &VBO);
|
//glGenBuffers(1, &VBO);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
//glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, verticesSize, vertices, GL_STATIC_DRAW);
|
//glBufferData(GL_ARRAY_BUFFER, verticesSize, vertices, GL_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
}
|
}
|
36
src/shader.cpp
Normal file
36
src/shader.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#include <shader.hpp>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace oglu
|
||||||
|
{
|
||||||
|
Shader::Shader(const char* vertexShaderFile, const char* fragmentShaderFile) :
|
||||||
|
vertexShader(0), fragmentShader(0)
|
||||||
|
{
|
||||||
|
std::cout << "jkskdjks" << std::endl;
|
||||||
|
vertexShader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
char* source = nullptr;
|
||||||
|
LoadShaderSource(vertexShaderFile, &source);
|
||||||
|
std::cout << source << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Shader::LoadShaderSource(const char* filename, char** buffer)
|
||||||
|
{
|
||||||
|
std::ifstream file(filename);
|
||||||
|
if (!file.good())
|
||||||
|
{
|
||||||
|
file.close();
|
||||||
|
throw std::exception(std::string("Failed to open shader file: " + std::string(filename)).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string str((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||||
|
(*buffer) = (char*)malloc(str.size() + 1);
|
||||||
|
std::cout << "dsnskdnksdnk" << std::endl;
|
||||||
|
memcpy(*buffer, str.c_str(), str.size());
|
||||||
|
std::cout << "diufoisdufo34" << std::endl;
|
||||||
|
(*buffer)[str.size()] = '\x00';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue