Replacing SGIS in GLQuake

Post tutorials on how to do certain tasks within game or engine code here.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Replacing SGIS in GLQuake

Post by Baker »

Not a very interesting tutorial, but I'm doing this for MH's Direct3D 8.1 wrapper and I want to remember precisely what needed to be done. This is replacing a very old multitexturing API extension with the ARB extension (but retaining backwards compatibility with aguirRe's way).

Using aguirRe's Enhanced GLQuake as the role model here ...

Files to examine: gl_draw.c gl_rsurf.c gl_vidnt.c glquake.h

gldraw.c

GL_LoadPicTexture:

static GLenum oldtarget = TEXTURE0_SGIS; --> GLenum gl_oldtarget;

Rename oldtarget occurances to gl_oldtarget

gl_vidnt.c

Steal aguirRe's CheckMultitextureExtensions outright, replacing the existing function.

Code: Select all

#ifdef _WIN32
void CheckMultiTextureExtensions(void)
{
	qboolean SGIS, ARB;

	if (COM_CheckParm("-nomtex"))
	{
		Con_Printf ("WARNING: Multitexture disabled at command line\n");
		return;
	}

	if (COM_CheckParm("-nomtexarb"))
		ARB = false;
	else
		ARB = strstr (gl_extensions, "GL_ARB_multitexture ") != NULL;

	SGIS = strstr (gl_extensions, "GL_SGIS_multitexture ") != NULL;

	if (ARB || SGIS)
	{
		Con_Printf ("GL_%s_multitexture extensions found\n", ARB ? "ARB" : "SGIS");
		qglMTexCoord2fSGIS = (void *) wglGetProcAddress (ARB ? "glMultiTexCoord2fARB" : "glMTexCoord2fSGIS");
		qglSelectTextureSGIS = (void *) wglGetProcAddress (ARB ? "glActiveTextureARB" : "glSelectTextureSGIS");
		TEXTURE0_SGIS = ARB ? 0x84C0 : 0x835E;
		TEXTURE1_SGIS = ARB ? 0x84C1 : 0x835F;
		gl_oldtarget = TEXTURE0_SGIS;
		gl_mtexable = true;
	}
	else
		Con_Printf ("WARNING: Multitexture not supported\n");
}
#else
void CheckMultiTextureExtensions(void)
{
		gl_mtexable = true;
}
#endif
glquake.h

Find

Code: Select all

// Multitexture
#define    TEXTURE0_SGIS				0x835E
#define    TEXTURE1_SGIS				0x835F
Replace with

Code: Select all

// Multitexture
extern GLenum gl_oldtarget;
extern GLenum gl_Texture0;
extern GLenum gl_Texture1;
#define    TEXTURE0_SGIS gl_Texture0
#define    TEXTURE1_SGIS gl_Texture1
Team Xlink
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Post by Team Xlink »

It seems sweet and simple.

But what exactly is SGSI?
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

Team Xlink wrote:It seems sweet and simple.

But what exactly is SGSI?
The short fuzzy poorly explained version goes like this. SG = Silicon Graphics. In the 1990s an OpenGL extension was formalized under ARB ( http://www.opengl.org/about/arb/ ) and engines should be checking for that extension for multitexture instead of the old SGSI extension. So the above applies to OpenGL using engines (i.e. not the PSP, for example, and not DirectQ which uses Direct3D instead OpenGL or software renderers obviously).
MeTcHsteekle
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Post by MeTcHsteekle »

uuuuh huh huh Silicon Graaphics uuuu huh huh huh

{pnsfw}
bah
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

For reasons I can't quite understand, this implementation causes my Half-Life format textures to be all white.

The I tried r_lightmaps 1 and nothing!

So I loaded up aguirRe's Enhanced GLQuake engine only to discover his r_lightmaps 1 doesn't work either.

Kind of unexpected ... something "fun" to work through.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

What the wise person does is just remove SGIS altogether. OK, I can understand and appreciate the more cautious approach for sure, but in this case we're talking about an extension that's long since been superseded on everything aside from Voodoo 2 cards (I believe it may have even been superseded on Voodoo 2 - if anyone could pull an extensions list from a Voodoo 2 it would be great).

SGIS is crap, fundamentally. You can't use it with vertex arrays, you can't use it with combine modes, and who knows whether or not it's going to play nice if you try to use it with anything else.

It's not as if GL_ARB_multitexture is in any way new and therefore worthy of suspicion either. SGIS was deprecated back in the last century. Drop it already.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

quake is the only thing that even uses the extension, that I'm aware of.
Just use a q2/q3 minidriver instead if your voodoo driver doesn't support arb.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Post by leileilol »

mh wrote:if anyone could pull an extensions list from a Voodoo 2 it would be great
GL_VENDOR: 3Dfx Interactive Inc.
GL_RENDERER: 3Dfx/Voodoo2/2 TMUs/4 MB/stand-alone (Jan 7 2000)
GL_VERSION: 1.1.0

GL_EXTENSIONS:
GL_ARB_multitexture GL_EXT_abgr GL_EXT_bgra GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_EXT_packed_pixels GL_EXT_paletted_texture GL_EXT_point_parameters GL_EXT_shared_texture_palette GL_EXT_stencil_wrap GL_EXT_texture_env_add GL_EXT_vertex_array GL_SGIS_texture_edge_clamp GL_SGIS_multitexture WGL_3DFX_gamma_control WGL_EXT_swap_control
i should not be here
Post Reply