forked from mono/moon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext-gl.h
More file actions
159 lines (131 loc) · 4.11 KB
/
context-gl.h
File metadata and controls
159 lines (131 loc) · 4.11 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* context-gl.h
*
* Copyright 2010 Novell, Inc. (http://www.novell.com)
*
* See the LICENSE file included with the distribution for details.
*
*/
#ifndef __MOON_CONTEXT_GL_H__
#define __MOON_CONTEXT_GL_H__
#include "context.h"
#include "surface-gl.h"
#define MAX_CONVOLVE_SIZE 32
#define MIN_GL_VERSION 2.0
namespace Moonlight {
class MOON_API GLContext : public Context {
public:
GLContext (GLSurface *surface);
virtual ~GLContext ();
void Push (Group extents);
void Clear (Color *color);
void BlitYV12 (unsigned char *data[],
int stride[]);
void Paint (Color *color);
void Paint (MoonSurface *src,
double alpha,
double x,
double y);
void Project (MoonSurface *src,
const double *matrix,
double alpha,
double x,
double y);
void Blur (MoonSurface *src,
double radius,
double x,
double y);
void DropShadow (MoonSurface *src,
double dx,
double dy,
double radius,
Color *color,
double x,
double y);
void ShaderEffect (MoonSurface *src,
PixelShader *shader,
Brush **sampler,
int *sampler_mode,
int n_sampler,
Color *constant,
int n_constant,
int *ddxUvDdyUvPtr,
double x,
double y);
void Flush ();
protected:
#if !USE_CGL && !USE_EGL
PFNGLCREATESHADERPROC glCreateShader;
PFNGLSHADERSOURCEPROC glShaderSource;
PFNGLCOMPILESHADERPROC glCompileShader;
PFNGLGETSHADERIVPROC glGetShaderiv;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
PFNGLDELETESHADERPROC glDeleteShader;
PFNGLCREATEPROGRAMPROC glCreateProgram;
PFNGLATTACHSHADERPROC glAttachShader;
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
PFNGLUNIFORM4FPROC glUniform4f;
PFNGLUNIFORM4FVPROC glUniform4fv;
PFNGLUNIFORM1IPROC glUniform1i;
PFNGLLINKPROGRAMPROC glLinkProgram;
PFNGLUSEPROGRAMPROC glUseProgram;
PFNGLDELETEPROGRAMPROC glDeleteProgram;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArray;
PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArray;
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
#endif
virtual void SetFramebuffer ();
virtual void SetScissor ();
void SetViewport ();
void SetupVertexData ();
virtual void SetupVertexData (const double *matrix,
double x,
double y,
double width,
double height);
void SetupTexCoordData ();
virtual void SetupTexCoordData (const double *matrix,
double du,
double dv);
virtual void SetupTexUnit (GLenum target, GLint texture);
static int PixelAlignment (int stride);
static int PixelRowLength (int stride,
int width,
int size);
GLuint CreateShader (GLenum shaderType,
GLsizei count,
const GLchar **str);
GLuint GetVertexShader ();
virtual const char *ProgramPrecisionString ();
GLuint GetBlendProgram ();
GLuint GetProjectProgram (double alpha, unsigned yuv);
GLuint GetConvolveProgram (unsigned size);
GLuint GetDropShadowProgram (unsigned size);
GLuint GetEffectProgram (PixelShader *ps);
static const char *WritemaskToType (const char *writemask);
void Paint (MoonSurface *src,
const double *matrix,
double alpha,
double x,
double y);
float vertices[4][4];
float texcoords[4][4];
GLuint framebuffer;
GLuint vs;
GLuint blend_program;
GLuint project_program[2][2];
GLuint convolve_program[MAX_CONVOLVE_SIZE + 1];
GLuint dropshadow_program[MAX_CONVOLVE_SIZE + 1];
GHashTable *effect_program;
};
};
#endif /* __MOON_CONTEXT_GL_H__ */