Skip to content

Instantly share code, notes, and snippets.

View McZonk's full-sized avatar

Max McZonk

  • Germany
View GitHub Profile
// vertex shader
attribute vec4 a_color;
attribute vec4 a_position;
attribute vec2 a_tex_coord;
varying mediump vec2 v_tex_coord;
varying lowp vec4 v_color_mix;
void main() {
v_color_mix = a_color;
v_tex_coord = a_tex_coord;
gl_Position = a_position;
// vertex shader
uniform float u_selected;
attribute vec4 a_position;
attribute vec4 a_color;
varying lowp vec4 v_color;
void main() {
if (u_selected > 0.0) {
v_color = vec4(0.5, 1.0, 1.0, 1.0);
} else {
v_color = a_color;
// vertex shader
attribute vec4 a_color;
attribute vec4 a_position;
attribute vec2 a_tex_coord;
varying highp vec2 v_tex_coord;
varying lowp vec4 v_color_mix;
void main() {
v_color_mix = a_color;
v_tex_coord = a_tex_coord;
gl_Position = a_position;
// vertex shader
attribute vec4 a_position;
attribute vec2 a_tex_coord;
varying mediump vec2 v_tex_coord;
void main() {
v_tex_coord = a_tex_coord;
gl_Position = a_position;
}
// fragment shader
@McZonk
McZonk / CheckClearColor.m
Last active January 1, 2016 15:09
Fixing TRAUMA OpenGL ES debugger warnings
if(flashIntensity > 0.0f)
{
glClearColor(flashIntensity, flashIntensity, flashIntensity, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
else
{
glClear(GL_COLOR_BUFFER_BIT);
}
@McZonk
McZonk / UIImageView+UIPImageFrame.m
Created October 8, 2013 09:59
Category to calculate the image frame in UIImageView
#import "UIImageView+UIPImageFrame.h"
@implementation UIImageView (UIPImageFrame)
- (CGRect)imageFrame
{
UIViewContentMode contentMode = self.contentMode;
UIImage *image = self.image;
if(image == nil)
@implementation IrisSegue
- (void)perform
{
CATransition *shutterAnimation = [CATransition animation];
[shutterAnimation setDelegate:self];
[shutterAnimation setDuration:0.5];
shutterAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[shutterAnimation setType:@"cameraIris"];
@McZonk
McZonk / gist:5516682
Last active December 16, 2015 23:49
overriding self might seem strange, but it ensure that you cannot accidentally use the strong self.
- (void)foo
{
__weak __typeof__(self) weakSelf = self;
dispatch_async(queue, ^{
__typeof__(self) self = weakSelf;
[self bar];
});
}
@McZonk
McZonk / main.m
Created April 23, 2013 13:48
Dispatch Behavior
int main(int argc, const char * argv[])
{
@autoreleasepool {
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_block_t block = ^{
int a = 5;
NSLog(@"%p = %d", &a, a);
@McZonk
McZonk / No-Default.c
Created April 17, 2013 10:55
If you use switch(enum) you should not implement default: You will get a helpful warning when a value is not implemented. This is useful when new values will be added to the enum. You don't forget to handle the new value because of the warning. When a value doesn't need to be handle, add it at the end of the switch with a break.
typedef enum MyEnum {
MyEnum1,
MyEnum2,
MyEnum3,
} MyEnum;
static int function1(MyEnum e) {
switch(e) { // warning: Enumeration value 'MyEnum3' not handled in switch
case MyEnum1:
return 1;