This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable Metal validation layer: 0FF-0, ON-1 | |
export METAL_DEVICE_WRAPPER_TYPE=1 | |
export METAL_ERROR_MODE=5 | |
export METAL_DEBUG_ERROR_MODE=5 | |
# Clean and make | |
make clean && make | |
# Execute | |
./YourExecutableName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example shows a demo as per existing Pan3D Model. | |
// Here, each class is responsible to release it own resources. | |
#include <iostream> | |
using namespace std; | |
class Position // GPU allocator/deallocator for position buffers | |
{ | |
public: | |
Position() { cout << "Position Ctor" << endl; Allocate(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example shows a demo as per new deallocation model suggestion. | |
// Here, the derive class explicitly deallocates | |
// a. owned resources. | |
// b. based class resources | |
#include <iostream> | |
using namespace std; | |
class Position // GPU allocator/deallocator for position buffers | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtCore> | |
#include <QtGui> | |
#include <QtWidgets> | |
QImage createImageWithFBO() | |
{ | |
QSurfaceFormat format; | |
format.setMajorVersion(3); | |
format.setMinorVersion(3); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <AppKit/AppKit.h> | |
@interface MyAppDelegate : NSObject <NSApplicationDelegate> | |
{ | |
NSWindow *window; | |
} | |
@end | |
@implementation MyAppDelegate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
// Ideally the interface should in .h | |
@interface Photo : NSObject { | |
NSString* caption; | |
NSString* photographer; | |
NSString* instrument; | |
NSString* musician; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <AppKit/AppKit.h> | |
#import <QuartzCore/CAMetalLayer.h> | |
@interface MyAppDelegate : NSObject <NSApplicationDelegate> | |
{ | |
NSWindow *window; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FIX: force the macosxsdk to 10.12 | |
# macx { | |
# QMAKE_MAC_SDK = macosx10.12 | |
# } | |
# | |
# With the above change ensure you first delete the existing makefile and .qmake.stash from the directory. Note .qmake.stash is a hidden file (view it ls -la) | |
QT += core gui | |
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | |
DEFINES += QT_DEPRECATED_WARNINGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example program | |
#include <iostream> | |
#include <string> | |
#include <cstddef> | |
#include <iostream> | |
using namespace std; | |
template <typename Owner, typename Tag> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define TO_POINTER(value) ((void*)(value)) | |
#define FORWARD_POINTER(pointer, offset) ((void*)((uintptr_t)TO_POINTER(pointer) + offset)) | |
#define POINTER_TO_UINT(pointer) ((uintptr_t)(pointer)) | |
#define ALIGN_POINTER(pointer, base) TO_POINTER(((POINTER_TO_UINT(pointer))+((base)-1L)) & ~((base)-1L)) | |
or | |
#define ALIGN_POINTER(pointer, base) TO_POINTER((UT_POINTER_TO_UINT(pointer)) + ((UT_POINTER_TO_UINT(pointer)) % base)) | |
#define IS_POINTER_ALIGNED(pointer, alignment) (((uintptr_t)pointer & (uintptr_t)(alignment - 1L)) == 0) | |
or |
OlderNewer