Esempio n. 1
0
static void ST_DrawDamageMarkers(void)
{
	damagemarker_t *dmgmarker;

	for (dmgmarker = dmgmarkers.next; dmgmarker != &dmgmarkers;
	     dmgmarker = dmgmarker->next) {
		static vtx_t v[3];
		player_t *p;
		float angle;
		byte alpha;

		GL_SetState(GLSTATE_BLEND, 1);
		GL_SetOrtho(0);

		alpha = (dmgmarker->tics << 3);

		if (alpha < 0)
			alpha = 0;

		v[0].x = -8;
		v[0].a = alpha;
		v[1].x = 8;
		v[1].a = alpha;
		v[2].y = 4;
		v[2].r = 255;
		v[2].a = alpha;

		p = &players[consoleplayer];

		angle = (float)TRUEANGLES(p->mo->angle -
					  R_PointToAngle2(dmgmarker->source->x,
							  dmgmarker->source->y,
							  p->mo->x, p->mo->y));

		dglPushMatrix();
		dglTranslatef(160, 120, 0);
		dglRotatef(angle, 0.0f, 0.0f, 1.0f);
		dglTranslatef(0, 16, 0);
		dglDisable(GL_TEXTURE_2D);
		dglSetVertex(v);
		dglTriangle(0, 1, 2);
		dglDrawGeometry(3, v);
		dglEnable(GL_TEXTURE_2D);
		dglPopMatrix();

		GL_ResetViewport();
		GL_SetState(GLSTATE_BLEND, 0);
	}
}
Esempio n. 2
0
static int RLXAPI CreateSurface(int numberOfSparePages)
{
    GL_InstallExtensions();
	GL_ResetViewport();
    return 0;
}
Esempio n. 3
0
static int RLXAPI CreateSurface(int numberOfSparePages)
{
	static GLint          attrib[32];
	GLint		*pAttrib =  attrib;

	*pAttrib = AGL_RGBA; pAttrib++;
	*pAttrib = AGL_DOUBLEBUFFER; pAttrib++;
	*pAttrib = AGL_NONE; pAttrib++;

    AGLPixelFormat fmt;
    GLboolean      ok;

    g_pRLX->pGX->View.lpBackBuffer   = NULL;

    /* Choose an rgb pixel format */
    GDHandle gdhDisplay;
    ok = DMGetGDeviceByDisplayID((DisplayIDType)g_cgDisplayID, &gdhDisplay, false);
    SYS_ASSERT(ok == noErr);
    fmt = aglChoosePixelFormat(&gdhDisplay, 1, attrib);
	SYS_AGLTRACE(0);
    if(fmt == NULL)
    {
        ok = SYS_AGLTRACE(aglGetError());
		return -1;
    }
    /* Create an AGL context */
    g_pAGLC = aglCreateContext(fmt, NULL);
    SYS_AGLTRACE(0);
	if(g_pAGLC == NULL)
		return -2;

    /* Attach the window to the context */
    ok = SYS_AGLTRACE(aglSetDrawable(g_pAGLC, GetWindowPort(g_hWnd)));
    if(!ok)
		return -3;

    /* Make the context the current context */
    ok = SYS_AGLTRACE(aglSetCurrentContext(g_pAGLC));
    if(!ok)
		return -4;

	SizeWindow(g_hWnd, gl_lx, gl_ly, true);
	if ((g_pRLX->Video.Config & RLXVIDEO_Windowed))
		CenterWindow(g_hWnd);
    ShowWindow(g_hWnd);

	// copy portRect
	GetPortBounds(GetWindowPort(g_hWnd), g_pRect);

    /* Pixel format is no more needed */
    aglDestroyPixelFormat(fmt);

    if (!(g_pRLX->Video.Config & RLXVIDEO_Windowed))
    {
		HideMenuBar();
        aglSetFullScreen(g_pAGLC, 0, 0, 0, 0);
	    GLint swap = !!(g_pRLX->pGX->View.Flags & GX_CAPS_VSYNC);
        aglSetInteger(g_pAGLC, AGL_SWAP_INTERVAL, &swap);
		SYS_AGLTRACE(0);
	}

    // Reset engine
    GL_InstallExtensions();
	GL_ResetViewport();

	g_pRLX->pGX->Surfaces.maxSurface = numberOfSparePages;;

	if (g_pRLX->pGX->View.Flags & GX_CAPS_MULTISAMPLING)
	{
		glEnable(GL_MULTISAMPLE_ARB);
	}

    return 0;
}
Esempio n. 4
0
int Draw_BigText(int x, int y, rcolor color, const char* string) {
    int c = 0;
    int i = 0;
    int vi = 0;
    int index = 0;
    float vx1 = 0.0f;
    float vy1 = 0.0f;
    float vx2 = 0.0f;
    float vy2 = 0.0f;
    float tx1 = 0.0f;
    float tx2 = 0.0f;
    float ty1 = 0.0f;
    float ty2 = 0.0f;
    float smbwidth;
    float smbheight;
    int pic;

    if(x <= -1) {
        x = Center_Text(string);
    }

    y += 14;

    pic = GL_BindGfxTexture("SYMBOLS", true);

    smbwidth = (float)gfxwidth[pic];
    smbheight = (float)gfxheight[pic];

    dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, DGL_CLAMP);
    dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, DGL_CLAMP);

    dglSetVertex(vtxstring);

    GL_SetState(GLSTATE_BLEND, 1);
    GL_SetOrtho(0);

    for(i = 0, vi = 0; i < dstrlen(string); i++, vi += 4) {
        vx1 = (float)x;
        vy1 = (float)y;

        c = string[i];
        if(c == '\n' || c == '\t') {
            continue;    // villsa: safety check
        }
        else if(c == 0x20) {
            x += 6;
            continue;
        }
        else {
            if(c >= '0' && c <= '9') {
                index = (c - '0') + SM_NUMBERS;
            }
            if(c >= 'A' && c <= 'Z') {
                index = (c - 'A') + SM_FONT1;
            }
            if(c >= 'a' && c <= 'z') {
                index = (c - 'a') + SM_FONT2;
            }
            if(c == '-') {
                index = SM_MISCFONT;
            }
            if(c == '%') {
                index = SM_MISCFONT + 1;
            }
            if(c == '!') {
                index = SM_MISCFONT + 2;
            }
            if(c == '.') {
                index = SM_MISCFONT + 3;
            }
            if(c == '?') {
                index = SM_MISCFONT + 4;
            }
            if(c == ':') {
                index = SM_MISCFONT + 5;
            }

            // [kex] use 'printf' style formating for special symbols
            if(c == '/') {
                c = string[++i];

                switch(c) {
                // up arrow
                case 'u':
                    index = SM_MICONS + 17;
                    break;
                // down arrow
                case 'd':
                    index = SM_MICONS + 16;
                    break;
                // right arrow
                case 'r':
                    index = SM_MICONS + 18;
                    break;
                // left arrow
                case 'l':
                    index = SM_MICONS;
                    break;
                // cursor box
                case 'b':
                    index = SM_MICONS + 1;
                    break;
                // thermbar
                case 't':
                    index = SM_THERMO;
                    break;
                // thermcursor
                case 's':
                    index = SM_THERMO + 1;
                    break;
                default:
                    return 0;
                }
            }

            vx2 = vx1 + symboldata[index].w;
            vy2 = vy1 - symboldata[index].h;

            tx1 = ((float)symboldata[index].x / smbwidth) + 0.001f;
            tx2 = (tx1 + (float)symboldata[index].w / smbwidth) - 0.002f;

            ty1 = ((float)symboldata[index].y / smbheight);
            ty2 = ty1 + (((float)symboldata[index].h / smbheight));

            vtxstring[vi + 0].x     = vx1;
            vtxstring[vi + 0].y     = vy1;
            vtxstring[vi + 0].tu    = tx1;
            vtxstring[vi + 0].tv    = ty2;
            vtxstring[vi + 1].x     = vx2;
            vtxstring[vi + 1].y     = vy1;
            vtxstring[vi + 1].tu    = tx2;
            vtxstring[vi + 1].tv    = ty2;
            vtxstring[vi + 2].x     = vx2;
            vtxstring[vi + 2].y     = vy2;
            vtxstring[vi + 2].tu    = tx2;
            vtxstring[vi + 2].tv    = ty1;
            vtxstring[vi + 3].x     = vx1;
            vtxstring[vi + 3].y     = vy2;
            vtxstring[vi + 3].tu    = tx1;
            vtxstring[vi + 3].tv    = ty1;

            dglSetVertexColor(vtxstring + vi, color, 4);

            dglTriangle(vi + 2, vi + 1, vi + 0);
            dglTriangle(vi + 3, vi + 2, vi + 0);

            if(devparm) {
                vertCount += 4;
            }

            x += symboldata[index].w;
        }
    }

    if(vi) {
        dglDrawGeometry(vi, vtxstring);
    }

    GL_ResetViewport();
    GL_SetState(GLSTATE_BLEND, 0);

    return x;
}
Esempio n. 5
0
int Draw_Text(int x, int y, rcolor color, float scale,
              dboolean wrap, const char* string, ...) {
    int c;
    int i;
    int vi = 0;
    int    col;
    const float size = 0.03125f;
    float fcol, frow;
    int start = 0;
    dboolean fill = false;
    char msg[MAX_MESSAGE_SIZE];
    va_list    va;
    const int ix = x;

    va_start(va, string);
    vsprintf(msg, string, va);
    va_end(va);

    GL_SetState(GLSTATE_BLEND, 1);

    if(!r_fillmode.value) {
        dglEnable(GL_TEXTURE_2D);
        dglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        r_fillmode.value = 1.0f;
        fill = true;
    }

    GL_BindGfxTexture("SFONT", true);

    dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, DGL_CLAMP);
    dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, DGL_CLAMP);

    GL_SetOrthoScale(scale);
    GL_SetOrtho(0);

    dglSetVertex(vtxstring);

    for(i = 0, vi = 0; i < dstrlen(msg); i++, vi += 4) {
        c = toupper(msg[i]);
        if(c == '\t') {
            while(x % 64) {
                x++;
            }
            continue;
        }
        if(c == '\n') {
            y += ST_FONTWHSIZE;
            x = ix;
            continue;
        }
        if(c == 0x20) {
            if(wrap) {
                if(x > 192) {
                    y += ST_FONTWHSIZE;
                    x = ix;
                    continue;
                }
            }
        }
        else {
            start = (c - ST_FONTSTART);
            col = start & (ST_FONTNUMSET - 1);

            fcol = (col * size);
            frow = (start >= ST_FONTNUMSET) ? 0.5f : 0.0f;

            vtxstring[vi + 0].x     = (float)x;
            vtxstring[vi + 0].y     = (float)y;
            vtxstring[vi + 0].tu    = fcol + 0.0015f;
            vtxstring[vi + 0].tv    = frow + size;
            vtxstring[vi + 1].x     = (float)x + ST_FONTWHSIZE;
            vtxstring[vi + 1].y     = (float)y;
            vtxstring[vi + 1].tu    = (fcol + size) - 0.0015f;
            vtxstring[vi + 1].tv    = frow + size;
            vtxstring[vi + 2].x     = (float)x + ST_FONTWHSIZE;
            vtxstring[vi + 2].y     = (float)y + ST_FONTWHSIZE;
            vtxstring[vi + 2].tu    = (fcol + size) - 0.0015f;
            vtxstring[vi + 2].tv    = frow + 0.5f;
            vtxstring[vi + 3].x     = (float)x;
            vtxstring[vi + 3].y     = (float)y + ST_FONTWHSIZE;
            vtxstring[vi + 3].tu    = fcol + 0.0015f;
            vtxstring[vi + 3].tv    = frow + 0.5f;

            dglSetVertexColor(vtxstring + vi, color, 4);

            dglTriangle(vi + 0, vi + 1, vi + 2);
            dglTriangle(vi + 0, vi + 2, vi + 3);

            if(devparm) {
                vertCount += 4;
            }


        }
        x += ST_FONTWHSIZE;
    }

    if(vi) {
        dglDrawGeometry(vi, vtxstring);
    }

    GL_ResetViewport();

    if(fill) {
        dglDisable(GL_TEXTURE_2D);
        dglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        r_fillmode.value = 0.0f;
    }

    GL_SetState(GLSTATE_BLEND, 0);
    GL_SetOrthoScale(1.0f);

    return x;
}
Esempio n. 6
0
static int RLXAPI CreateSurface(int numberOfSparePages)
{
    CGOpenGLDisplayMask displayMask = CGDisplayIDToOpenGLDisplayMask( g_cgDisplayID ) ;
    static CGLPixelFormatAttribute attribs[32];
	CGLPixelFormatAttribute	*pAttrib =  attribs;
    CGLPixelFormatObj pixelFormatObj ;
    long numPixelFormats = 0;

	*pAttrib = kCGLPFAFullScreen; pAttrib++;
	*pAttrib = kCGLPFASingleRenderer; pAttrib++;

	*pAttrib = kCGLPFADisplayMask; pAttrib++;
	*pAttrib = (CGLPixelFormatAttribute)displayMask; pAttrib++;

	*pAttrib = kCGLPFADoubleBuffer; pAttrib++;
	*pAttrib = kCGLPFAColorSize; pAttrib++;
	*pAttrib = (CGLPixelFormatAttribute)gl_bpp; pAttrib++;

	 if ((g_pRLX->pGX->View.Flags & GX_CAPS_MULTISAMPLING))
	{
		*pAttrib = kCGLPFASampleBuffers; pAttrib++;
		*pAttrib = (CGLPixelFormatAttribute)1;  pAttrib++;

		*pAttrib = kCGLPFASamples;  pAttrib++;
		*pAttrib = (CGLPixelFormatAttribute)g_pRLX->pGX->View.Multisampling; pAttrib++;
	}

	if (SYS_CGLTRACE(CGLChoosePixelFormat( attribs, &pixelFormatObj, &numPixelFormats )))
		return -1;

    if (!numPixelFormats)
        return -2;

	DEBUG_PIXEL_FORMAT(pixelFormatObj);

    if (SYS_CGLTRACE(CGLCreateContext( pixelFormatObj, NULL, &g_pCGLC )))
       return -3;

    CGLDestroyPixelFormat( pixelFormatObj ) ;

    long swapInterval = !!(g_pRLX->pGX->View.Flags & GX_CAPS_VSYNC);
    SYS_CGLTRACE(CGLSetParameter( g_pCGLC, kCGLCPSwapInterval, &swapInterval));
    SYS_CGLTRACE(CGLSetCurrentContext( g_pCGLC ));
    if (SYS_CGLTRACE(CGLSetFullScreen( g_pCGLC )))
	{
		CGDisplaySwitchToMode(g_cgDisplayID, g_cgPrevDisplayMode);
		CGReleaseAllDisplays();

		return -5;
	}

	HideMenuBar();

    // Reset engine
    GL_InstallExtensions();
	GL_ResetViewport();

	g_pRLX->pGX->Surfaces.maxSurface = numberOfSparePages;;

	if (g_pRLX->pGX->View.Flags & GX_CAPS_MULTISAMPLING)
	{
		glEnable(GL_MULTISAMPLE_ARB);
	}

    return 0;
}
Esempio n. 7
0
static void ST_DrawStatus(void)
{
	int lump;
	float width;
	float height;
	float uv[4][2];
	const rcolor color = D_RGBA(0x68, 0x68, 0x68, 0x90);

	GL_SetState(GLSTATE_BLEND, 1);
	lump = GL_BindGfxTexture("STATUS", true);

	width = (float)gfxwidth[lump];
	height = (float)gfxheight[lump];

	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, DGL_CLAMP);
	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, DGL_CLAMP);

	if (st_drawhud.value >= 2)
		GL_SetOrthoScale(0.725f);

	GL_SetOrtho(0);

	dglSetVertex(st_vtx);
	st_vtxcount = 0;

	if (st_drawhud.value == 1) {
		// health

		uv[0][0] = uv[3][0] = 0.0f;
		uv[0][1] = uv[1][1] = 0.0f;
		uv[1][0] = uv[2][0] = 40.0f / width;
		uv[2][1] = uv[3][1] = 6.0f / height;

		ST_DrawStatusItem(st_healthVertex, uv, color);

		// armor

		uv[0][0] = uv[3][0] = 40.0f / width;
		uv[0][1] = uv[1][1] = 0.0f;
		uv[1][0] = uv[2][0] = uv[0][0] + (36.0f / width);
		uv[2][1] = uv[3][1] = 6.0f / height;

		ST_DrawStatusItem(st_armorVertex, uv, color);
	}
	// cards

	uv[0][0] = uv[3][0] = 0.0f;
	uv[0][1] = uv[1][1] = 6.0f / height;
	uv[1][0] = uv[2][0] = 9.0f / width;
	uv[2][1] = uv[3][1] = 1.0f;

	ST_DrawKey(it_bluecard, uv, st_key1Vertex);

	uv[0][0] = uv[3][0] = 9.0f / width;
	uv[1][0] = uv[2][0] = (9.0f / width) * 2;

	ST_DrawKey(it_yellowcard, uv, st_key2Vertex);

	uv[0][0] = uv[3][0] = (9.0f / width) * 2;
	uv[1][0] = uv[2][0] = (9.0f / width) * 3;

	ST_DrawKey(it_redcard, uv, st_key3Vertex);

	// skulls

	uv[0][0] = uv[3][0] = (9.0f / width) * 3;
	uv[1][0] = uv[2][0] = (9.0f / width) * 4;

	ST_DrawKey(it_blueskull, uv, st_key1Vertex);

	uv[0][0] = uv[3][0] = (9.0f / width) * 4;
	uv[1][0] = uv[2][0] = (9.0f / width) * 5;

	ST_DrawKey(it_yellowskull, uv, st_key2Vertex);

	uv[0][0] = uv[3][0] = (9.0f / width) * 5;
	uv[1][0] = uv[2][0] = (9.0f / width) * 6;

	ST_DrawKey(it_redskull, uv, st_key3Vertex);

	dglDrawGeometry(st_vtxcount, st_vtx);

	GL_ResetViewport();
	GL_SetState(GLSTATE_BLEND, 0);

	if (st_drawhud.value >= 2)
		GL_SetOrthoScale(1.0f);
}