opengl stamp wasnt working right, stamp assumed an alpha channel existed.
This commit is contained in:
@@ -152,8 +152,9 @@ void BMF_DrawStringTexture(BMF_Font* font, char* string, float x, float y, float
|
||||
* @param fbuf float image buffer, when NULL to not operate on it.
|
||||
* @param w image buffer width.
|
||||
* @param h image buffer height.
|
||||
* @param channels number of channels in the image (3 or 4 - currently)
|
||||
*/
|
||||
void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h);
|
||||
void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -180,7 +180,7 @@ void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float
|
||||
((BMF_BitmapFont*)font)->DrawStringTexture(string, x, y, z);
|
||||
}
|
||||
|
||||
void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h) {
|
||||
void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels) {
|
||||
if (!font) return;
|
||||
((BMF_BitmapFont*)font)->DrawStringBuf(str, posx, posy, col, buf, fbuf, w, h);
|
||||
((BMF_BitmapFont*)font)->DrawStringBuf(str, posx, posy, col, buf, fbuf, w, h, channels);
|
||||
}
|
||||
|
@@ -241,7 +241,7 @@ void BMF_BitmapFont::DrawStringTexture(char *str, float x, float y, float z)
|
||||
}
|
||||
|
||||
#define FTOCHAR(val) val<=0.0f?0: (val>=1.0f?255: (char)(255.0f*val))
|
||||
void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h)
|
||||
void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@@ -277,7 +277,9 @@ void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, un
|
||||
pixel[0] = colch[0];
|
||||
pixel[1] = colch[1];
|
||||
pixel[2] = colch[2];
|
||||
pixel[4] = 1; /*colch[3];*/
|
||||
if (channels==4) {
|
||||
pixel[4] = 1; /*colch[3];*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -310,7 +312,9 @@ void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, un
|
||||
pixel[0] = col[0];
|
||||
pixel[1] = col[1];
|
||||
pixel[2] = col[2];
|
||||
pixel[3] = 1; /*col[3];*/
|
||||
if (channels==4) {
|
||||
pixel[3] = 1; /*col[3];*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -130,8 +130,9 @@ public:
|
||||
* @param fbuf float image buffer, when NULL to not operate on it.
|
||||
* @param w image buffer width.
|
||||
* @param h image buffer height.
|
||||
* @param channels number of channels in the image (3 or 4 - currently)
|
||||
*/
|
||||
void DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h);
|
||||
void DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels);
|
||||
|
||||
protected:
|
||||
/** Pointer to the font data. */
|
||||
|
@@ -47,7 +47,7 @@ struct anim;
|
||||
void free_image(struct Image *me);
|
||||
|
||||
void BKE_stamp_info(struct ImBuf *ibuf);
|
||||
void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height);
|
||||
void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int channels);
|
||||
int BKE_write_ibuf(struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality);
|
||||
void BKE_makepicstring(char *string, char *base, int frame, int imtype);
|
||||
void BKE_add_image_extension(char *string, int imtype);
|
||||
|
@@ -969,7 +969,7 @@ static void stampdata(StampData *stamp_data, int do_prefix)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int channels)
|
||||
{
|
||||
struct StampData stamp_data;
|
||||
|
||||
@@ -1017,7 +1017,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
/* Top left corner */
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.file);
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
y -= font_height+2; /* Top and bottom 1 pix padding each */
|
||||
}
|
||||
|
||||
@@ -1025,7 +1025,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
if (stamp_data.note[0]) {
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.note);
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
y -= font_height+2; /* Top and bottom 1 pix padding each */
|
||||
}
|
||||
|
||||
@@ -1033,7 +1033,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
if (stamp_data.date[0]) {
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.date);
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
}
|
||||
|
||||
/* Bottom left corner, leaving space for timing */
|
||||
@@ -1042,7 +1042,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
y = font_height+2+1; /* 2 for padding in TIME|FRAME fields below and 1 for padding in this one */
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.marker);
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
}
|
||||
|
||||
/* Left bottom corner */
|
||||
@@ -1051,7 +1051,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
y = 1;
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.time);
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */
|
||||
}
|
||||
|
||||
@@ -1061,7 +1061,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
if (!stamp_data.time[0]) x = 1;
|
||||
y = 1;
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
}
|
||||
|
||||
if (stamp_data.camera[0]) {
|
||||
@@ -1070,7 +1070,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
x = (width/2) - (BMF_GetStringWidth(font, stamp_data.camera)/2);
|
||||
y = 1;
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
}
|
||||
|
||||
if (stamp_data.scene[0]) {
|
||||
@@ -1079,7 +1079,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
x = width - (text_width+1+text_pad);
|
||||
y = 1;
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
}
|
||||
|
||||
if (stamp_data.strip[0]) {
|
||||
@@ -1088,7 +1088,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
|
||||
x = width - (text_width+1+text_pad);
|
||||
y = height - font_height - 1;
|
||||
buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
|
||||
BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
|
||||
BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2022,7 +2022,7 @@ static void renderresult_stampinfo()
|
||||
RenderResult rres;
|
||||
/* this is the basic trick to get the displayed float or char rect from render result */
|
||||
RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
|
||||
BKE_stamp_buf((unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty);
|
||||
BKE_stamp_buf((unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
@@ -1301,7 +1301,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
|
||||
do_ogl_view3d_render(re, v3d, winx, winy);
|
||||
glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32);
|
||||
if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) {
|
||||
BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
|
||||
BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty, 3);
|
||||
}
|
||||
window_swap_buffers(render_win->win);
|
||||
|
||||
@@ -1343,7 +1343,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
|
||||
do_ogl_view3d_render(re, v3d, winx, winy);
|
||||
glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32);
|
||||
if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) {
|
||||
BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
|
||||
BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty, 3);
|
||||
}
|
||||
window_swap_buffers(render_win->win);
|
||||
}
|
||||
|
Reference in New Issue
Block a user