Example #1
0
	void label::render(){
		//渲染标签
		float fcR, fcG, fcB, fcA;
		fcR = FgR; fcG = FgG; fcB = FgB; fcA = FgA;
		if (mouseon){
			fcR = FgR*1.2f; fcG = FgG*1.2f; fcB = FgB*1.2f; fcA = FgA*0.8f;
		}
		if (focused){                                                 //Focus
			glDisable(GL_TEXTURE_2D);
			glColor4f(FgR*0.6f, FgG*0.6f, FgB*0.6f, linealpha);
			glLineWidth(linewidth);
			//glBegin(GL_POINTS)
			//glVertex2i(xmin - 1, ymin)
			//glEnd()
			glBegin(GL_LINE_LOOP);
			glVertex2i(xmin, ymin);
			glVertex2i(xmin, ymax);
			glVertex2i(xmax, ymax);
			glVertex2i(xmax, ymin);
			glEnd();
		}
		glEnable(GL_TEXTURE_2D);
		setFontColor(fcR, fcG, fcB, fcA);
		renderChar(xmin, ymin, text);
	}
Example #2
0
void Scene::renderString(const char* str, f32 x, f32 y, int r, int g, int b)
{
    int l = 0;
    while(str[l] != 0) l++;

    x -= (l*25) / 2;

    int i = 0;
    while(str[i] != 0)
    {
        glPolyFmt(POLY_ALPHA(27+rand()%3) | POLY_ID(BG_FX2_POLYID) | POLY_CULL_NONE);
        int rr = r+irand(80);
        if(rr < 0) rr = 0;
        if(rr > 255) rr = 255;
        int gg = g+irand(80);
        if(gg < 0) gg = 0;
        if(gg > 255) gg = 255;
        int bb = b+irand(80);
        if(bb < 0) bb = 0;
        if(bb > 255) bb = 255;

        glColor3b(rr, gg, bb);
        renderChar(str[i], x+frand(1), y+frand(2), 10);
        x += 25;
        i++;
    }
}
Example #3
0
void RrdGlcd::displayChar(int row, int col, char c) {
    int x= col*6;
    // if this wraps the line ignore it
    if(x+6 > WIDTH) return;

    // convert row/column into y and x pixel positions based on font size
    renderChar(this->fb, c, x, row*8);
}
Example #4
0
void CharActor::renderUnrotated()
{
    glPolyFmt(POLY_ALPHA(27+rand()%3) | POLY_ID(BG_FX2_POLYID) | POLY_CULL_NONE);
    
    glColor3b(255, 160+irand(80), 0);
    
    renderChar(c, x+frand(1), y+frand(2), size);
}
Example #5
0
void workshopScene::print(int x, int y, std::string str)
{
    glBindTexture(GL_TEXTURE_2D, font);
    for (unsigned int i = 0; i < str.size(); i++)
    {
        renderChar(x + i * 8, y, str[i]);
    }
}
Example #6
0
Mesh Text::mesh(wstring str, Color color, const TextProperties &properties)
{
    float x = 0, y = 0, w = 0, h = 0;
    float totalHeight = height(str, properties);
    Mesh retval(new Mesh_t());

    for(wchar_t ch : str)
    {
        Matrix mat = Matrix::translate(x, totalHeight - y - 1, 0);
        if(updateFromChar(x, y, w, h, ch, properties))
        {
            renderChar(retval, mat, color, ch);
        }
    }

    return retval;
}
Example #7
0
    void setText(const QString &text, const QFont &font) {
        m_text = text;
        m_charIndex = 0;

        clear();

        for (int i = 0; i < m_text.length(); i++) {
            QChar letter = m_text.at(i);
            QImage image = renderChar(letter, font);
            KisGbrBrush *brush = new KisGbrBrush(image, letter);
            brush->setSpacing(0.1); // support for letter spacing?
            brush->makeMaskImage();

            m_brushesMap.insert(letter, brush);
            KisBrushesPipe<KisGbrBrush>::addBrush(brush);
        }
    }
