コード例 #1
0
ファイル: GUI_button.c プロジェクト: sphaero/TableGUI
void GUIButton_Draw(TGUIWidget *AWidget)
{
  TGUIWidgetProperties *BWidgetProperties = (TGUIWidgetProperties *)Widget_GetPointer(AWidget, "prop");
  TGUIButtonProperties *BButtonProperties = (TGUIButtonProperties *)Widget_GetPointer(AWidget, "btn");
  
  if (BWidgetProperties->FEnabled)
  {
    if (BWidgetProperties->FDown)
    {
      glSetColor(BButtonProperties->FColorDown);
    } else
    {
      if (AWidget == AWidget->FWindow->FWidgetMouseOver)
      {
        glSetColor(BButtonProperties->FColorHighlight);
      } else
      {
        glSetColor(BButtonProperties->FColorNormal);
      };
    };
  } else
  {
    glSetColor(BButtonProperties->FColorDisabled);
  };
  glClear(GL_COLOR_BUFFER_BIT);
  glPrint(AWidget->FWindow->FFont, (BWidgetProperties->FWidth / 2) - (glTextWidth(AWidget->FWindow->FFont, BButtonProperties->FText->FPointer) / 2),
                                   (BWidgetProperties->FHeight / 2) + (glTextHeight(AWidget->FWindow->FFont, BButtonProperties->FText->FPointer) / 2),
                                   BButtonProperties->FText->FPointer,
                                   0.0f, 0.0f, 0.0f);
};
コード例 #2
0
void GvMaterial::glSetColor()
{
   glSetColor(0);
}
コード例 #3
0
ファイル: drawinfo.cpp プロジェクト: Nlcke/gideros
static void drawIP(const char* ip, int size, int xx, int yy)
{
    static const char* chardot = " "
                                 " "
                                 " "
                                 " "
                                 ".";

    static const char* charcolon = " "
                                   "."
                                   " "
                                   "."
                                   " ";

    static const char* char0 = " .. "
                               ".  ."
                               ".  ."
                               ".  ."
                               " .. ";

    static const char* char1 = " . "
                               ".. "
                               " . "
                               " . "
                               "...";

    static const char* char2 = " .. "
                               ".  ."
                               "  . "
                               " .  "
                               "....";

    static const char* char3 = "... "
                               "   ."
                               " .. "
                               "   ."
                               "... ";

    static const char* char4 = "  .."
                               " . ."
                               ".  ."
                               "...."
                               "   .";

    static const char* char5 = "...."
                               ".   "
                               "...."
                               "   ."
                               "... ";

    static const char* char6 = " .. "
                               ".   "
                               "... "
                               ".  ."
                               " .. ";

    static const char* char7 = "...."
                               "   ."
                               "  . "
                               "  . "
                               "  . ";

    static const char* char8 = " .. "
                               ".  ."
                               " .. "
                               ".  ."
                               " .. ";

	static const char* char9 = " .. "
							   ".  ."
		                       " ..."
		                       "   ."
		                       " .. ";

	static const char* chara = " .. "
		                       ".  ."
		                       "...."
		                       ".  ."
		                       ".  .";

	static const char* charb = "... "
		                       ".  ."
		                       "... "
		                       ".  ."
		                       "... ";

	static const char* charc = " ..."
		                       ".   "
		                       ".   "
		                       ".   "
		                       " ...";

	static const char* chard = "... "
		                       ".  ."
		                       ".  ."
		                       ".  ."
		                       "... ";

	static const char* chare = "...."
		                       ".   "
		                       "... "
		                       ".   "
		                       "....";

	static const char* charf = "...."
		                       ".   "
		                       "... "
		                       ".   "
		                       ".   ";

	static const char* charPercent = ".   ."
                                     "   . "
                                     "  .  "
                                     " .   "
                                     ".   .";

    static const char* charX = ".  ."
                               ".  ."
                               " .. "
                               ".  ."
                               ".  .";

    static const char* charSpace = " "
                                   " "
                                   " "
                                   " "
                                   " ";

	static const char* loading =
        ".    ..   ..  ...  . .  .  ..."
        ".   .  . .  . .  . . .. . .   "
        ".   .  . .... .  . . . .. . .."
        ".   .  . .  . .  . . .  . .  ."
        "...  ..  .  . ...  . .  .  ...";


	static const char* localip =
        ".    ..   ...  ..  .     . ...   . .  . ...  ..   "
        ".   .  . .    .  . .     . .  .  . .. . .   .  . ."
        ".   .  . .    .... .     . ...   . . .. ... .  .  "
        ".   .  . .    .  . .     . .     . .  . .   .  . ."
        "...  ..   ... .  . ...   . .     . .  . .    ..   ";

    static const char* resolution =
        "...  ...  ...  ..  .   .  . ..... .  ..  .  .  "
        ".  . .   .    .  . .   .  .   .   . .  . .. . ."
        "...  ...  ..  .  . .   .  .   .   . .  . . ..  "
        ". .  .      . .  . .   .  .   .   . .  . .  . ."
        ".  . ... ...   ..  ...  ..    .   .  ..  .  .  ";

    static const char* hardware =
        ".  .  ..  ...  ...  . . .  ..  ...  ...  "
        ".  . .  . .  . .  . . . . .  . .  . .   ."
        ".... .... ...  .  . . . . .... ...  ...  "
        ".  . .  . . .  .  .  . .  .  . . .  .   ."
        ".  . .  . .  . ...   . .  .  . .  . ...  ";

    static const char* zoom =
        "....  ..   ..  .   .  "
        "   . .  . .  . .. .. ."
        " ..  .  . .  . . . .  "
        ".    .  . .  . .   . ."
        "....  ..   ..  .   .  ";

	static const char* chars[] = {char0, char1, char2, char3, char4, char5, char6, char7, char8, char9, chara, charb, charc, chard, chare, charf };

	glPushColor();

    glSetColor(infoColor_[0], infoColor_[1], infoColor_[2], 1);

	float v[8];

	int len = strlen(ip);
	for (int i = 0; i < len; ++i)
	{
		const char* chr=charSpace;
        if (ip[i] == '.')
			chr = chardot;
        else if (ip[i] == ':')
			chr = charcolon;
        else if(ip[i] == ' ')
            chr = charSpace;
        else if(ip[i] == 'X')
            chr = charX;
        else if(ip[i] == '%')
            chr = charPercent;
        else if (ip[i] == 'I')
			chr = localip;
        else if (ip[i] == 'L')
			chr = loading;
        else if (ip[i] == 'R')
            chr = resolution;
        else if (ip[i] == 'H')
            chr = hardware;
        else if (ip[i] == 'Z')
            chr = zoom;
		else if ((ip[i]>='a')&&(ip[i]<='f'))
			chr = chars[ip[i] - 'a'+10];
		else if ((ip[i] >= '0') && (ip[i] <= '9'))
			chr = chars[ip[i] - '0'];

		int height = 5;
		int width = strlen(chr) / height;

		for (int y = 0; y < height; ++y)
			for (int x = 0; x < width; ++x)
			{
				if (chr[x + y * width] == '.')
				{
					//glBegin(GL_QUADS);
					//glVertex2i((x + xx)     * size, (y + yy)     * size);
					//glVertex2i((x + xx + 1) * size, (y + yy)     * size);
					//glVertex2i((x + xx + 1) * size, (y + yy + 1) * size);
					//glVertex2i((x + xx)     * size, (y + yy + 1) * size);
					//glEnd();

					v[0] = (x + xx)     * size; v[1] = (y + yy)     * size;
					v[2] = (x + xx + 1) * size; v[3] = (y + yy)     * size;
					v[4] = (x + xx)     * size; v[5] = (y + yy + 1) * size;
					v[6] = (x + xx + 1) * size; v[7] = (y + yy + 1) * size;

					ShaderProgram::stdBasic->setData(ShaderProgram::DataVertex,ShaderProgram::DFLOAT,2, v,4, true, NULL);
					ShaderProgram::stdBasic->drawArrays(ShaderProgram::TriangleStrip, 0, 4);
				}
			}

		xx = xx + width + 1;
	}


	glPopColor();
}