mirror of
https://github.com/fltk/fltk.git
synced 2026-05-30 04:55:29 +08:00
Rename variable from txt_buf to alpha_buf
This commit is contained in:
+8
-8
@@ -416,7 +416,7 @@ int gl_texture_fifo::compute_texture(const char* str, int n)
|
|||||||
|
|
||||||
fifo[current].scale = gl_scale;
|
fifo[current].scale = gl_scale;
|
||||||
fifo[current].fdesc = gl_fontsize;
|
fifo[current].fdesc = gl_fontsize;
|
||||||
char *txt_buf = Fl_Gl_Window_Driver::global()->alpha_mask_for_string(str, n, w, h);
|
char *alpha_buf = Fl_Gl_Window_Driver::global()->alpha_mask_for_string(str, n, w, h);
|
||||||
|
|
||||||
// save GL parameters GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT
|
// save GL parameters GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT
|
||||||
GLint row_length, alignment;
|
GLint row_length, alignment;
|
||||||
@@ -430,12 +430,12 @@ int gl_texture_fifo::compute_texture(const char* str, int n)
|
|||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, w);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, w);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||||
// GL_ALPHA8 is defined in GL/gl.h of X11 and of MinGW32 and of MinGW64 and of OpenGL.framework for MacOS
|
// GL_ALPHA8 is defined in GL/gl.h of X11 and of MinGW32 and of MinGW64 and of OpenGL.framework for MacOS
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA8, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, txt_buf);
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA8, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_buf);
|
||||||
/* For the record: texture construction if an alpha-only-texture is not possible
|
/* For the record: texture construction if an alpha-only-texture is not possible
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, w, h, 0, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, rgba_buf);
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, w, h, 0, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, rgba_buf);
|
||||||
and also, replace GL_SRC_ALPHA by GL_ONE in glBlendFunc() call of display_texture()
|
and also, replace GL_SRC_ALPHA by GL_ONE in glBlendFunc() call of display_texture()
|
||||||
*/
|
*/
|
||||||
delete[] txt_buf; // free the buffer now we have copied it into the Gl texture
|
delete[] alpha_buf; // free the buffer now we have copied it into the GL texture
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
// restore saved GL parameters
|
// restore saved GL parameters
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
|
||||||
@@ -525,13 +525,13 @@ char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w,
|
|||||||
Fl_Surface_Device::pop_current();
|
Fl_Surface_Device::pop_current();
|
||||||
delete image_surface;
|
delete image_surface;
|
||||||
// This gives us an RGB rendering of the text. We build an alpha channel from that.
|
// This gives us an RGB rendering of the text. We build an alpha channel from that.
|
||||||
char *txt_buf = new char [w * h];
|
char *alpha_buf = new char [w * h];
|
||||||
for (int idx = 0; idx < w * h; ++idx)
|
for (int idx = 0; idx < w * h; ++idx)
|
||||||
{ // Fake up the alpha component using the green component's value
|
{ // Fake up the alpha component using the green component's value
|
||||||
txt_buf[idx] = image->array[idx * 3 + 1];
|
alpha_buf[idx] = image->array[idx * 3 + 1];
|
||||||
}
|
}
|
||||||
delete image;
|
delete image;
|
||||||
return txt_buf;
|
return alpha_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -782,7 +782,7 @@ char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, i
|
|||||||
fl_font(f, s * gl_scale);
|
fl_font(f, s * gl_scale);
|
||||||
fl_draw(str, n, 0, fl_height() - fl_descent());
|
fl_draw(str, n, 0, fl_height() - fl_descent());
|
||||||
// get the alpha channel only of the bitmap
|
// get the alpha channel only of the bitmap
|
||||||
char *txt_buf = new char[w*h], *r = txt_buf, *q;
|
char *alpha_buf = new char[w*h], *r = alpha_buf, *q;
|
||||||
q = (char*)CGBitmapContextGetData(surf->offscreen());
|
q = (char*)CGBitmapContextGetData(surf->offscreen());
|
||||||
for (int i = 0; i < h; i++) {
|
for (int i = 0; i < h; i++) {
|
||||||
for (int j = 0; j < w; j++) {
|
for (int j = 0; j < w; j++) {
|
||||||
@@ -792,7 +792,7 @@ char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, i
|
|||||||
}
|
}
|
||||||
Fl_Surface_Device::pop_current();
|
Fl_Surface_Device::pop_current();
|
||||||
delete surf;
|
delete surf;
|
||||||
return txt_buf;
|
return alpha_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FL_CFG_GFX_QUARTZ
|
#endif // FL_CFG_GFX_QUARTZ
|
||||||
|
|||||||
Reference in New Issue
Block a user