Пример #1
0
/*
 * Draw a flat-shaded, Z-less, RGB line into an osmesa buffer.
 */
static void flat_color_z_line( GLcontext *ctx,
                                   GLuint v0, GLuint v1, GLuint pv )
{
   OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
   struct vertex_buffer *VB = ctx->VB;
   GLint x1 = (GLint) VB->Win[v0][0], x2 = (GLint) VB->Win[v1][0];
   GLint y1 = (GLint) VB->Win[v0][1], y2 = (GLint) VB->Win[v1][1];
   GLint z1 = (GLint) (VB->Win[v0][2] + ctx->LineZoffset);
   GLint z2 = (GLint) (VB->Win[v1][2] + ctx->LineZoffset);
   unsigned long pixel = PACK_RGBA( VB->Color[pv][0], VB->Color[pv][1],
                                   VB->Color[pv][2], 0 );

   WINCLIP_X(x1,x2);
   WINCLIP_Y(y1,y2);

#define BRESENHAM_PLOT(X,Y,Z,ZBUF)		\
	if (Z < *ZBUF) {			\
          { GLuint *ptr4 = PIXELADDR4(X,Y); *ptr4 = pixel; } \
	   *ZBUF = Z;				\
	}

   BRESENHAM_Z( ctx, x1, y1, z1, x2, y2, z2 );

#undef BRESENHAM_PLOT
}
Пример #2
0
	void update(GraphicsDevice* gdev, int winWidth, int winHeight, s32& gameRunning)
	{
		if (!s_showUI)
			return;

		UISystem::predraw();
		UISystem::begin();

		DrawTextBuf* text = Draw2D::getDrawText();
		text->color = PACK_RGBA(0xa0, 0xff, 0xff, 0xa0);
		text->font = UISystem::getFont(18);
		text->x = c_leftEdge; text->y = 4;
		sprintf(text->msg, "XL Engine  version %s", Settings::getVersion());

		handleMainIcons();
		handleGameSelection(gdev, winWidth, winHeight, gameRunning);

		if (s_menu == MENU_VIDEO)
		{
			handleVideoMenu(gdev, winWidth, winHeight, gameRunning);
		}
		else if (s_menu == MENU_SETTINGS)
		{
			handleSettingsMenu(gdev, winWidth, winHeight, gameRunning);
		}

		UISystem::finish();
	}
Пример #3
0
	void handleVideoMenu(GraphicsDevice* gdev, int winWidth, int winHeight, s32& gameRunning)
	{
		char msg[512];
		XLSettings* settings = Settings::get();

		if (UISystem::window(CTRL_WIN_VIDEO, 1, "Video Settings", 32, 32, 400, 400))
		{
			playUISound(SOUND_DENY);
			s_menu = -1;
			UISystem::setCurrentLayer(0);
		}
		else
		{
			bool fullscreen = (settings->flags&XL_FLAG_FULLSCREEN)!=0;
			bool advancedGL = false;

			UISystem::staticText(1, fullscreen ? "[X] Fullscreen" : "[ ] Fullscreen", 40, 60);
			UISystem::staticText(1, "[ ] Vsync", 40, 80);
			UISystem::staticText(1, "[ ] Stretch to Fit", 40, 100);
			UISystem::staticText(1, "------------- Game Resolution -------------", 40, 140);
			UISystem::staticText(1, "[X] Use 320x200 multiple (16:10 in 4:3)", 40, 160);
			UISystem::staticText(1, "[ ] Use 4:3 aspect ratio", 40, 180);
			sprintf(msg, "Game Resolution: [%dx%d]", settings->gameWidth, settings->gameHeight);
			UISystem::staticText(1, msg, 40, 200);

			Color winResColor = PACK_RGBA(190, 255, 255, 255);
			if (fullscreen) { winResColor = PACK_RGBA(128, 128, 128, 255); }
			UISystem::staticText(1, "--------------- Window Size ---------------", 40, 240, winResColor);

			sprintf(msg, "Window Resolution: [%dx%d]", settings->windowWidth, settings->windowHeight);
			UISystem::staticText(1, msg, 40, 260, winResColor);

			Color advOptColor = PACK_RGBA(190, 255, 255, 255);
			if (!advancedGL) { advOptColor = PACK_RGBA(128, 128, 128, 255); }
			UISystem::staticText(1, "---------------- Graphics -----------------", 40, 300);
			UISystem::staticText(1, "Backend: [OpenGL 1.5 - Fixed Function]", 40, 320);
			UISystem::staticText(1, "[ ] UI Glow", 40, 340, advOptColor);
		}
	}
Пример #4
0
/*
 * Draw a flat-shaded, RGB line into an osmesa buffer.
 */