Example #8
0
void CBitmapFont::renderString(const std::string &str, F32 x, F32 y, F32 size){
	if(!mTextures.size())
		makeFont();
	F32 w,h;
	stringSize(str, &w, &h);
	if(x != -9999.0 && y != -9999.0){
		pen.x = x;
		pen.y = y + 16;
	}
	F32 startx = 0;

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	for(S32 i = 0 ; i < str.size() ; i++){
        if(str[i] == '\n'){
            pen.x = startx;
            pen.y += getFontSize() * 64.0 * 1.4 / dpi;
        } else
            renderChar(str[i]);
	}
	glDisable(GL_BLEND);
}
Example #9
0
	void button::render(){

		//渲染按钮
		float fcR, fcG, fcB, fcA;
		fcR = FgR; fcG = FgG; fcB = FgB; fcA = FgA;
		if (mouseon){
			fcR = FgR*1.2f; fcG = FgG*1.2f; fcB = FgB*1.2f; fcA = FgA*0.8f;
		}
		if (pressed){
			fcR = FgR*0.8f; fcG = FgG*0.8f; fcB = FgB*0.8f; fcA = FgA*1.5f;
		}
		if (!enabled){
			fcR = FgR*0.5f; fcG = FgG*0.5f; fcB = FgB*0.5f; fcA = FgA*0.3f;
		}
		glColor4f(fcR, fcG, fcB, fcA);

		glDisable(GL_TEXTURE_2D);    //Button
		glBegin(GL_QUADS);
		glVertex2i(xmin, ymin);
		glVertex2i(xmin, ymax);
		glVertex2i(xmax, ymax);
		glVertex2i(xmax, ymin);
		glEnd();
		glColor4f(FgR*0.9f, FgG*0.9f, FgB*0.9f, linealpha);

		if (!enabled) glColor4f(0.5f, 0.5f, 0.5f, linealpha);
		glLineWidth(linewidth);
		glBegin(GL_LINE_LOOP);
		glVertex2i(xmin, ymin);
		glVertex2i(xmin, ymax);
		glVertex2i(xmax, ymax);
		glVertex2i(xmax, ymin);
		glEnd();

		glBegin(GL_LINE_LOOP);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmin + 1, ymin + 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmin + 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmax - 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmax - 1, ymin + 1);

		glEnd();

		glEnable(GL_TEXTURE_2D);
		setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
		if (!enabled) setFontColor(0.6f, 0.6f, 0.6f, 1.0f);
		renderChar((xmin + xmax - getStrWidth(text)) / 2, (ymin + ymax - 20) / 2, text);
	}
Example #10
0
	void trackbar::render(){

		//渲染TrackBar(How can I translate it?)
		float fcR, fcG, fcB, fcA;
		float bcR, bcG, bcB, bcA;
		fcR = FgR; fcG = FgG; fcB = FgB; fcA = FgA;
		bcR = BgR; bcG = BgG; bcB = BgB; bcA = BgA;
		if (mouseon){
			fcR = FgR*1.2f; fcG = FgG*1.2f; fcB = FgB*1.2f; fcA = FgA*0.8f;
		}
		if (pressed){
			fcR = FgR*0.8f; fcG = FgG*0.8f; fcB = FgB*0.8f; fcA = FgA*1.5f;
		}
		if (!enabled){
			fcR = FgR*0.5f; fcG = FgG*0.5f; fcB = FgB*0.5f; fcA = FgA*0.3f;
		}

		glColor4f(bcR, bcG, bcB, bcA);                                              //Track
		glDisable(GL_TEXTURE_2D);
		glBegin(GL_QUADS);
		glVertex2i(xmin, ymin);
		glVertex2i(xmax, ymin);
		glVertex2i(xmax, ymax);
		glVertex2i(xmin, ymax);
		glEnd();
		glDisable(GL_TEXTURE_2D);                                                //Bar
		glColor4f(fcR, fcG, fcB, fcA);
		glBegin(GL_QUADS);
		glVertex2i(xmin + barpos, ymin);
		glVertex2i(xmin + barpos + barwidth, ymin);
		glVertex2i(xmin + barpos + barwidth, ymax);
		glVertex2i(xmin + barpos, ymax);
		glEnd();
		glColor4f(FgR*0.9f, FgG*0.9f, FgB*0.9f, linealpha);

		if (!enabled) glColor4f(0.5f, 0.5f, 0.5f, linealpha);
		//glLineWidth(linewidth)                                                  //Focus
		glBegin(GL_LINE_LOOP);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmin + 1, ymin + 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmin + 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.4f, 0.4f, 0.4f, linealpha);
		glVertex2i(xmax - 1, ymax - 1);

		if (focused)
			glColor4f(1.0f, 1.0f, 1.0f, linealpha);
		else
			glColor4f(0.8f, 0.8f, 0.8f, linealpha);
		glVertex2i(xmax - 1, ymin + 1);

		glEnd();
		glEnable(GL_TEXTURE_2D);
		setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
		if (!enabled) setFontColor(0.6f, 0.6f, 0.6f, 1.0f);
		renderChar((xmin + xmax - getStrWidth(text)) / 2, ymin, text);

	}
