Skip to content

Instantly share code, notes, and snippets.

@attilaz
attilaz / gist:caf77e1b0e1b0a1fbcd0
Last active August 29, 2015 14:14
Bgfx dynamic index/vertex buffer problem (modified cubes.cpp)
/*
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "common.h"
#include "bgfx_utils.h"
struct PosColorVertex
{
@attilaz
attilaz / gist:25e71ebda916dd2732ae
Created February 5, 2015 13:03
Bgfx Rendering problem
/*
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "common.h"
#include "bgfx_utils.h"
struct PosColorVertex
{
@attilaz
attilaz / gist:f079dd520b6eb1681f9e
Created February 6, 2015 08:06
Bgfx render problem
/*
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "common.h"
#include "bgfx_utils.h"
struct PosColorVertex
{
@attilaz
attilaz / gist:78bfe8fa093dd128ad9d
Created February 11, 2015 15:14
renderergl_hack.cpp
void ProgramGL::bindAttributes(const VertexDecl& _vertexDecl, uint32_t _baseVertex) const
{
for (uint32_t ii = 0; ii < 15; ++ii)
GL_CHECK(glDisableVertexAttribArray(ii) );
for (uint32_t ii = 0; Attrib::Count != m_used[ii]; ++ii)
{
Attrib::Enum attr = Attrib::Enum(m_used[ii]);
GLint loc = m_attributes[attr];
@attilaz
attilaz / gist:04beb4319061b371fd32
Created March 2, 2015 14:35
combo horizontal layout bug
if (ImGui::CollapsingHeader("Horizontal Layout"))
{
// Text
ImGui::Text("Hello");
ImGui::SameLine();
ImGui::Text("World");
// Button
if (ImGui::Button("Banana")) printf("Pressed!\n");
ImGui::SameLine();
if (ImGui::CollapsingHeader("Horizontal Layout"))
{
// Text
ImGui::Text("Hello");
ImGui::SameLine();
ImGui::Text("World");
// Button
if (ImGui::Button("Banana")) printf("Pressed!\n");
ImGui::SameLine();
@attilaz
attilaz / api_trace_bgfx
Created March 25, 2015 09:00
api traces
,0,1,GL_ARB_vertex_array_object,glBindVertexArray,1,3.764,
,3,1,GL_ARB_framebuffer_object,glBindFramebuffer,GL_FRAMEBUFFER 0,17.452,
,6,1,GL_ARB_vertex_buffer_object,glBindBuffer,GL_ARRAY_BUFFER 6,4.106,
,9,1,GL_ARB_vertex_buffer_object,glBufferSubData,GL_ARRAY_BUFFER 0 2000 0x23157FB8,13.345,
,12,1,GL_ARB_vertex_buffer_object,glBindBuffer,GL_ARRAY_BUFFER 0,1.711,
,15,1,GL_ARB_framebuffer_object,glBindFramebuffer,GL_FRAMEBUFFER 0,1.711,
,18,1,GL_ARB_framebuffer_object,glBindFramebuffer,GL_FRAMEBUFFER 2,4.791,
,22,1,OpenGL_1.0,glViewport,0 0 1024 1024,40.721,
,25,1,OpenGL_1.0,glClearDepth,1.000000,8.897,
,28,1,OpenGL_1.0,glDepthMask,GL_TRUE,1.711,
namespace bgfx
{
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL
# include "glimports.h"
void GlContext::create(uint32_t _width, uint32_t _height)
{
glGetIntegerv( GL_FRAMEBUFFER_BINDING, (GLint*)&m_fbo );
}
/*
C++ interface
*/
namespace mtl
{
class CommandQueue
{
public:
CommandQueue(id <MTLCommandQueue> commandQueue = nil) : m_commandQueue(commandQueue) {}
@attilaz
attilaz / gist:434e2e8c08f482f71b10
Created June 11, 2015 14:35
using metal wrapper
// Interface Orientation
UIInterfaceOrientation mnOrientation;
// Renderer globals
mtl::Device m_Device;
mtl::CommandQueue m_CommandQueue;
mtl::Library m_ShaderLibrary;
mtl::DepthStencilState m_DepthState;
// textured Quad