Skip to content

Instantly share code, notes, and snippets.

@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>
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;
/*
* 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"
@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
in examples like hdr.cpp:
#ifndef SKIP_ENTRY_IMPLEMENT_MAIN
ENTRY_IMPLEMENT_MAIN(ExampleHDR);
#endif
----------------------------------------------------------------------
in mega.cpp:
/*
@attilaz
attilaz / androidfilereader
Created July 24, 2017 06:33
Android File read from assets
class FileReaderAndroidImpl : public bx::FileReaderI
{
public:
FileReaderAndroidImpl(AAssetManager *assetManager, AAsset* _file)
: m_assetManager(assetManager)
, m_file(_file)
, m_open(false)
{
}
@attilaz
attilaz / geometryc.txt
Created October 28, 2017 11:30
geometryc benchmark
I have tested two large obj file with geometryc.
ApCity uncompressed zip lzma
No Index compress 1,366,519 486,989 337,053
Index compress 1,244,034 432,734 296,368
Index+Vertex DWORD 1,244,034 388,990 300,717
Salle
No Index compress 28,663,702 17,863,876 11,664,913
#define BUTTON_ID 1
cButton* btn = new cButton(LOC"PLAY", "images/foo.png");
btn->setPosition(sGuiVec2(100,200));
btn->setScale(2.0f);
btn->setAnchorPoint(sGuiVec2(0,0));
btn->onPressed().addHandler(this, &onButtonPressed);
addChild(btn, 1, BUTTON_ID);
void onButtonPressed(cButton* btn)
@attilaz
attilaz / gist:2530b9efd5a10f2395ebe1abd4514e5b
Created January 14, 2019 15:47
#include<string> #include <vector>
This file has been truncated, but you can view the full file.
#line 1 "..\\..\\..\\tools\\shaderc\\shaderc_spirv.cpp"
#line 1 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.10.25017\\include\\string"
#pragma once
#line 1 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.10.25017\\include\\istream"
#pragma once
@attilaz
attilaz / gist:bc75cd64ca186caac3fa886ada02a32f
Last active April 14, 2019 17:20
material specification
Storage for materials:
Version A. compact/hardcoded for certain shading types
type: 1 byte (phong=0, pbrMetallicRoughnes=1, pbrSpecularGlossiness=2, ...)
if ( type == 0 )
4 floats diffuseColor
string diffuseTexture
1 byte diffuseTexture texcoord channel
4 bytes diffuseTexture sampler parameters
.....