Skip to content

Commit 3183d42

Browse files
committed
Added bigg stuff and got rendering working
1 parent 013e3da commit 3183d42

File tree

21 files changed

+1003
-148
lines changed

21 files changed

+1003
-148
lines changed

igneous/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ set(SOURCES
1111
src/ecs/systems/captureSystem.cpp
1212
src/ecs/systems/rendererSystem.cpp
1313
src/gui/gui.cpp
14+
src/gui/imgui_assets.h
1415
src/physics/physics.cpp
1516
src/renderer/camera.cpp
1617
src/renderer/capture.cpp
1718
src/renderer/fpsCamera.cpp
18-
src/renderer/igneous_assets.h
19+
src/renderer/splash_assets.h
1920
src/renderer/renderer.cpp
20-
src/renderer/splashShaders.hpp
2121
)
2222

2323
set(INCLUDES
@@ -28,7 +28,6 @@ set(INCLUDES
2828
include/igneous/console/console.hpp
2929
include/igneous/console/conVar.hpp
3030
include/igneous/core/debug.hpp
31-
include/igneous/core/game.hpp
3231
include/igneous/core/igneous.hpp
3332
include/igneous/core/input.hpp
3433
include/igneous/core/log.hpp

igneous/include/igneous/core.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "igneous/core/debug.hpp"
4-
#include "igneous/core/game.hpp"
54
#include "igneous/core/igneous.hpp"
65
#include "igneous/core/input.hpp"
76
#include "igneous/core/log.hpp"
Lines changed: 85 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,96 @@
11
#pragma once
22

3-
#include <bigg.hpp>
3+
#include <bgfx/bgfx.h>
4+
#include <GLFW/glfw3.h>
45

5-
#include "igneous/core/game.hpp"
6-
#include "igneous/console/console.hpp"
7-
#include "igneous/renderer/renderer.hpp"
6+
#include <bx/allocator.h>
87

9-
namespace igneous {
10-
class Engine : public bigg::Application
8+
namespace igneous
119
{
12-
void initialize(int _argc, char** _argv);
13-
14-
//Input callbacks
15-
void onKey(int key, int scancode, int action, int mods);
16-
void onMouseButton(int button, int action, int mods);
17-
void onScroll(double xoffset, double yoffset);
18-
void onCursorPos(double xpos, double ypos);
19-
void onCursorEnter(int entered);
20-
void onWindowSize(int width, int height);
21-
22-
void onReset();
23-
void update(float dt);
24-
int shutdown();
10+
// allocator
11+
class Allocator : public bx::AllocatorI
12+
{
13+
public:
14+
void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line)
15+
{
16+
if (_size == 0)
17+
{
18+
free(_ptr);
19+
return nullptr;
20+
}
21+
else
22+
{
23+
return malloc(_size);
24+
}
25+
}
26+
};
27+
28+
// Application
29+
class Application
30+
{
31+
static void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
32+
static void charCallback(GLFWwindow* window, unsigned int codepoint);
33+
static void charModsCallback(GLFWwindow* window, unsigned int codepoint, int mods);
34+
static void mouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
35+
static void cursorPosCallback(GLFWwindow* window, double xpos, double ypos);
36+
static void cursorEnterCallback(GLFWwindow* window, int entered);
37+
static void scrollCallback(GLFWwindow* window, double xoffset, double yoffset);
38+
static void dropCallback(GLFWwindow* window, int count, const char** paths);
39+
static void windowSizeCallback(GLFWwindow* window, int width, int height);
2540
public:
26-
Engine(Game* game);
41+
Application(const char* title = "", uint32_t width = 1280, uint32_t height = 768);
42+
virtual ~Application() {};
43+
44+
int run(
45+
int argc,
46+
char** argv,
47+
bgfx::RendererType::Enum type = bgfx::RendererType::Count,
48+
uint16_t vendorId = BGFX_PCI_ID_NONE,
49+
uint16_t deviceId = 0,
50+
bgfx::CallbackI * callback = NULL,
51+
bx::AllocatorI * allocator = NULL
52+
);
53+
54+
void reset(uint32_t flags = 0);
55+
uint32_t getWidth() const;
56+
uint32_t getHeight() const;
57+
void setSize(int width, int height);
58+
const char* getTitle() const;
59+
void setTitle(const char* title);
60+
61+
virtual void initialize(int _argc, char** _argv) {};
62+
virtual void update(float dt) {};
63+
virtual void render() {};
64+
virtual int shutdown() { return 0; };
65+
66+
virtual void onReset() {};
67+
virtual void onKey(int key, int scancode, int action, int mods) {}
68+
virtual void onChar(unsigned int codepoint) {}
69+
virtual void onCharMods(int codepoint, unsigned int mods) {}
70+
virtual void onMouseButton(int button, int action, int mods) {}
71+
virtual void onCursorPos(double xpos, double ypos) {}
72+
virtual void onCursorEnter(int entered) {}
73+
virtual void onScroll(double xoffset, double yoffset) {}
74+
virtual void onDrop(int count, const char** paths) {}
75+
virtual void onWindowSize(int width, int height) {}
76+
protected:
77+
GLFWwindow* mWindow;
78+
Allocator mAllocator;
79+
bool mKeyDown[GLFW_KEY_LAST + 1] = { 0 };
80+
bool mMouseButtonDown[GLFW_MOUSE_BUTTON_LAST + 1] = { 0 };
81+
float mMouseWheelH;
82+
float mMouseWheel;
2783
private:
28-
uint32_t mReset = BGFX_RESET_NONE;
29-
Game* game;
30-
Console* console;
31-
Renderer* renderer;
84+
uint32_t mReset;
85+
uint32_t mWidth;
86+
uint32_t mHeight;
87+
const char* mTitle;
3288
};
3389
} // end namespace igneous
3490

35-
#define IG_IMPLEMENT_MAIN(GAME_CLASS) \
36-
int main(int argc, char** argv) \
37-
{ \
38-
return Engine(new GAME_CLASS).run(argc, argv, bgfx::RendererType::Count, BGFX_PCI_ID_AMD, 0, new CaptureCallback); \
91+
#define IG_IMPLEMENT_MAIN(APPLICATION_CLASS) \
92+
int main(int argc, char** argv) \
93+
{ \
94+
APPLICATION_CLASS app; \
95+
return app.run(argc, argv, bgfx::RendererType::Count, BGFX_PCI_ID_AMD, 0, new CaptureCallback); \
3996
}

igneous/include/igneous/gui/gui.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#pragma once
22

3+
#include <GLFW/glfw3.h>
4+
#include <imgui/imgui.h>
5+
36
namespace igneous {
47
namespace gui
58
{
9+
void init(GLFWwindow* window);
10+
void update(float dt);
11+
void reset(uint16_t width, uint16_t height);
12+
void render(ImDrawData* drawData);
13+
void shutdown();
14+
615
/*! Themes to use with `setTheme(Theme theme)` */
716
enum Theme
817
{

igneous/include/igneous/renderer/capture.hpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,11 @@
55
#include <bx/string.h>
66
#include <bx/filepath.h>
77
#include <bx/bx.h>
8+
#include "igneous/core/igneous.hpp"
89
#include "igneous/renderer/aviwriter.hpp"
910
#include <bx/allocator.h>
1011

1112
namespace igneous {
12-
class Allocator : public bx::AllocatorI
13-
{
14-
public:
15-
void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line)
16-
{
17-
if (_size == 0)
18-
{
19-
free(_ptr);
20-
return nullptr;
21-
}
22-
else
23-
{
24-
return malloc(_size);
25-
}
26-
}
27-
};
28-
2913
struct CaptureCallback : public bgfx::CallbackI
3014
{
3115
CaptureCallback();

igneous/include/igneous/renderer/renderer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class Renderer
1717
std::string getGpuInfo();
1818

1919
bgfx::TextureHandle loadTexture(std::string path, uint32_t _flags = 0, bool track = true);
20+
const bgfx::Memory* loadMemory(const char* filename);
21+
bgfx::ShaderHandle loadShader(const char* shader);
2022
bgfx::ProgramHandle loadProgram(const char* vs, const char* fs);
2123

2224
template<typename VertexType>

igneous/shaders/fs_imgui.sc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$input v_color0, v_texcoord0
2+
3+
#include <bgfx_shader.sh>
4+
5+
SAMPLER2D(s_tex, 0);
6+
7+
void main()
8+
{
9+
vec4 texel = texture2D(s_tex, v_texcoord0);
10+
gl_FragColor = texel * v_color0;
11+
}

igneous/shaders/varying.def.sc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
2+
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);
13
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
24

35
vec3 a_position : POSITION;
6+
vec4 a_normal : NORMAL;
7+
vec4 a_color0 : COLOR0;
48
vec2 a_texcoord0 : TEXCOORD0;

igneous/shaders/vs_imgui.sc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
$input a_position, a_texcoord0, a_color0
2+
$output v_color0, v_texcoord0
3+
4+
#include <bgfx_shader.sh>
5+
6+
void main()
7+
{
8+
vec2 pos = 2.0*a_position.xy*u_viewTexel.xy;
9+
gl_Position = vec4(pos.x - 1.0, 1.0 - pos.y, 0.0, 1.0);
10+
v_texcoord0 = a_texcoord0;
11+
v_color0 = a_color0;
12+
}

0 commit comments

Comments
 (0)