textures almost work?
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
#include "../Global.h"
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/string.h>
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Game
|
||||
{
|
||||
@@ -19,84 +18,10 @@ namespace Game
|
||||
float uv_y;
|
||||
};
|
||||
|
||||
struct BgfxCallback : public bgfx::CallbackI
|
||||
struct Texture
|
||||
{
|
||||
virtual ~BgfxCallback()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void fatal(const char* _filePath, uint16_t _line, bgfx::Fatal::Enum _code, const char* _str) override
|
||||
{
|
||||
// Something unexpected happened, inform user and bail out.
|
||||
printf("Fatal error: 0x%08x: %s", _code, _str);
|
||||
|
||||
// Must terminate, continuing will cause crash anyway.
|
||||
abort();
|
||||
}
|
||||
|
||||
virtual void traceVargs(const char* _filePath, uint16_t _line, const char* _format, va_list _argList) override
|
||||
{
|
||||
printf("%s (%d): ", _filePath, _line);
|
||||
vprintf(_format, _argList);
|
||||
}
|
||||
|
||||
virtual void profilerBegin(const char* /*_name*/,
|
||||
uint32_t /*_abgr*/,
|
||||
const char* /*_filePath*/,
|
||||
uint16_t /*_line*/) override
|
||||
{
|
||||
}
|
||||
|
||||
virtual void profilerBeginLiteral(const char* /*_name*/,
|
||||
uint32_t /*_abgr*/,
|
||||
const char* /*_filePath*/,
|
||||
uint16_t /*_line*/) override
|
||||
{
|
||||
}
|
||||
|
||||
virtual void profilerEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
virtual uint32_t cacheReadSize(uint64_t _id) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual bool cacheRead(uint64_t _id, void* _data, uint32_t _size) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void cacheWrite(uint64_t _id, const void* _data, uint32_t _size) override
|
||||
{
|
||||
}
|
||||
|
||||
virtual void screenShot(const char* _filePath,
|
||||
uint32_t _width,
|
||||
uint32_t _height,
|
||||
uint32_t _pitch,
|
||||
const void* _data,
|
||||
uint32_t /*_size*/,
|
||||
bool _yflip) override
|
||||
{
|
||||
}
|
||||
|
||||
virtual void captureBegin(uint32_t _width,
|
||||
uint32_t _height,
|
||||
uint32_t /*_pitch*/,
|
||||
bgfx::TextureFormat::Enum /*_format*/,
|
||||
bool _yflip) override
|
||||
{
|
||||
}
|
||||
|
||||
virtual void captureEnd() override
|
||||
{
|
||||
}
|
||||
|
||||
virtual void captureFrame(const void* _data, uint32_t /*_size*/) override
|
||||
{
|
||||
}
|
||||
bgfx::UniformHandle SamplerHandle;
|
||||
bgfx::TextureHandle Handle;
|
||||
};
|
||||
|
||||
struct Model
|
||||
@@ -116,24 +41,21 @@ namespace Game
|
||||
|
||||
bgfx::ProgramHandle Shader;
|
||||
bgfx::UniformHandle Uniforms[8];
|
||||
Texture Textures[4];
|
||||
uint64_t State = 0;
|
||||
static Material LoadFromShader(const char* vertPath, const char* fragPath);
|
||||
};
|
||||
|
||||
struct Camera
|
||||
{
|
||||
float FreelookXRot = 0.0f;
|
||||
float FreelookYRot = 0.0f;
|
||||
Transform Transform;
|
||||
static Material LoadFromShader(const char* vertPath,
|
||||
const char* fragPath,
|
||||
bgfx::TextureHandle = BGFX_INVALID_HANDLE,
|
||||
bgfx::UniformHandle sampler = BGFX_INVALID_HANDLE);
|
||||
};
|
||||
|
||||
class GameRendering
|
||||
{
|
||||
private:
|
||||
bgfx::UniformHandle DefaultSampler;
|
||||
Texture Textures[8];
|
||||
Material Materials[8];
|
||||
Model Models[8];
|
||||
BgfxCallback Callback;
|
||||
Camera Cam;
|
||||
|
||||
public:
|
||||
void Setup();
|
||||
|
||||
Reference in New Issue
Block a user