46#define BORDERCOLOR 0x00000000
50#define GRIDPOINTSTEXT 1
53#define GRIDPOINTSIZE 3
54#define GRIDPOINTOFFSET 4
55#define GRIDPOINTSTXTSIZE 14
56#define GRIDPOINTBG clrTransparent
57#define GRIDPOINTCLR 0xFFFF0000
64static int writeImage(
char* filename,
int width,
int height,
void *buffer,
char* title)
72 fp = fopen(filename,
"wb");
74 LOGERROR(
"WritePng: Could not open file %s for writing", filename);
80 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
81 if (png_ptr == NULL) {
82 LOGERROR(
"WritePng: Could not allocate write struct");
88 info_ptr = png_create_info_struct(png_ptr);
89 if (info_ptr == NULL) {
90 LOGERROR(
"WritePng: Could not allocate info struct");
96 if (setjmp(png_jmpbuf(png_ptr))) {
97 LOGERROR(
"WritePng: Error during png creation");
102 png_init_io(png_ptr, fp);
105 png_set_IHDR(png_ptr, info_ptr, width, height,
106 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
107 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
112 title_text.compression = PNG_TEXT_COMPRESSION_NONE;
113 title_text.key = strdup(
"Title");
114 title_text.text = title;
115 png_set_text(png_ptr, info_ptr, &title_text, 1);
118 png_write_info(png_ptr, info_ptr);
122 for (i = height - 1; i >= 0; i--) {
123 png_write_row(png_ptr, (png_bytep)buffer + i * width * 4);
127 png_write_end(png_ptr, NULL);
131 if (fp != NULL) fclose(fp);
132 if (info_ptr != NULL) png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
133 if (png_ptr != NULL) png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
140static void writePng(
int x,
int y,
int w,
int h,
bool oFb) {
142 GLubyte result[w * h * 4];
143 static int scr_nr = 0;
147 GL_CHECK(fbstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER));
148 if(fbstatus != GL_FRAMEBUFFER_COMPLETE)
149 LOGERROR(
"WritePng: Framebuffer is not complete! %d", fbstatus);
151 GL_CHECK(glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, &result));
153 snprintf(filename,
sizeof(filename),
"/tmp/%03doFb.png", scr_nr++);
155 snprintf(filename,
sizeof(filename),
"/tmp/%03dbFb.png", scr_nr++);
157 writeImage(filename, w, h, &result, strdup(
"osd"));
162 col.a = ((colARGB & 0xFF000000) >> 24) / 255.0;
163 col.r = ((colARGB & 0x00FF0000) >> 16) / 255.0;
164 col.g = ((colARGB & 0x0000FF00) >> 8 ) / 255.0;
165 col.b = ((colARGB & 0x000000FF) ) / 255.0;
174attribute vec2 position; \
175varying vec4 rectCol; \
176uniform vec4 inColor; \
177uniform mat4 projection; \
181 gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
188precision mediump float; \
189varying vec4 rectCol; \
193 gl_FragColor = rectCol; \
200attribute vec2 position; \
201attribute vec2 texCoords; \
203varying vec2 TexCoords; \
204varying vec4 alphaValue;\
205varying vec4 bColorValue;\
207uniform vec4 bColor; \
208uniform mat4 projection; \
213 gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
214 TexCoords = texCoords; \
215 alphaValue = alpha; \
216 bColorValue = bColor; \
222precision mediump float; \
223varying vec2 TexCoords; \
224varying vec4 alphaValue; \
225varying vec4 bColorValue; \
227uniform sampler2D screenTexture; \
229float clamp_to_border_factor (vec2 coords) \
231 bvec2 out1 = greaterThan (coords, vec2 (1,1)); \
232 bvec2 out2 = lessThan (coords, vec2 (0,0)); \
233 bool do_clamp = (any (out1) || any (out2)); \
234 return float (!do_clamp); \
239 vec4 color = texture2D(screenTexture, TexCoords) * alphaValue; \
240 float f = clamp_to_border_factor (TexCoords); \
241 gl_FragColor = mix (bColorValue, color, f); \
247precision mediump float; \
248varying vec2 TexCoords; \
249varying vec4 alphaValue; \
250varying vec4 bColorValue; \
252uniform sampler2D screenTexture; \
254float clamp_to_border_factor (vec2 coords) \
256 bvec2 out1 = greaterThan (coords, vec2 (1,1)); \
257 bvec2 out2 = lessThan (coords, vec2 (0,0)); \
258 bool do_clamp = (any (out1) || any (out2)); \
259 return float (!do_clamp); \
264 vec4 color = texture2D(screenTexture, TexCoords) * alphaValue; \
265 vec4 color_swapped = vec4(color.b, color.g, color.r, color.a); \
266 float f = clamp_to_border_factor (TexCoords); \
267 gl_FragColor = mix (bColorValue, color_swapped, f); \
274attribute vec2 position; \
275attribute vec2 texCoords; \
277varying vec2 TexCoords; \
278varying vec4 textColor; \
280uniform mat4 projection; \
281uniform vec4 inColor; \
285 gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
286 TexCoords = texCoords; \
287 textColor = inColor; \
293precision mediump float; \
294varying vec2 TexCoords; \
295varying vec4 textColor; \
297uniform sampler2D glyphTexture; \
301 vec4 sampled = vec4(1.0, 1.0, 1.0, texture2D(glyphTexture, TexCoords).r); \
302 gl_FragColor = textColor * sampled; \
315 const char *vertexCode = NULL;
316 const char *fragmentCode = NULL;
336 LOGERROR(
"openglosd: %s: unknown shader type", __FUNCTION__);
340 if (vertexCode == NULL || fragmentCode == NULL) {
341 LOGERROR(
"openglosd: %s: error reading shader", __FUNCTION__);
345 if (!
Compile(vertexCode, fragmentCode)) {
346 LOGERROR(
"openglosd: %s: error compiling shader", __FUNCTION__);
353 GL_CHECK(glUniform1f(glGetUniformLocation(
id, name), value));
357 GL_CHECK(glUniform1i(glGetUniformLocation(
id, name), value));
361 GL_CHECK(glUniform2f(glGetUniformLocation(
id, name), x, y));
365 GL_CHECK(glUniform3f(glGetUniformLocation(
id, name), x, y, z));
369 GL_CHECK(glUniform4f(glGetUniformLocation(
id, name), x, y, z, w));
373 GL_CHECK(glUniformMatrix4fv(glGetUniformLocation(
id, name), 1, GL_FALSE, glm::value_ptr(matrix)));
377 GLuint sVertex, sFragment;
379 GL_CHECK(sVertex = glCreateShader(GL_VERTEX_SHADER));
380 GL_CHECK(glShaderSource(sVertex, 1, &vertexCode, NULL));
385 GL_CHECK(sFragment = glCreateShader(GL_FRAGMENT_SHADER));
386 GL_CHECK(glShaderSource(sFragment, 1, &fragmentCode, NULL));
387 GL_CHECK(glCompileShader(sFragment));
392 GL_CHECK(glAttachShader(
id, sVertex));
393 GL_CHECK(glAttachShader(
id, sFragment));
394 GL_CHECK(glBindAttribLocation(
id, 0,
"position"));
395 GL_CHECK(glBindAttribLocation(
id, 1,
"texCoords"));
401 GL_CHECK(glDeleteShader(sFragment));
407 GLchar infoLog[1024];
409 GL_CHECK(glGetShaderiv(
object, GL_COMPILE_STATUS, &success));
411 GL_CHECK(glGetShaderInfoLog(
object, 1024, NULL, infoLog));
412 LOGERROR(
"openglosd: %s: Compile-time error: Type: %d - %s", __FUNCTION__,
type, infoLog);
416 GL_CHECK(glGetProgramiv(
object, GL_LINK_STATUS, &success));
418 GL_CHECK(glGetProgramInfoLog(
object, 1024, NULL, infoLog));
419 LOGERROR(
"openglosd: %s: Link-time error: Type: %d - %s", __FUNCTION__,
type, infoLog);
426#define KERNING_UNKNOWN (-10000)
434 width = ftGlyph->bitmap.width;
435 height = ftGlyph->bitmap.rows;
436 advanceX = ftGlyph->root.advance.x >> 16;
463 GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
471 ftGlyph->bitmap.width,
472 ftGlyph->bitmap.rows,
476 ftGlyph->bitmap.buffer
480 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
481 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
482 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
483 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
484 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
485 GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 4));
493 float width,
float height,
494 float bearingLeft,
float bearingTop,
495 float xoffset,
float yoffset) {
529 GL_CHECK(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_atlas_width));
531 FT_Set_Pixel_Sizes(face, 0, height);
532 FT_GlyphSlot g = face->glyph;
541 if (FT_Load_Char(face, i, FT_LOAD_NO_BITMAP)) {
549 if (FT_Stroker_New(g->library, &stroker)) {
550 LOGERROR(
"openglosd: %s: FT_Stroker_New error!", __FUNCTION__);
554 float outlineWidth = 0.25f;
555 FT_Stroker_Set(stroker, (
int)(outlineWidth * 64),
556 FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
558 if (FT_Get_Glyph(g, &ftGlyph)) {
559 LOGERROR(
"openglosd: %s: FT_Get_Glyph error!", __FUNCTION__);
563 if (FT_Glyph_StrokeBorder(&ftGlyph, stroker, 0, 1)) {
564 LOGERROR(
"openglosd: %s: FT_Glyph_StrokeBoder error!", __FUNCTION__);
568 FT_Stroker_Done(stroker);
570 if (FT_Glyph_To_Bitmap(&ftGlyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
571 LOGERROR(
"openglosd: %s: FT_Glyph_To_Bitmap error!", __FUNCTION__);
575 FT_BitmapGlyph bGlyph = (FT_BitmapGlyph)ftGlyph;
577 if (roww + bGlyph->bitmap.width + 1 >= (
unsigned int)max_atlas_width) {
578 w = std::max(
w, roww);
583 roww += bGlyph->bitmap.width + 1;
584 rowh = std::max(rowh, (
int)bGlyph->bitmap.rows);
586 FT_Done_Glyph(ftGlyph);
589 w = std::max(
w, roww);
595 LOGDEBUG2(
L_OPENGL,
"openglosd: %s: Try creating font atlas texture with w %d h %d (max %d)", __FUNCTION__,
w,
h, max_atlas_width);
609 GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
610 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
611 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
612 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
613 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
622 if (FT_Load_Char(face, i, FT_LOAD_NO_BITMAP)) {
623 LOGWARNING(
"openglosd: %s: Loading char %c failed!", __FUNCTION__, i);
630 if (FT_Stroker_New(g->library, &stroker)) {
631 LOGERROR(
"openglosd: %s: FT_Stroker_New error!", __FUNCTION__);
635 float outlineWidth = 0.25f;
636 FT_Stroker_Set(stroker, (
int)(outlineWidth * 64),
637 FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
639 if (FT_Get_Glyph(g, &ftGlyph)) {
640 LOGERROR(
"openglosd: %s: FT_Get_Glyph error!", __FUNCTION__);
644 if (FT_Glyph_StrokeBorder(&ftGlyph, stroker, 0, 1)) {
645 LOGERROR(
"openglosd: %s: FT_Glyph_StrokeBoder error!", __FUNCTION__);
649 FT_Stroker_Done(stroker);
651 if (FT_Glyph_To_Bitmap(&ftGlyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
652 LOGERROR(
"openglosd: %s: FT_Glyph_To_Bitmap error!", __FUNCTION__);
655 FT_BitmapGlyph bGlyph = (FT_BitmapGlyph)ftGlyph;
658 if (ox + bGlyph->bitmap.width + 1 >= (
unsigned int)max_atlas_width) {
669 bGlyph->bitmap.width,
673 bGlyph->bitmap.buffer
676 float ax = bGlyph->root.advance.x >> 16;
677 float ay = bGlyph->root.advance.y >> 16;
678 float bw = bGlyph->bitmap.width;
679 float bh = bGlyph->bitmap.rows;
680 float bl = bGlyph->left;
681 float bt = bGlyph->top;
682 float tx = ox / (float)
w;
683 float ty = oy / (float)
h;
686 rowh = std::max(rowh, (
int)bGlyph->bitmap.rows);
687 ox += bGlyph->bitmap.width + 1;
689 FT_Done_Glyph(ftGlyph);
692 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
693 LOGDEBUG2(
L_OPENGL,
"openglosd: %s: Created a %d x %d (%d kB) FontAtlas for fontsize %d, rowh %d, roww %d", __FUNCTION__,
w,
h,
w *
h / 1024, height, rowh, roww);
731 int error = FT_New_Face(
ftLib, fontName, 0, &
face);
733 LOGERROR(
"openglosd: %s: failed to open %s!", __FUNCTION__, *
name);
741 charcode = FT_Get_First_Char(
face, &gindex);
744 while (gindex != 0) {
746 charcode = FT_Get_Next_Char(
face, charcode, &gindex);
747 min_index = std::min(min_index, (
int)gindex);
748 max_index = std::max(max_index, (
int)gindex);
751 FT_Set_Char_Size(
face, 0, charHeight * 64, 0, 0);
752 height = (
face->size->metrics.ascender -
face->size->metrics.descender + 63) / 64;
753 bottom = abs((
face->size->metrics.descender - 63) / 64);
755 LOGDEBUG2(
L_OPENGL,
"openglosd: %s: Created new font: %s (%d) height: %d, bottom: %d - %d chars (%d - %d)", __FUNCTION__, fontName, charHeight,
height,
bottom, count, min_index, max_index);
768 for (font =
fonts->First(); font; font =
fonts->Next(font))
769 if (!strcmp(font->
Name(),
name) && charHeight == font->
Size()) {
778 if (FT_Init_FreeType(&
ftLib)) {
779 LOGERROR(
"openglosd: %s: failed to initialize FreeType library!", __FUNCTION__);
782 fonts =
new cList<cOglFont>;
792 LOGERROR(
"openglosd: %s: failed to deinitialize FreeType library!", __FUNCTION__);
799 if (charCode == 0xA0)
804 if (g->CharCode() == charCode) {
809 FT_UInt glyph_index = FT_Get_Char_Index(
face, charCode);
811 FT_Int32 loadFlags = FT_LOAD_NO_BITMAP;
813 int error = FT_Load_Glyph(
face, glyph_index, loadFlags);
821 error = FT_Stroker_New(
ftLib, &stroker );
826 float outlineWidth = 0.25f;
827 FT_Stroker_Set(stroker,
828 (
int)(outlineWidth * 64),
829 FT_STROKER_LINECAP_ROUND,
830 FT_STROKER_LINEJOIN_ROUND,
834 error = FT_Get_Glyph(
face->glyph, &ftGlyph);
840 error = FT_Glyph_StrokeBorder( &ftGlyph, stroker, 0, 1 );
845 FT_Stroker_Done(stroker);
847 error = FT_Glyph_To_Bitmap( &ftGlyph, FT_RENDER_MODE_NORMAL, 0, 1);
855 FT_Done_Glyph(ftGlyph);
862 if (glyph && prevSym) {
866 FT_UInt glyph_index = FT_Get_Char_Index(
face, glyph->
CharCode());
867 FT_UInt glyph_index_prev = FT_Get_Char_Index(
face, prevSym);
868 FT_Get_Kerning(
face, glyph_index_prev, glyph_index, FT_KERNING_DEFAULT, &delta);
869 kerning = delta.x / 64;
878 if (glyph && prevSym) {
882 FT_UInt glyph_index = FT_Get_Char_Index(
face, glyph->
CharCode());
883 FT_UInt glyph_index_prev = FT_Get_Char_Index(
face, prevSym);
884 FT_Get_Kerning(
face, glyph_index_prev, glyph_index, FT_KERNING_DEFAULT, &delta);
885 kerning = delta.x / 64;
895cOglFb::cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHeight) {
920 GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
width,
height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
921 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
922 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
923 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
924 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
926 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER,
fb));
928 GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
texture, 0));
931 GL_CHECK(fbstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER));
932 if(fbstatus != GL_FRAMEBUFFER_COMPLETE) {
933 LOGERROR(
"openglosd: %s: Framebuffer is not complete!", __FUNCTION__);
943 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER,
fb));
947 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER,
fb));
951 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER,
fb));
955 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
956 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
989 GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
width,
height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
990 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
991 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
992 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
993 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
995 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER,
fb));
997 GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
texture, 0));
1000 GL_CHECK(fbstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER));
1001 if(fbstatus != GL_FRAMEBUFFER_COMPLETE) {
1002 LOGERROR(
"openglosd: %s: Framebuffer is not complete (%d)!", __FUNCTION__, fbstatus);
1013 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER,
fb));
1018 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
1019 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
1099 GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0));
1115 GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0));
1124 GL_CHECK(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
1152 glm::mat4 projection = glm::ortho(0.0f, (GLfloat)width, (GLfloat)height, 0.0f, -1.0f, 1.0f);
1161 GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0));
1169 GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0));
1217cOglCmdRenderFbToBufferFb::cOglCmdRenderFbToBufferFb(
cOglFb *fb,
cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX, GLint drawPortY, GLint dirtyX, GLint dirtyTop, GLint dirtyWidth, GLint dirtyHeight,
bool alphablending,
cSoftHdDevice *device) :
cOglCmd(fb) {
1223 this->x = (GLfloat)
x;
1224 this->y = (GLfloat)
y;
1238 GLfloat texX2 = texX1 + 1.0f;
1240 GLfloat texY2 = texY1 + 1.0f;
1247 texY2 = texY1 + pageHeight;
1250 GLfloat quadVertices[] = {
1252 x ,
y , texX1, texY2,
1253 x , y2, texX1, texY1,
1254 x2, y2, texX2, texY1,
1256 x ,
y , texX1, texY2,
1257 x2, y2, texX2, texY1,
1258 x2,
y , texX2, texY2
1272 GL_CHECK(glEnable(GL_SCISSOR_TEST));
1276 GL_CHECK(glDisable(GL_SCISSOR_TEST));
1294 this->x = (GLfloat)
x;
1295 this->y = (GLfloat)
y;
1303 GLfloat x2 =
x + (GLfloat)
fb->
Width();
1306 GLfloat texX1 = 0.0f;
1307 GLfloat texX2 = 1.0f;
1308 GLfloat texY1 = 1.0f;
1309 GLfloat texY2 = 0.0f;
1311 GLfloat quadVertices[] = {
1313 x ,
y , texX1, texY1,
1314 x , y2, texX1, texY2,
1315 x2, y2, texX2, texY2,
1317 x ,
y , texX1, texY1,
1318 x2, y2, texX2, texY2,
1319 x2,
y , texX2, texY1
1356 this->color =
color;
1363 GL_CHECK(glClearColor(col.r, col.g, col.b, col.a));
1364 GL_CHECK(glClear(GL_COLOR_BUFFER_BIT));
1371 this->color =
color;
1377 GL_CHECK(glClearColor(col.r, col.g, col.b, col.a));
1378 GL_CHECK(glClear(GL_COLOR_BUFFER_BIT));
1386 this->width =
width;
1388 this->color =
color;
1400 GLfloat vertices[] = {
1432 this->width =
width;
1434 this->color =
color;
1442 int numVertices = 0;
1443 GLfloat *vertices = NULL;
1449 case 1:
case 2:
case 3:
case 4:
case -1:
case -2:
case -3:
case -4:
1452 case 5:
case 6:
case 7:
case 8:
1479 numVertices = size/2;
1480 GLfloat radiusX = (GLfloat)
width/2;
1481 GLfloat radiusY = (GLfloat)
height/2;
1482 GLfloat *vertices =
new GLfloat[size];
1483 vertices[0] =
x + radiusX;
1484 vertices[1] =
y + radiusY;
1485 for (
int i=0; i <= 180; i++) {
1486 vertices[2*i+2] =
x + radiusX + (GLfloat)cos(2*i * M_PI / 180.0f)*radiusX;
1487 vertices[2*i+3] =
y + radiusY - (GLfloat)sin(2*i * M_PI / 180.0f)*radiusY;
1494 numVertices = size/2;
1495 GLfloat radiusX = (GLfloat)
width;
1496 GLfloat radiusY = (GLfloat)
height;
1499 GLint startAngle = 0;
1500 GLfloat *vertices =
new GLfloat[size];
1551 for (
int i=0; i <= 45; i++) {
1552 vertices[2*i+2] =
x + transX + (GLfloat)cos((2*i + startAngle) * M_PI / 180.0f)*radiusX;
1553 vertices[2*i+3] =
y + transY - (GLfloat)sin((2*i + startAngle) * M_PI / 180.0f)*radiusY;
1560 numVertices = size/2;
1561 GLfloat radiusX = 0.0f;
1562 GLfloat radiusY = 0.0f;
1565 GLint startAngle = 0;
1566 GLfloat *vertices =
new GLfloat[size];
1569 radiusX = (GLfloat)
width;
1570 radiusY = (GLfloat)
height/2;
1572 vertices[1] =
y + radiusY;
1577 radiusX = (GLfloat)
width/2;
1578 radiusY = (GLfloat)
height;
1579 vertices[0] =
x + radiusX;
1580 vertices[1] =
y + radiusY;
1586 radiusX = (GLfloat)
width;
1587 radiusY = (GLfloat)
height/2;
1588 vertices[0] =
x + radiusX;
1589 vertices[1] =
y + radiusY;
1595 radiusX = (GLfloat)
width/2;
1596 radiusY = (GLfloat)
height;
1597 vertices[0] =
x + radiusX;
1605 for (
int i=0; i <= 90; i++) {
1606 vertices[2*i+2] =
x + transX + (GLfloat)cos((2*i + startAngle) * M_PI / 180.0f)*radiusX;
1607 vertices[2*i+3] =
y + transY - (GLfloat)sin((2*i + startAngle) * M_PI / 180.0f)*radiusY;
1625 this->width =
width;
1627 this->color =
color;
1635 bool falling =
type & 0x02;
1636 bool vertical =
type & 0x04;
1641 int numVertices = steps + 2;
1642 GLfloat *vertices =
new GLfloat[numVertices*2];
1646 vertices[0] = (GLfloat)(
x +
width);
1647 vertices[1] = (GLfloat)(
y +
height);
1650 vertices[0] = (GLfloat)
x;
1651 vertices[1] = (GLfloat)
y;
1654 vertices[0] = (GLfloat)
x;
1655 vertices[1] = (GLfloat)(
y +
height);
1658 vertices[0] = (GLfloat)(
x +
width);
1659 vertices[1] = (GLfloat)
y;
1662 vertices[0] = (GLfloat)(
x);
1663 vertices[1] = (GLfloat)(
y);
1667 for (
int i = 0; i <= steps; i++) {
1668 GLfloat c = cos(i * M_PI / steps);
1672 vertices[2*i+2] = (GLfloat)
x + (GLfloat)
width / 2.0f + (GLfloat)
width * c / 2.0f;
1673 vertices[2*i+3] = (GLfloat)
y + (GLfloat)i * ((GLfloat)
height) / steps ;
1675 vertices[2*i+2] = (GLfloat)
x + (GLfloat)i * ((GLfloat)
width) / steps ;
1676 vertices[2*i+3] = (GLfloat)
y + (GLfloat)
height / 2.0f + (GLfloat)
height * c / 2.0f;
1700 const char *name,
int fontSize, tColor colorText,
int length) :
cOglCmd(fb), fontName(name) {
1732 int fontHeight = f->
Height();
1733 int bottom = f->
Bottom();
1735 FT_ULong prevSym = 0;
1739 int unknown_char = 0;
1740 for (
int i = 0;
symbols[i]; i++) {
1749 if (!unknown_char) {
1751 std::vector<GLfloat> vertices;
1752 vertices.reserve( 4 * 6 *
length);
1754 for (
int i = 0;
symbols[i]; i++) {
1762 LOGWARNING(
"openglosd: %s: could not load glyph %lx", __FUNCTION__, sym);
1773 GLfloat y2 =
y + (fontHeight - bottom - g->
BearingTop());
1774 GLfloat w = g->
Width();
1777 vertices.push_back(x2);
1778 vertices.push_back(y2);
1779 vertices.push_back(g->
XOffset());
1780 vertices.push_back(g->
YOffset());
1782 vertices.push_back(x2 + w);
1783 vertices.push_back(y2);
1785 vertices.push_back(g->
YOffset());
1787 vertices.push_back(x2);
1788 vertices.push_back(y2 + h);
1789 vertices.push_back(g->
XOffset());
1792 vertices.push_back(x2 + w);
1793 vertices.push_back(y2);
1795 vertices.push_back(g->
YOffset());
1797 vertices.push_back(x2);
1798 vertices.push_back(y2 + h);
1799 vertices.push_back(g->
XOffset());
1802 vertices.push_back(x2 + w);
1803 vertices.push_back(y2 + h);
1811 if ( xGlyph >
fb->
Width() - 1 )
1819 LOGDEBUG2(
L_OPENGL,
"openglosd: %s: char %d is not on the texture atlas, use single draw", __FUNCTION__, unknown_char);
1820 for (
int i = 0;
symbols[i]; i++) {
1824 LOGWARNING(
"openglosd: %s: could not load glyph %lx", __FUNCTION__, sym);
1831 kerning = f->
Kerning(g, prevSym);
1835 GLfloat y1 =
y + (fontHeight - bottom - g->
BearingTop());
1836 GLfloat x2 = x1 + g->
Width();
1837 GLfloat y2 = y1 + g->
Height();
1839 GLfloat vertices[] = {
1855 if ( xGlyph >
fb->
Width() - 1 )
1860 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
1871 this->width =
width;
1888 GL_CHECK(glGenTextures(1, &texture));
1889 GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture));
1901 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
1902 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
1903 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
1904 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
1905 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
1912 GLfloat quadVertices[] = {
1928 GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture));
1938 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
1939 GL_CHECK(glDeleteTextures(1, &texture));
1963 GLfloat quadVertices[] = {
2015 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2016 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2017 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2018 GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2019 GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
2045 wait =
new cCondWait();
2074 cCondWait::SleepMs(10);
2076 bool doSignal =
false;
2093 LOGERROR(
"openglosd: %s: cannot store image, no cache set", __FUNCTION__);
2098 LOGERROR(
"openglosd: %s: cannot store image of %dpx x %dpx "
2099 "(maximum size is %dpx x %dpx) - falling back to "
2100 "cOsdProvider::StoreImageData()", __FUNCTION__,
2101 image.Width(), image.Height(),
2106 int imgSize = image.Width() * image.Height();
2107 int newMemUsed = imgSize *
sizeof(tColor) +
memCached;
2109 float cachedMB =
memCached / 1024.0f / 1024.0f;
2111 LOGERROR(
"openglosd: %s: Maximum size for GPU cache reached. Used: %.2fMB Max: %.2fMB", __FUNCTION__, cachedMB, maxMB);
2119 tColor *argb = MALLOC(tColor, imgSize);
2121 LOGERROR(
"openglosd: %s: memory allocation of %d kb for OSD image failed", __FUNCTION__, (
int)(imgSize *
sizeof(tColor) / 1024));
2127 memcpy(argb, image.Data(),
sizeof(tColor) * imgSize);
2130 imageRef->width = image.Width();
2131 imageRef->height = image.Height();
2134 cTimeMs timer(5000);
2135 while (imageRef->used && imageRef->texture == 0 && !timer.TimedOut())
2136 cCondWait::SleepMs(2);
2138 if (imageRef->texture == GL_NONE) {
2139 LOGERROR(
"openglosd: %s: failed to store OSD image texture! (%s)", __FUNCTION__, timer.TimedOut() ?
"timed out" :
"allocation failed");
2184 int imgSize = imageRef->width * imageRef->height *
sizeof(tColor);
2194 LOGERROR(
"openglosd: %s: Could not initiate OpenGL context", __FUNCTION__);
2201 LOGERROR(
"openglosd: %s: Could not initiate shaders", __FUNCTION__);
2208 LOGERROR(
"openglosd: %s: Vertex Buffers NOT initialized", __FUNCTION__);
2221 LOGINFO(
"OpenGL context initialized");
2223 uint64_t start_flush = 0;
2224 uint64_t end_flush = 0;
2239 uint64_t start = cTimeMs::Now();
2240 if (strcmp(cmd->
Description(),
"InitFramebuffer") == 0 || time_reset) {
2241 start_flush = cTimeMs::Now();
2246 LOGDEBUG2(
L_OPENGL_TIME_ALL,
"openglosd: %s: \"%-*s\", %dms, %d commands left, time %" PRIu64
"", __FUNCTION__, 15, cmd->
Description(), (
int)(cTimeMs::Now() - start), (
int)(
commands.size()), cTimeMs::Now());
2248 if (strcmp(cmd->
Description(),
"Copy buffer to OutputFramebuffer") == 0) {
2249 end_flush = cTimeMs::Now();
2251 LOGDEBUG2(
L_OPENGL_TIME,
"openglosd: %s: OSD Flush %dms, time %" PRIu64
"", __FUNCTION__, (
int)(end_flush - start_flush), cTimeMs::Now());
2270 EGL_CHECK(eglMakeCurrent(
Render->EglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
2277 while(!
Render->GlInitiated()) {
2290 GL_CHECK(glDisable(GL_DEPTH_TEST));
2296 for (
int i=0; i <
stCount; i++) {
2307 for (
int i=0; i <
stCount; i++)
2312 for (
int i=0; i <
vbCount; i++) {
2323 for (
int i=0; i <
vbCount; i++) {
2340cOglPixmap::cOglPixmap(std::shared_ptr<cOglThread> oglThread,
int Layer,
const cRect &ViewPort,
const cRect &DrawPort) : cPixmap(Layer, ViewPort, DrawPort) {
2342 int width = DrawPort.IsEmpty() ? ViewPort.Width() : DrawPort.Width();
2343 int height = DrawPort.IsEmpty() ? ViewPort.Height() : DrawPort.Height();
2346 LOGWARNING(
"openglosd: %s: cannot allocate pixmap of %dpx x %dpx, clipped to %dpx x %dpx!", __FUNCTION__,
2347 width, height, std::min(width,
oglThread->MaxTextureSize()), std::min(height,
oglThread->MaxTextureSize()));
2348 width = std::min(width,
oglThread->MaxTextureSize());
2349 height = std::min(height,
oglThread->MaxTextureSize());
2352 fb =
new cOglFb(width, height, ViewPort.Width(), ViewPort.Height());
2357 tinyfont = cFont::CreateFont(Setup.FontOsd, GRIDPOINTSTXTSIZE);
2371 cPixmap::MarkViewPortDirty(Rect);
2376 cPixmap::SetClean();
2381 cPixmap::SetLayer(Layer);
2386 Alpha = constrain(Alpha, ALPHA_TRANSPARENT, ALPHA_OPAQUE);
2387 if (Alpha != cPixmap::Alpha()) {
2388 cPixmap::SetAlpha(Alpha);
2394 cPixmap::SetTile(Tile);
2399 cPixmap::SetViewPort(Rect);
2404 cPixmap::SetDrawPortPoint(Point, Dirty);
2415 MarkDrawPortDirty(DrawPort());
2424 MarkDrawPortDirty(DrawPort());
2435void cOglPixmap::DrawScaledImage(
const cPoint &Point,
const cImage &Image,
double FactorX,
double FactorY, __attribute__ ((unused))
bool AntiAlias) {
2438 tColor *argb = MALLOC(tColor, Image.Width() * Image.Height());
2441 memcpy(argb, Image.Data(),
sizeof(tColor) * Image.Width() * Image.Height());
2445 DrawGridRect(cRect(Point.X(), Point.Y(), Image.Width() * FactorX, Image.Height() * FactorY), GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2448 MarkDrawPortDirty(cRect(Point, cSize(Image.Width() * FactorX, Image.Height() * FactorY)).Intersected(DrawPort().Size()));
2451void cOglPixmap::DrawScaledImage(
const cPoint &Point,
int ImageHandle,
double FactorX,
double FactorY, __attribute__ ((unused))
bool AntiAlias) {
2454 if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) {
2455 sOglImage *img =
oglThread->GetImageRef(ImageHandle);
2458 DrawGridRect(cRect(Point.X(), Point.Y(), img->width * FactorX, img->height * FactorY), GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2461 MarkDrawPortDirty(cRect(Point, cSize(img->width * FactorX, img->height * FactorY)).Intersected(DrawPort().Size()));
2466 cRect r(Point.X(), Point.Y(), 1, 1);
2469 DrawGridRect(cRect(r.X(), r.Y(), 0, 0), GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2472 MarkDrawPortDirty(r);
2479 bool specialColors = ColorFg || ColorBg;
2480 tColor *argb = MALLOC(tColor, Bitmap.Width() * Bitmap.Height());
2485 for (
int py = 0; py < Bitmap.Height(); py++)
2486 for (
int px = 0; px < Bitmap.Width(); px++) {
2487 tIndex index = *Bitmap.Data(px, py);
2488 *p++ = (!index && Overlay) ? clrTransparent : (specialColors ?
2489 (index == 0 ? ColorBg : index == 1 ? ColorFg :
2490 Bitmap.Color(index)) : Bitmap.Color(index));
2495 DrawGridRect(cRect(Point.X(), Point.Y(), Bitmap.Width(), Bitmap.Height()), GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2499 MarkDrawPortDirty(cRect(cPoint(Point.X(), Point.Y()), cSize(Bitmap.Width(), Bitmap.Height())).Intersected(DrawPort().Size()));
2502void cOglPixmap::DrawText(
const cPoint &Point,
const char *s, tColor ColorFg, tColor ColorBg,
const cFont *Font,
int Width,
int Height,
int Alignment) {
2506 int len = s ? Utf8StrLen(s) : 0;
2507 unsigned int *symbols = MALLOC(
unsigned int, len + 1);
2512 Utf8ToArray(s, symbols, len + 1);
2518 int w = Font->Width(s);
2519 int h = Font->Height();
2521 int cw = Width ? Width : w;
2522 int ch = Height ? Height : h;
2525 if (Width > ViewPort().Width() && !x)
2526 x = ViewPort().Width() - w;
2528 cRect r(x, y, cw, ch);
2530 if (ColorBg != clrTransparent)
2533 if (Width || Height) {
2536 if ((Alignment & taLeft) != 0) {
2537 if ((Alignment & taBorder) != 0)
2538 x += std::max(h / TEXT_ALIGN_BORDER, 1);
2539 }
else if ((Alignment & taRight) != 0) {
2542 if ((Alignment & taBorder) != 0)
2543 x -= std::max(h / TEXT_ALIGN_BORDER, 1);
2546 x += (Width - w) / 2;
2551 if ((Alignment & taTop) != 0)
2553 else if ((Alignment & taBottom) != 0) {
2558 y += (Height - h) / 2;
2565 DrawGridRect(cRect(x, y, cw, ch), GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2569 MarkDrawPortDirty(r);
2579 DrawGridRect(Rect, GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2583 MarkDrawPortDirty(Rect);
2593 DrawGridRect(Rect, GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2597 MarkDrawPortDirty(Rect);
2607 DrawGridRect(Rect, GRIDPOINTOFFSET, GRIDPOINTSIZE, GRIDPOINTCLR, GRIDPOINTBG, tinyfont);
2611 MarkDrawPortDirty(Rect);
2615 LOGWARNING(
"openglosd: %s: %d %d %d not implemented in OpenGl OSD", __FUNCTION__, Pixmap->ViewPort().X(), Source.X(), Dest.X());
2619 LOGWARNING(
"openglosd: %s: %d %d %d not implemented in OpenGl OSD", __FUNCTION__, Pixmap->ViewPort().X(), Source.X(), Dest.X());
2623 LOGWARNING(
"openglosd: %s: %d %d not implemented in OpenGl OSD", __FUNCTION__, Source.X(), Dest.X());
2627 LOGWARNING(
"openglosd: %s: %d %d not implemented in OpenGl OSD", __FUNCTION__, Source.X(), Dest.X());
2631void cOglPixmap::DrawGridText(
const cPoint &Point,
const char *s, tColor ColorFg, tColor ColorBg,
const cFont *Font,
int Width,
int Height,
int Alignment) {
2635 int len = s ? Utf8StrLen(s) : 0;
2636 unsigned int *symbols = MALLOC(
unsigned int, len + 1);
2641 Utf8ToArray(s, symbols, len + 1);
2647 int w = Font->Width(s);
2648 int h = Font->Height();
2650 int cw = Width ? Width : w;
2651 int ch = Height ? Height : h;
2653 cRect r(x, y, cw, ch);
2655 if (ColorBg != clrTransparent)
2658 if (Width || Height) {
2661 if ((Alignment & taLeft) != 0) {
2662 if ((Alignment & taBorder) != 0)
2663 x += std::max(h / TEXT_ALIGN_BORDER, 1);
2664 }
else if ((Alignment & taRight) != 0) {
2667 if ((Alignment & taBorder) != 0)
2668 x -= std::max(h / TEXT_ALIGN_BORDER, 1);
2671 x += (Width - w) / 2;
2676 if ((Alignment & taTop) != 0)
2678 else if ((Alignment & taBottom) != 0) {
2683 y += (Height - h) / 2;
2690 MarkDrawPortDirty(r);
2693void cOglPixmap::DrawGridRect(
const cRect &Rect,
int offset,
int size, tColor clr, tColor bg,
const cFont *font) {
2694 int x1 = Rect.X() + offset;
2695 int x2 = Rect.X() + Rect.Width() + offset;
2697 int y2 = Rect.Y() + Rect.Height();
2702 sprintf(p1,
"%d.%d", x1, y1);
2703 sprintf(p2,
"%d.%d", x2, y1);
2704 sprintf(p3,
"%d.%d", x1, y2);
2705 sprintf(p4,
"%d.%d", x2, y2);
2708#ifdef GRIDPOINTSTEXT
2709 this->DrawGridText(cPoint(x1, y1), p1, clr, bg, font);
2711 if (Rect.Width() && Rect.Height()) {
2715#ifdef GRIDPOINTSTEXT
2716 this->DrawGridText(cPoint(x2, y1), p2, clr, bg, font);
2717 this->DrawGridText(cPoint(x1, y2), p3, clr, bg, font);
2718 this->DrawGridText(cPoint(x2, y2), p4, clr, bg, font);
2740 double pixel_aspect;
2744 LOGDEBUG2(
L_OSD,
"openglosd: %s: New Osd %p osdLeft %d osdTop %d screenWidth %d screenHeight %d", __FUNCTION__,
this, Left, Top, osdWidth, osdHeight);
2760 LOGDEBUG2(
L_OSD,
"openglosd: %s: Delete Osd %p", __FUNCTION__,
this);
2777 for (
int i = 0; i < NumAreas; i++)
2778 r.Combine(cRect(Areas[i].x1, Areas[i].y1, Areas[i].Width(), Areas[i].Height()));
2780 tArea area = { r.Left(), r.Top(), r.Right(), r.Bottom(), 32 };
2787 bFb =
new cOglFb(r.Width(), r.Height(), r.Width(), r.Height());
2788 cCondWait initiated;
2792 return cOsd::SetAreas(&area, 1);
2802 if (cOsd::AddPixmap(p)) {
2824 for (
int i = start; i <
oglPixmaps.Size(); i++) {
2826 if (Pixmap->Layer() >= 0)
2830 cOsd::DestroyPixmap(Pixmap);
2840 LOGDEBUG2(
L_OSD,
"openglosd: %s: Flush Osd %p", __FUNCTION__,
this);
2844 for (
int i = 0; i <
oglPixmaps.Size(); i++) {
2867 for (
int layer = 0; layer < MAXPIXMAPLAYERS; layer++) {
2868 for (
int i = 0; i <
oglPixmaps.Size(); i++) {
2881 bool alphablending = layer == 0 ? false :
true;
2909 std::unique_ptr<cBitmap> scaledBitmap;
2910 const cBitmap *b = &Bitmap;
2912 if (!DoubleEqual(FactorX, 1.0) || !DoubleEqual(FactorY, 1.0)) {
2913 scaledBitmap.reset(Bitmap.Scaled(FactorX, FactorY, AntiAlias));
2914 b = scaledBitmap.get();
2920 const cRect &viewport =
oglPixmaps[0]->ViewPort();
2922 xNew -= viewport.X();
2924 yNew -= viewport.Y();
2926 oglPixmaps[0]->DrawBitmap(cPoint(xNew, yNew), *b);
int BearingTop(void) const
void SetKerningCache(FT_ULong prevSym, int kerning)
cVector< tKerning > kerningCache
int BearingLeft(void) const
int GetKerningCache(FT_ULong prevSym)
float YOffset(void) const
cOglAtlasGlyph(FT_ULong charCode, float advanceX, float advanceY, float width, float height, float bearingLeft, float bearingTop, float xoffset, float yoffset)
float XOffset(void) const
virtual ~cOglAtlasGlyph()
cOglCmdBufferFill(cOglFb *fb, GLint color)
virtual bool Execute(void)
cOglCmdCopyBufferToOutputFb(cOglFb *fb, cOglOutputFb *oFb, GLint x, GLint y, int active, cSoftHdDevice *device, cVideoRender *render)
virtual bool Execute(void)
virtual bool Execute(void)
cOglCmdDeleteFb(cOglFb *fb)
GLfloat * CreateVerticesFull(int &numVertices)
GLfloat * CreateVerticesQuadrant(int &numVertices)
virtual bool Execute(void)
GLfloat * CreateVerticesHalf(int &numVertices)
cOglCmdDrawEllipse(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint quadrants)
quadrants: 0 draws the entire ellipse 1..4 draws only the first, second, third or fourth quadrant,...
virtual bool Execute(void)
cOglCmdDrawImage(cOglFb *fb, tColor *argb, GLint width, GLint height, GLint x, GLint y, bool overlay=true, double scaleX=1.0f, double scaleY=1.0f)
virtual ~cOglCmdDrawImage(void)
virtual bool Execute(void)
cOglCmdDrawRectangle(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color)
virtual bool Execute(void)
cOglCmdDrawSlope(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint type)
type: 0: horizontal, rising, lower 1: horizontal, rising, upper 2: horizontal, falling,...
cOglCmdDrawText(cOglFb *fb, GLint x, GLint y, unsigned int *symbols, GLint limitX, const char *name, int fontSize, tColor colorText, int length)
virtual bool Execute(void)
virtual ~cOglCmdDrawText(void)
virtual bool Execute(void)
cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y, double scaleX=1.0f, double scaleY=1.0f)
cOglCmdDropImage(sOglImage *imageRef, cCondWait *wait)
virtual bool Execute(void)
cOglCmdFill(cOglFb *fb, GLint color)
virtual bool Execute(void)
virtual bool Execute(void)
cOglCmdInitFb(cOglFb *fb, cCondWait *wait=NULL)
cOglCmdInitOutputFb(cOglOutputFb *oFb)
virtual bool Execute(void)
virtual bool Execute(void)
cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX, GLint drawPortY, GLint dirtyX, GLint dirtyTop, GLint dirtyWidth, GLint dirtyHeight, bool alphablending, cSoftHdDevice *device)
virtual bool Execute(void)
cOglCmdStoreImage(sOglImage *imageRef, tColor *argb)
virtual ~cOglCmdStoreImage(void)
virtual bool Execute(void)=0
virtual const char * Description(void)=0
virtual void Unbind(void)
GLint ViewportHeight(void)
virtual void BindWrite(void)
GLint ViewportWidth(void)
cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHeight)
cOglAtlasGlyph * GetGlyph(int sym) const
virtual ~cOglFontAtlas(void)
cOglAtlasGlyph * Glyph[MAX_CHARCODE - MIN_CHARCODE+1]
cOglFontAtlas(FT_Face face, int height)
static cList< cOglFont > * fonts
static void Cleanup(void)
cOglFontAtlas * Atlas(void)
static cOglFont * Get(const char *name, int charHeight)
cList< cOglGlyph > glyphCache
int Kerning(cOglGlyph *glyph, FT_ULong prevSym) const
cOglFont(const char *fontName, int charHeight)
int AtlasKerning(cOglAtlasGlyph *glyph, FT_ULong prevSym) const
cOglGlyph * Glyph(FT_ULong charCode) const
void SetKerningCache(FT_ULong prevSym, int kerning)
int BearingTop(void) const
void LoadTexture(FT_BitmapGlyph ftGlyph)
int BearingLeft(void) const
cOglGlyph(FT_ULong charCode, FT_BitmapGlyph ftGlyph)
cVector< tKerning > kerningCache
int GetKerningCache(FT_ULong prevSym)
static cOglOutputFb * oFb
virtual cPixmap * CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort=cRect::Null)
cOglOsd(int Left, int Top, uint Level, std::shared_ptr< cOglThread > oglThread, cSoftHdDevice *device)
std::shared_ptr< cOglThread > oglThread
virtual void DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double FactorX, double FactorY, bool AntiAlias=false)
virtual const cSize & MaxPixmapSize(void) const
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
virtual void DestroyPixmap(cPixmap *Pixmap)
cVector< cOglPixmap * > oglPixmaps
virtual ~cOglOutputFb(void)
virtual void Unbind(void)
cOglOutputFb(GLint width, GLint height)
virtual void BindWrite(void)
virtual void DrawImage(const cPoint &Point, const cImage &Image)
virtual void DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX=1.0f, double FactorY=1.0f, bool AntiAlias=false)
virtual void SetClean(void)
virtual void Fill(tColor Color)
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)
virtual void SetAlpha(int Alpha)
virtual void MarkViewPortDirty(const cRect &Rect)
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)
virtual ~cOglPixmap(void)
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty=true)
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants=0)
virtual void SetViewPort(const cRect &Rect)
virtual void Scroll(const cPoint &Dest, const cRect &Source=cRect::Null)
virtual void SetDirty(bool dirty=true)
cOglPixmap(std::shared_ptr< cOglThread > oglThread, int Layer, const cRect &ViewPort, const cRect &DrawPort=cRect::Null)
virtual void Pan(const cPoint &Dest, const cRect &Source=cRect::Null)
virtual void DrawRectangle(const cRect &Rect, tColor Color)
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type)
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
virtual void DrawPixel(const cPoint &Point, tColor Color)
std::shared_ptr< cOglThread > oglThread
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)
virtual void SetLayer(int Layer)
virtual void SetTile(bool Tile)
std::queue< cOglCmd * > commands
int StoreImage(const cImage &image)
sOglImage * GetImageRef(int slot)
bool InitVertexBuffers(void)
void eglReleaseContext(void)
sOglImage imageCache[OGL_MAX_OSDIMAGES]
cOglThread(cCondWait *startWait, int maxCacheSize, cSoftHdDevice *device)
virtual void Action(void)
void DropImageData(int imageHandle)
void DeleteVertexBuffers(void)
void eglAcquireContext(void)
void EnableBlending(void)
void SetVertexSubData(GLfloat *vertices, int count=0)
void SetShaderProjectionMatrix(GLint width, GLint height)
void SetShaderTexture(GLint value)
void SetShaderColor(GLint color)
void DisableBlending(void)
void SetShaderBorderColor(GLint bcolor)
void DrawArrays(int count=0)
void SetShaderAlpha(GLint alpha)
void ActivateShader(void)
void SetVertexData(GLfloat *vertices, int count=0)
void SetMatrix4(const GLchar *name, const glm::mat4 &matrix)
void SetInteger(const GLchar *name, GLint value)
void SetVector2f(const GLchar *name, GLfloat x, GLfloat y)
void SetFloat(const GLchar *name, GLfloat value)
bool Compile(const char *vertexCode, const char *fragmentCode)
void SetVector3f(const GLchar *name, GLfloat x, GLfloat y, GLfloat z)
bool CheckCompileErrors(GLuint object, bool program=false)
void SetVector4f(const GLchar *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
bool Load(eShaderType type)
void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int)
Draw an OSD pixmap.
virtual void GetOsdSize(int &, int &, double &)
Returns the width, height and aspect ratio the OSD.
cVideoRender * Render(void)
void OsdClose(void)
Close the OSD.
cVideoRender - Video render class
Some helper functions for GL.
Logger class header file.
#define L_OPENGL_TIME_ALL
void ConvertColor(const GLint &colARGB, glm::vec4 &col)
const char * textureFragmentShaderSwapBR
const char * rectVertexShader
static cOglVb * VertexBuffers[vbCount]
const char * textureFragmentShader
const char * rectFragmentShader
const char * textFragmentShader
static cShader * Shaders[stCount]
const char * textureVertexShader
const char * textVertexShader
Osd class - hardware accelerated (OpenGL/ES) - header file.
#define OGL_MAX_OSDIMAGES
const struct @0 FT_Errors[]
#define OGL_CMDQUEUE_SIZE