-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDVGOglEffectBase.h
More file actions
111 lines (99 loc) · 3.46 KB
/
DVGOglEffectBase.h
File metadata and controls
111 lines (99 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#import <Foundation/Foundation.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <GLKit/GLKitBase.h>
#import <GLKit/GLKTextureLoader.h>
#import <AVFoundation/AVFoundation.h>
#include <GLKit/GLKMath.h>
#import "math.h"
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define SHADER_STRING(text) @ STRINGIZE2(text)
enum
{
UNIFORM_RENDER_TRANSFORM_RPL = 100,
UNIFORM_SHADER_SAMPLER_RPL,
UNIFORM_SHADER_COLORTINT_RPL,
UNIFORM_SHADER_COLORTRANSP_RPL,
MAX_UNIFORMS_COUNT
};
enum
{
ATTRIB_VERTEX_RPL,
ATTRIB_TEXCOORD_RPL,
ATTRIB_TEXCOORD2_RPL,
NUM_ATTRIBUTES
};
typedef enum {
kDVGGLNoRotation,
kDVGGLRotateLeft,
kDVGGLRotateRight,
kDVGGLFlipVertical,
kDVGGLFlipHorizonal,
kDVGGLRotateRightFlipVertical,
kDVGGLRotateRightFlipHorizontal,
kDVGGLRotate180
} DVGGLRotationMode;
typedef enum {
DVGGLBlendNormal,
DVGGLBlendAdd
} DVGGLBlendMode;
struct GPUVector3 {
GLfloat one;
GLfloat two;
GLfloat three;
};
typedef struct GPUVector3 GPUVector3;
struct GPUMatrix3x3 {
GPUVector3 one;
GPUVector3 two;
GPUVector3 three;
};
typedef struct GPUMatrix3x3 GPUMatrix3x3;
@interface DVGOglEffectShader : NSObject
@property GLuint rplProgram;
@property NSArray* rplProgramAttPairs;
@property NSArray* rplProgramUniPairs;
@property GLint* rplUniforms;
@end
@class DVGStackableCompositionInstruction;
@interface DVGOglEffectBase : NSObject
// effects stuff
@property NSInteger effectTrackIndex;
@property CGFloat effectRenderingUpscale;
@property DVGGLBlendMode effectRenderingBlendMode;
// opengl stuff
@property DVGGLRotationMode effectTrackOrientation;
@property CMPersistentTrackID effectTrackID;
@property EAGLContext *rplContext;
- (void)prepareTransform:(CGAffineTransform)transf;
- (void)prepareOglResources;
- (void)releaseOglResources;
- (void)prepareContextForRendering;
- (void)activateContextShader:(int)shaderindex;
- (void)releaseContextForRendering;
- (int)prepareVertexShader:(NSString*)vertShaderSource
withFragmentShader:(NSString*)fragShaderSource
withAttribs:(NSArray*)attribPairs
withUniforms:(NSArray*)uniformPairs;
- (int)getActiveShaderUniform:(int)uniform;
- (void)renderIntoPixelBuffer:(CVPixelBufferRef)destBuffer
prevBuffer:(CVPixelBufferRef)prevBuffer
trackBuffer:(CVPixelBufferRef)trackBuffer
trackOrient:(DVGGLRotationMode)trackOrientation
atTime:(CGFloat)time withTween:(float)tweenFactor;
// utility functions
- (NSInteger)getMaxTextureSize;
- (CVOpenGLESTextureRef)bgraTextureForPixelBuffer:(CVPixelBufferRef)pixelBuffer;
+ (DVGGLRotationMode)orientationForPrefferedTransform:(CGAffineTransform)preferredTransform andSize:(CGSize)videoSize;
+ (CGSize)landscapeSizeForOrientation:(DVGGLRotationMode)orientation andSize:(CGSize)videoSize;
+ (const GLfloat *)textureCoordinatesForRotation:(DVGGLRotationMode)rotationMode;
+ (const GLfloat *)traformRSForRotation:(DVGGLRotationMode)rotationMode;
+ (GLKTextureInfo*)createGLKTextureFromCGImage:(CGImageRef)image;
+ (CVPixelBufferRef)createPixelBufferFromCGImage:(CGImageRef)image;
+ (CGImageRef)createCGImageFromPixelBuffer:(CVPixelBufferRef)pixelBuffer;
+ (GLKMatrix3)CGAffineTransformToGLKMatrix3:(CGAffineTransform)affineTransform;
+ (UIImage *)imageWithFlippedRGBOfImage:(UIImage *)image;
+ (void)applyTransform:(CGAffineTransform)trf toCoords:(GLfloat*)textureCoords amount:(int)c center:(CGPoint)center;
@end