static void flat_color_line( GLcontext *ctx,
                                 GLuint v0, GLuint v1, GLuint pv )
{
   OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
   struct vertex_buffer *VB = ctx->VB;
   GLint x1 = (GLint) VB->Win[v0][0], y1 = (GLint) VB->Win[v0][1];
   GLint x2 = (GLint) VB->Win[v1][0], y2 = (GLint) VB->Win[v1][1];
   unsigned long pixel = PACK_RGBA( VB->Color[pv][0], VB->Color[pv][1],
                                   VB->Color[pv][2], 0 );
   WINCLIP_X(x1,x2);
   WINCLIP_Y(y1,y2);

#define BRESENHAM_PLOT(X,Y)					\
   { GLuint *ptr4 = PIXELADDR4(X,Y); *ptr4 = pixel; }

   BRESENHAM( x1, y1, x2, y2 );

#undef BRESENHAM_PLOT
}
Пример #5
0
/**
 * rsvg_css_parse_color:
 * @str: string to parse
 * @inherit: whether to inherit
 *
 * Parse a CSS2 color specifier, return RGB value
 *
 * Returns: and RGB value
 */
guint32
rsvg_css_parse_color (const char *str, gboolean * inherit)
{
    gint val = 0;

    SETINHERIT ();

    if (str[0] == '#') {
        int i;
        for (i = 1; str[i]; i++) {
            int hexval;
            if (str[i] >= '0' && str[i] <= '9')
                hexval = str[i] - '0';
            else if (str[i] >= 'A' && str[i] <= 'F')
                hexval = str[i] - 'A' + 10;
            else if (str[i] >= 'a' && str[i] <= 'f')
                hexval = str[i] - 'a' + 10;
            else
                break;
            val = (val << 4) + hexval;
        }
        /* handle #rgb case */
        if (i == 4) {
            val = ((val & 0xf00) << 8) | ((val & 0x0f0) << 4) | (val & 0x00f);
            val |= val << 4;
        }

        val |= 0xff000000; /* opaque */
    }
    else if (g_str_has_prefix (str, "rgb")) {
        gint r, g, b, a;
        gboolean has_alpha;
        guint nb_toks;
        char **toks;

        r = g = b = 0;
        a = 255;

        if (str[3] == 'a') {
            /* "rgba" */
            has_alpha = TRUE;
            str += 4;
        }
        else {
            /* "rgb" */
            has_alpha = FALSE;
            str += 3;
        }

        str = strchr (str, '(');
        if (str == NULL)
          return val;

        toks = rsvg_css_parse_list (str + 1, &nb_toks);

        if (toks) {
            if (nb_toks == (has_alpha ? 4 : 3)) {
                r = rsvg_css_clip_rgb_percent (toks[0], 255.0);
                g = rsvg_css_clip_rgb_percent (toks[1], 255.0);
                b = rsvg_css_clip_rgb_percent (toks[2], 255.0);
                if (has_alpha)
                    a = rsvg_css_clip_rgb_percent (toks[3], 1.0);
                else
                    a = 255;
            }

            g_strfreev (toks);
        }

        val = PACK_RGBA (r, g, b, a);
    } else if (!strcmp (str, "inherit"))
        UNSETINHERIT ();
    else {
        CRRgb rgb;

        if (cr_rgb_set_from_name (&rgb, (const guchar *) str) == CR_OK) {
            val = PACK_RGB (rgb.red, rgb.green, rgb.blue);
        } else {
            /* default to opaque black on failed lookup */
            UNSETINHERIT ();
            val = PACK_RGB (0, 0, 0);
        }
    }

    return val;
}
Пример #6
0
static void set_color( GLcontext *ctx,
                       GLubyte r, GLubyte g, GLubyte b, GLubyte a )
{
   OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
   osmesa->pixel = PACK_RGBA( r, g, b, a );
}
Пример #7
0
	void handleGameSelection(GraphicsDevice* gdev, int winWidth, int winHeight, s32& gameRunning)
	{
		int gx = 100, gy = 64;
		for (int g=0; g<Settings::getGameCount(); g++)
		{
			if (gameRunning == g)
			{
				if (gx + 332 > winWidth-20)
				{
					gx  = 100;
					gy += 350;
				}

				gdev->setVirtualViewport(false, gx, winHeight-gy-200-50, 266, 200);

				DrawTextBuf* text = Draw2D::getDrawText();
				text->color = PACK_RGBA(0xa0, 0xff, 0xff, 0xa0);
				text->font = UISystem::getFont(18);
				text->x = gx+2; text->y = gy+252;

				GameInfo* info = Settings::getGameInfo(g);
				strcpy(text->msg, info->name);

				gx += 332;
				if (gx + 266 > winHeight-20)
				{
					gx  = 100;
					gy += 350;
				}
			}
			else
			{
				GameInfo* info = Settings::getGameInfo(g);
				if (UISystem::buttonIcon(CTRL_GAME_ICON+g, 0, info->iconID, gx, gy))
				{
					if (gameRunning != g)
					{
						playUISound(SOUND_AFFIRM);
						s_stopGame();
						if (s_startGame( g ))
						{
							s_showUI = false;
							gdev->setVirtualViewport(true, 0, 0, 0, 0);
							return;
						}
					}
					else
					{
						playUISound(SOUND_CLICK);
					}
				}

				gx += 300;
				if (gx + 234 > winWidth-20)
				{
					gx  = 100;
					gy += 350;
				}
			}
		}
	}