-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
egl render window done (does not work with NVIDIA)
- Loading branch information
Showing
26 changed files
with
593 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef __DK_APPLICATION_H__ | ||
#define __DK_APPLICATION_H__ | ||
|
||
#include "ret_code.h" | ||
|
||
namespace dk | ||
{ | ||
|
||
class application | ||
{ | ||
public: | ||
virtual void update() = 0; | ||
virtual void render() = 0; | ||
|
||
virtual ret_code create() = 0; | ||
}; | ||
|
||
} | ||
|
||
#endif // !__DK_APPLICATION_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef __DK_ASSERT_H__ | ||
#define __DK_ASSERT_H__ | ||
|
||
#include <stdlib.h> | ||
#include "log.h" | ||
|
||
#define DK_ASSERT(expr, ...) \ | ||
if (!(expr)) { \ | ||
DK_LOG_PRINT("ASSERT!", __FILE__, __func__, __LINE__, \ | ||
"Assertion failed: '", #expr, "'", ##__VA_ARGS__, '\n'); \ | ||
std::exit(1); \ | ||
} | ||
|
||
#endif // !__DK_ASSERT_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include <unordered_map> | ||
|
||
namespace lao | ||
namespace dk | ||
{ | ||
|
||
template<typename KeyT, typename ValT> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include <utility> | ||
|
||
namespace lao | ||
namespace dk | ||
{ | ||
|
||
template<typename FirstT, typename SecondT> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include <stack> | ||
|
||
namespace lao | ||
namespace dk | ||
{ | ||
|
||
template<typename T> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include <string> | ||
|
||
namespace lao | ||
namespace dk | ||
{ | ||
|
||
using string = std::string; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include <string_view> | ||
|
||
namespace lao | ||
namespace dk | ||
{ | ||
|
||
using string_view = std::string_view; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include <vector> | ||
|
||
namespace lao | ||
namespace dk | ||
{ | ||
|
||
template<typename T> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef __DK_GL_CALL_H__ | ||
#define __DK_GL_CALL_H__ | ||
|
||
#define GL_CALL(call) \ | ||
call; \ | ||
if (auto err = glGetError(); err != GL_NO_ERROR) \ | ||
dk::gl_print_error(__FILE__, __func__, __LINE__, err, #call) | ||
|
||
namespace dk | ||
{ | ||
|
||
void gl_print_error(const char* file, const char* func, int line, int err, const char* call); | ||
|
||
} | ||
|
||
#endif // !__DK_GL_CALL_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef __DK_SHADER_H__ | ||
#define __DK_SHADER_H__ | ||
|
||
#include <GL/gl.h> | ||
#include "ret_code.h" | ||
#include "containers/string_view.h" | ||
|
||
namespace dk | ||
{ | ||
|
||
enum class shader_type | ||
{ | ||
VERTEX_SHADER = 0, | ||
FRAGMENT_SHADER | ||
}; | ||
|
||
class shader | ||
{ | ||
private: | ||
GLuint m_shader; | ||
|
||
static GLenum convert_type(shader_type type); | ||
|
||
public: | ||
GLuint get_native() const { return m_shader; } | ||
|
||
ret_code create(shader_type type, string_view src); | ||
}; | ||
|
||
} | ||
|
||
#endif // !__DK_SAHDER_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef __DK_SHADER_PROGRAM_H__ | ||
#define __DK_SHADER_PROGRAM_H__ | ||
|
||
#include "graphic/shader.h" | ||
|
||
namespace dk | ||
{ | ||
|
||
class shader_program | ||
{ | ||
private: | ||
GLuint m_shader_program; | ||
|
||
public: | ||
shader_program() : m_shader_program(0) {} | ||
|
||
void enable() const; | ||
void disable() const; | ||
|
||
ret_code add_shader(const shader& shader) const; | ||
|
||
ret_code create(); | ||
ret_code link(); | ||
}; | ||
|
||
} | ||
|
||
#endif // !__DK_SADHER_PROGRAM_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ enum class ret_code | |
{ | ||
OK = 0, | ||
WARNING, | ||
ERORR, | ||
ERROR, | ||
FATAL | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef __DK_CLOCK_H__ | ||
#define __DK_CLOCK_H__ | ||
|
||
#include <chrono> | ||
#include <thread> | ||
|
||
namespace dk | ||
{ | ||
|
||
class clock | ||
{ | ||
private: | ||
std::chrono::high_resolution_clock::time_point m_last; | ||
std::chrono::high_resolution_clock::duration m_update_interval; | ||
|
||
public: | ||
clock(uint32_t UPS) | ||
{ | ||
m_update_interval = std::chrono::high_resolution_clock::duration(std::chrono::seconds(1)) / UPS; | ||
m_last = std::chrono::high_resolution_clock::now(); | ||
} | ||
|
||
bool is_elapsed() | ||
{ | ||
auto now = std::chrono::high_resolution_clock::now(); | ||
auto diff = now - m_last; | ||
if (diff > m_update_interval) { | ||
m_last += m_update_interval; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void wait() | ||
{ | ||
auto now = std::chrono::high_resolution_clock::now(); | ||
auto diff = now - m_last; | ||
if (diff < m_update_interval) | ||
std::this_thread::sleep_for(m_update_interval - diff); | ||
|
||
m_last += m_update_interval; | ||
} | ||
}; | ||
|
||
} | ||
|
||
#endif // !__DK_CLOCK_H__ |
Oops, something went wrong.