Page 1 of 1

Replacing SGIS in GLQuake

Posted: Wed Dec 02, 2009 10:42 am
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

Posted: Tue Dec 08, 2009 1:56 am
by Team Xlink
It seems sweet and simple.

But what exactly is SGSI?

Posted: Tue Dec 08, 2009 2:37 am
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).

Posted: Wed Dec 09, 2009 3:59 am
by MeTcHsteekle
uuuuh huh huh Silicon Graaphics uuuu huh huh huh

{pnsfw}

Posted: Tue Jun 22, 2010 12:23 pm
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.

Posted: Tue Jun 22, 2010 4:05 pm
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.

Posted: Tue Jun 22, 2010 4:26 pm
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.

Posted: Tue Jun 22, 2010 9:09 pm
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