These items were from the last code challenge review:
Should fix indentation:
"{"
" vec4 col;"
" float lp = v_uv.y;"
" col = u_dirColor * (1.0-lp) + a_color*lp;"
" float a = u_alpha * texture2D(s_texture, v_uv).a;"
" gl_FragColor = col*a;"
"}";
...
"{"
"vec4 col = vec4(0);"
"vec2 unit = 1.0 / u_resolution.xy;"
...
"{"
"for(float y = -r; y [less-than]= r; y += 1.0)"
"{"
"float weight = (r- abs(x)) * (r- abs(y));"
...
"for(float x = -r; x [less-than]= r; x += 1.0)"
"{"
"for(float y = -r; y [less-than]= r; y += 1.0)"
...
"{"
" float a = u_alpha * blur(v_uv).a;"
" gl_FragColor = vec4(a_color.rgb, a);"
...
#include "pxText.h"
#include FT_BITMAP_H
...
// set the requested font size
mUrl = n;
...
if(mShadow) {
//render shadow first
Should remove extra inconsistent spaces:
" float a = u_alpha * texture2D(s_texture, v_uv).a;"
" vec4 color = col * fontAlpha + u_effectColor * (1.0 - fontAlpha);"
" return vec4( color.rgb,color.a*u_alpha);"
" float a = u_alpha * blur(v_uv).a;"
if( useTextureDimsAlways)
if (mShadow && outW > 0 && outH > 0 ) {
if(mOutlineSize > 0 ) {
sizeof(unsigned char )
blendImage[2 * index] = data[2*index2];
blendImage[2 * index+1] = data[2*index2+1];
context.drawRect(mWidth, mHeight, 0, mFillColor, NULL ,0 );
Should be consistent with spacing:
px = (int) (px + mOutlineSize * outlineScale) - 1; //(subW * 0.5)
py = (int) (py + mOutlineSize * outlineScale);//(subH * 0.5)
unsigned char * getGlyphBitmapWithOutline(unsigned short theChar, FT_BBox &bbox);
const GlyphCacheEntry* getGlyph(uint32_t codePoint);
rtError init(const FT_Byte* fontData, FT_Long size, const char* n , FT_Long outlineSize = 0);
Should remove commented out lines:
// " return vec4( color.rgb,max(fontAlpha,outlineAlpha)*color.a*u_alpha);"
// " return vec4( color.rgb,max(fontAlpha,outlineAlpha)*u_alpha);"
// " gl_FragColor = vec4(a_color.rgb, a_color.a*a);"
// " return vec4( a_color.rgb, a_color.a*a);"
// " gl_FragColor = vec4(a_color.rgb, a_color.a*a);"
// FT_Set_Pixel_Sizes(mFace, 0, s);
// return RT_FAIL;
// uint32_t offsetX = 0, offsetY = 0;
// FT_BBox obox;
// FT_Outline_Get_CBox(&(mFace->glyph->outline) , &obox);
// FT_BBox nBox;
// FT_Outline_Get_CBox(&(mFace->glyph->outline) , &nBox);
// uint32_t xBold = (nBox.xMax - nBox.xMin) - (obox.xMax - obox.xMin);
// uint32_t yBold = (nBox.yMax - nBox.yMin) - (obox.yMax - obox.yMin);
// offsetX = xBold >> 1;
// offsetY = yBold >> 1;
// bbox.xMax += offsetX;
// bbox.xMin += offsetX;
// bbox.yMax += offsetY;
// bbox.yMin += offsetY;
// entry->bitmap_left += mShadowBlurRadio;
// entry->bitmap_left = blendImageMinX;
// if(mItalic){
// w += w*ITALIC_ADD_RATE;
// }
Should follow existing code style where opening brace is on separate line:
" if ((fontAlpha + outlineAlpha) > 0.0){"
" else {"
" if ((fontAlpha + outlineAlpha) > 0.0){"
if(gradientColor == nullptr || gradientColor[3] [less-than]= 0.01){
if (strokeColor && strokeColor[3] > 0) {
if (gTextOutlineShader->draw(gResW, gResH, gMatrix.data(), gAlpha, 4, verts, uv,
texture, colorPM, gradientColorPM, strokeColorPM) != PX_OK) {
if (gATextureShader->draw(gResW, gResH, gMatrix.data(), gAlpha, 4, verts, uv, texture, colorPM, gradientColorPM) !=
PX_OK) {
if (texture->getType() == PX_TEXTURE_ALPHA_88) {
if (gTextureBlurForOutlineShader->draw(gResW, gResH, gMatrix.data(), gAlpha, 4, verts, uv, texture, blur, shadowColorPM) != PX_OK) {
if (gTextureBlurShader->draw(gResW, gResH, gMatrix.data(), gAlpha, 4, verts, uv, texture, blur, shadowColorPM) !=
PX_OK) {
if (gAlpha == 0.0 || w [less-than]= 0.0 || h [less-than]= 0.0) {
if (t.getPtr() == NULL) {
}else{
if (mShadow && outW > 0 && outH > 0 ) {
if(mOutlineSize > 0 ) {
unsigned char * pxFont::getGlyphBitmapWithOutline(unsigned short theChar, FT_BBox &bbox)
const GlyphCacheEntry *pxFont::getGlyph(uint32_t codePoint) {
if (outlineBitmap == nullptr) {
for (int x = 0; x [less-than] outlineWidth; ++x) {
for (int y = 0; y [less-than] outlineHeight; ++y) {
if (px + outWidth > blendWidth) {
if (py + outHeight > blendHeight) {
for (unsigned int x = 0; x [less-than] outWidth; ++x) {
for (unsigned int y = 0; y [less-than] outHeight; ++y) {
if (mBold) {
if (newBmp != ret) {
void pxFont::measureTextInternal(const char *text, uint32_t size, float sx, float sy,
float &w, float &h) {
if (!mInitialized) {
while ((codePoint = u8_nextchar((char *) text, &i)) != 0) {
if (codePoint != '\n') {
void pxFont::renderText(const char *text, uint32_t size, float x, float y, float sx, float sy, float *color, float mw,
float *gradientColor, float *strokeColor, float * dropShadowColor, float strokeWidth, bool italic, bool bold,
bool dropShadow, float dropShadowOffsetX, float dropShadowOffsetY, float dropShadowBlur) {
if (!text || !mInitialized) {
if (dropShadow == false || dropShadowColor == NULL || dropShadowColor[3] [less-than]= 0.01) {
} else {
while ((codePoint = u8_nextchar((char *) text, &i)) != 0) {
void pxFont::renderText(const char *text, uint32_t size, float x, float y, float sx, float sy, float *color, float mw,
float *gradientColor, float *strokeColor, float * dropShadowColor, float strokeWidth, bool italic, bool bold,
bool dropShadow, float dropShadowOffsetX, float dropShadowOffsetY, float dropShadowBlur) {
if (codePoint != '\n') {
if (x == 0) {
if(mShadow) {
} else {
if (it != mFontMap.end()) { // local key search in map
} else {
if (fp != nullptr) {
} else {
if (getFontResource()->isFontLoaded()) {
rtError pxText::setItalic(bool var) {
rtError pxText::setBold(bool var) {
void pxText::updateShadowParams() {
rtError pxText::setDropShadow(bool b) {
rtError pxText::setDropShadowOffsetX(float x) {
rtError pxText::setDropShadowOffsetY(float y) {
rtError pxText::setDropShadowBlur(float b) {
rtError pxText::setStrokeWidth(float w) {
Should follow existing code style and use 2-space indentation:
" else {"
" return vec4(0.0,0.0,0.0,0.0);"
" }"
Should follow existing code style and put space after for
or if
:
"for(float x = -r; x [less-than]= r; x += 1.0)"
"for(float y = -r; y [less-than]= r; y += 1.0)"
"for(float x = -r; x [less-than]= r; x += 1.0)"
"for(float y = -r; y [less-than]= r; y += 1.0)"
if( useTextureDimsAlways)
if(gradientColor == nullptr || gradientColor[3] [less-than]= 0.01){
if(mStroker)
Should add comment what 10 represents:
glUniform1f(mBlurRadiusLoc, 10);
You have methods named "dealBold", "dealItalic", and "dealShadow". I think you mean "apply" instead of "deal". In English "deal" doesn't make sense in this context.
Wrong comment:
class textureBlurShaderProgram: public shaderProgram
...
}; //CLASS - textureShaderProgram
What is the purpose of these empty if blocks:
if (gTextOutlineShader->draw(gResW, gResH, gMatrix.data(), gAlpha, 4, verts, uv,
texture, colorPM, gradientColorPM, strokeColorPM) != PX_OK) {
}
if (gATextureShader->draw(gResW, gResH, gMatrix.data(), gAlpha, 4, verts, uv, texture, colorPM, gradientColorPM) !=
PX_OK) {
}
Typo in log:
rtLogInfo("cannot found font = %s", newLocalTTF.c_str());
Should be consistent about space between arguments/parameters:
context.drawRect(mw, mh, 1, mEntered?green:red, white,0);
memcpy(mDropShadowColor,c, sizeof(mDropShadowColor));
getFontResource()->renderText(tempStr, size, xPos, tempY, sx, sy, color, lineWidth, mGradientColor, mStrokeColor,
mDropShadowColor,mStrokeWidth, isItalic, isBold,
isDropShadow, mDropShadowOffsetX, mDropShadowOffsetY, mDropShadowBlur);
getFontResource()->renderText(tempStr, pixelSize, xPos, tempY, 1.0, 1.0, color, lineWidth, mGradientColor,
mStrokeColor,mDropShadowColor,mStrokeWidth, isItalic, isBold,
isDropShadow, mDropShadowOffsetX, mDropShadowOffsetY, mDropShadowBlur);
getFontResource()->renderText(ELLIPSIS_STR, pixelSize, xPos + charW, tempY, 1.0, 1.0, color, lineWidth,
mGradientColor, mStrokeColor,mDropShadowColor,mStrokeWidth, isItalic, isBold,
isDropShadow, mDropShadowOffsetX, mDropShadowOffsetY, mDropShadowBlur);
getFontResource()->renderText(tempStr, pixelSize, xPos, tempY, 1.0, 1.0, color, lineWidth, mGradientColor,
mStrokeColor,mDropShadowColor,mStrokeWidth, isItalic, isBold,
isDropShadow, mDropShadowOffsetX, mDropShadowOffsetY, mDropShadowBlur);
getFontResource()->renderText(ELLIPSIS_STR, pixelSize, xPos + charW, tempY, 1.0, 1.0, color, lineWidth,
mGradientColor, mStrokeColor,mDropShadowColor, mStrokeWidth, isItalic, isBold,
isDropShadow, mDropShadowOffsetX, mDropShadowOffsetY, mDropShadowBlur);
rtProperty(gradientColor,gradientColor, setGradientColor, uint32_t);
rtProperty(strokeWidth, strokeWidth,setStrokeWidth, float);
rtProperty(strokeColor, strokeColor,setStrokeColor, uint32_t);
rtProperty(dropShadowColor, dropShadowColor,setDropShadowColor, uint32_t);
rtProperty(dropShadowOffsetX, dropShadowOffsetX, setDropShadowOffsetX,float);
rtProperty(dropShadowBlur, dropShadowBlur,setDropShadowBlur,float);