Example #11
0
/****************Function to render keys using OpenGL selection or render mode****************/
static void Render(GLenum mode) {
    GLint i;
    float colorVal = 0.3;

    for (i = 0; i <= noOfVertices; i++) {
        if (mode == GL_SELECT) {
            glLoadName(i);
        }

        glBegin(GL_POLYGON);

        glColor3ub(colorVal, colorVal, colorVal);
        glVertex3fv(Vertex[i].v1);

        glColor3f(colorVal, colorVal, colorVal);
        glVertex3fv(Vertex[i].v2);

        glColor3ubv(Vertex[i].color);
        glVertex3fv(Vertex[i].v3);

        glColor3ubv(Vertex[i].color);
        glVertex3fv(Vertex[i].v4);

        glEnd();

        glColor3f(1, 1, 1);
        renderChar(((Vertex[i].v1[0] + Vertex[i].v2[0]) / 2) - strlen(Vertex[i].chN) * 1.5, Vertex[i].v1[1] + keyHeight * 0.2, Vertex[i].chN);
        renderChar(((Vertex[i].v1[0] + Vertex[i].v2[0]) / 2) - strlen(Vertex[i].chS) * 1.5, Vertex[i].v1[1] + keyHeight * 0.6, Vertex[i].chS);
    }

    if(zoomedKey!=-1)
    {
        glBegin(GL_POLYGON);

        glColor3f(colorVal, colorVal, colorVal);
        glVertex3fv(Vertex[zoomedKey].v1);

        glColor3f(colorVal, colorVal, colorVal);
        glVertex3fv(Vertex[zoomedKey].v2);

        glColor3ubv(Vertex[zoomedKey].color);
        glVertex3fv(Vertex[zoomedKey].v3);

        glColor3ubv(Vertex[zoomedKey].color);
        glVertex3fv(Vertex[zoomedKey].v4);

        glEnd();

        glColor3f(1, 1, 1);
        renderChar(((Vertex[zoomedKey].v1[0] + Vertex[zoomedKey].v2[0]) / 2) - strlen(Vertex[zoomedKey].chN) * 1.5, Vertex[zoomedKey].v1[1] + keyHeight * 0.5, Vertex[zoomedKey].chN);
        renderChar(((Vertex[zoomedKey].v1[0] + Vertex[zoomedKey].v2[0]) / 2) - strlen(Vertex[zoomedKey].chS) * 1.5, Vertex[zoomedKey].v1[1] + keyHeight , Vertex[zoomedKey].chS);

        zoomedKey = -1;
    }




    //Render text on output bar
    glColor3f(1, 1, 1);
    renderChar(xOrigin + 2, Vertex[0].v1[1] + keyHeight+20 , text);

    Vertex[0].color[0] = 0.0;
    Vertex[0].color[1] = 0.0;
    Vertex[0].color[2] = 0.0;

}