Skip to content

Instantly share code, notes, and snippets.

in examples like hdr.cpp:
#ifndef SKIP_ENTRY_IMPLEMENT_MAIN
ENTRY_IMPLEMENT_MAIN(ExampleHDR);
#endif
----------------------------------------------------------------------
in mega.cpp:
/*
@attilaz
attilaz / gist:d75fc7d4ab75388a42720f97a7075c81
Created November 26, 2016 18:45
metal transient object lifetime
From metal documentation:
"Command buffer and command encoder objects are transient and designed for a single use.
They are very inexpensive to allocate and deallocate, so their creation methods return autoreleased objects."
https://developer.apple.com/library/content/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Cmd-Submiss/Cmd-Submiss.html
Autorelease example:
NSAutoreleasePool* autoreleasePool = [[NSAutoreleasePool alloc] init];
//c is an autoreleased object
/*
* Copyright 2011-2016 Attila Kocsis. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "bgfx_p.h"
#if BGFX_CONFIG_RENDERER_METAL
#include "renderer_mtl.h"
Index: renderer_gl.cpp
===================================================================
--- renderer_gl.cpp (revision 972)
+++ renderer_gl.cpp (revision 973)
@@ -2756,6 +2756,16 @@
, name
, glGetAttribLocation(m_id, name)
);
+
+ bool found = false;
@attilaz
attilaz / gist:f9f8cc132ecfee38fb7f
Last active August 29, 2015 14:22
renderer_mtl.mm
/*
* Copyright 2011-2015 Attila Kocsis, Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "bgfx_p.h"
#if BGFX_CONFIG_RENDERER_METAL
#import <QuartzCore/CAMetalLayer.h>
#import <UIKit/UiView.h>
@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
/*
C++ interface
*/
namespace mtl
{
class CommandQueue
{
public:
CommandQueue(id <MTLCommandQueue> commandQueue = nil) : m_commandQueue(commandQueue) {}
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 );
}
@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,
if (ImGui::CollapsingHeader("Horizontal Layout"))
{
// Text
ImGui::Text("Hello");
ImGui::SameLine();
ImGui::Text("World");
// Button
if (ImGui::Button("Banana")) printf("Pressed!\n");
ImGui::SameLine();