C++, SDL2, OpenGL - Баг с цветом текста
Использую SDL_ttf для показа текста.
Код:
#include "Text.hpp"
using namespace fox;
Text::Text(){
TTF_Init();
textPolygon.setPointCount(4);
}
void Text::loadFont(std::string path, int size){
font=TTF_OpenFont(path.c_str(), size);
}
void Text::setFillColor(Color color){
textColor.r=color.rgb.r;
textColor.g=color.rgb.g;
textColor.b=color.rgb.b;
textColor.a=0;
mainColor=color.rgb;
}
void Text::setSize(float width, float height){
size.width=width; size.height=height;
textPolygon.setPointSize(0, 0, 0);
textPolygon.setPointSize(1, width, 0);
textPolygon.setPointSize(2, width, height);
textPolygon.setPointSize(3, 0, height);
position.y-=size.height/4;
}
void Text::setPosition(float x, float y){
position.x=x; position.y=y;
}
void Text::setText(std::string text){
textSurface=TTF_RenderText_Blended(font,
text.c_str(), textColor);
glGenTextures(1, &fontID);
glBindTexture(GL_TEXTURE_2D, fontID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textSurface->w,
textSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE,
textSurface->pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
setSize(textSurface->w, textSurface->h);
}
void Text::show(){
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTranslatef(getPosition().x,
getPosition().y, 0);
glBegin(GL_POLYGON);
glTexCoord2f(0, 0); textPolygon.getPoint(0);
glTexCoord2f(1, 0); textPolygon.getPoint(1);
glTexCoord2f(1, 1); textPolygon.getPoint(2);
glTexCoord2f(0, 1); textPolygon.getPoint(3);
glEnd();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
Vector2f Text::getPosition(){
return position;
}
Rectf Text::getSize(){
return size;
}
Color::RGB Text::getFillColor(){
return mainColor;
}
Когда я выставляю красный цвет то показывает синий да и вообще со всеми цветами так, кроме белого!
Почему так?