mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-18 04:53:06 +01:00
Updated to latest ocornut imgui.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
@@ -228,70 +229,6 @@ static bgfx::UniformHandle u_shadowMap[ShadowMapRenderTargets::Count];
|
||||
static bgfx::FrameBufferHandle s_rtShadowMap[ShadowMapRenderTargets::Count];
|
||||
static bgfx::FrameBufferHandle s_rtBlur;
|
||||
|
||||
static void shaderFilePath(char* _out, const char* _name)
|
||||
{
|
||||
strcpy(_out, s_shaderPath);
|
||||
strcat(_out, _name);
|
||||
strcat(_out, ".bin");
|
||||
}
|
||||
|
||||
long int fsize(FILE* _file)
|
||||
{
|
||||
long int pos = ftell(_file);
|
||||
fseek(_file, 0L, SEEK_END);
|
||||
long int size = ftell(_file);
|
||||
fseek(_file, pos, SEEK_SET);
|
||||
return size;
|
||||
}
|
||||
|
||||
static const bgfx::Memory* load(const char* _filePath)
|
||||
{
|
||||
FILE* file = fopen(_filePath, "rb");
|
||||
if (NULL != file)
|
||||
{
|
||||
uint32_t size = (uint32_t)fsize(file);
|
||||
const bgfx::Memory* mem = bgfx::alloc(size+1);
|
||||
size_t ignore = fread(mem->data, 1, size, file);
|
||||
BX_UNUSED(ignore);
|
||||
fclose(file);
|
||||
mem->data[mem->size-1] = '\0';
|
||||
return mem;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const bgfx::Memory* loadShader(const char* _name)
|
||||
{
|
||||
char filePath[512];
|
||||
shaderFilePath(filePath, _name);
|
||||
return load(filePath);
|
||||
}
|
||||
|
||||
static const bgfx::Memory* loadTexture(const char* _name)
|
||||
{
|
||||
char filePath[512];
|
||||
strcpy(filePath, "textures/");
|
||||
strcat(filePath, _name);
|
||||
return load(filePath);
|
||||
}
|
||||
|
||||
static bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName)
|
||||
{
|
||||
const bgfx::Memory* mem;
|
||||
|
||||
// Load vertex shader.
|
||||
mem = loadShader(_vsName);
|
||||
bgfx::ShaderHandle vsh = bgfx::createShader(mem);
|
||||
|
||||
// Load fragment shader.
|
||||
mem = loadShader(_fsName);
|
||||
bgfx::ShaderHandle fsh = bgfx::createShader(mem);
|
||||
|
||||
// Create program from shaders.
|
||||
return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */);
|
||||
}
|
||||
|
||||
void mtxBillboard(float* __restrict _result
|
||||
, const float* __restrict _view
|
||||
, const float* __restrict _pos
|
||||
@@ -1418,15 +1355,9 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
}
|
||||
|
||||
// Imgui.
|
||||
FILE* file = fopen("font/droidsans.ttf", "rb");
|
||||
uint32_t size = (uint32_t)fsize(file);
|
||||
void* data = malloc(size);
|
||||
size_t ignore = fread(data, 1, size, file);
|
||||
BX_UNUSED(ignore);
|
||||
fclose(file);
|
||||
|
||||
imguiCreate(data);
|
||||
|
||||
uint32_t size;
|
||||
void* data = load("font/droidsans.ttf", &size);
|
||||
imguiCreate(data, size);
|
||||
free(data);
|
||||
|
||||
// Uniforms.
|
||||
@@ -1456,16 +1387,9 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
PosColorTexCoord0Vertex::init();
|
||||
|
||||
// Textures.
|
||||
const bgfx::Memory* mem;
|
||||
|
||||
mem = loadTexture("figure-rgba.dds");
|
||||
bgfx::TextureHandle texFigure = bgfx::createTexture(mem);
|
||||
|
||||
mem = loadTexture("flare.dds");
|
||||
bgfx::TextureHandle texFlare = bgfx::createTexture(mem);
|
||||
|
||||
mem = loadTexture("fieldstone-rgba.dds");
|
||||
bgfx::TextureHandle texFieldstone = bgfx::createTexture(mem);
|
||||
bgfx::TextureHandle texFigure = loadTexture("figure-rgba.dds");
|
||||
bgfx::TextureHandle texFlare = loadTexture("flare.dds");
|
||||
bgfx::TextureHandle texFieldstone = loadTexture("fieldstone-rgba.dds");
|
||||
|
||||
// Meshes.
|
||||
Mesh bunnyMesh;
|
||||
|
||||
Reference in New Issue
Block a user