Automatic OGL activate in EXE mod.

Status
Not open for further replies.

Sky Ninja

Member
I'm working on a small mod to add files to give proper animation & color changes to models by use of new extrernal files. I saw OGL automatically active in TML, but I can't figure it out. I had some theories, but they failed. Also, I'm not using the SVN, because I can't seem to download a subversion client.
 
Oh, I was just enabling that the other day, in i_video.c or win_vid.c, there's a bit of code where it switches to software by default in I_StarupGraphics :

(This is from the SDL code)

Original:

#ifdef HWRENDER
if (M_CheckParm("-opengl") || rendermode == render_opengl)
{
rendermode = render_opengl;
HWD.pfnInit = hwSym("Init",NULL);
HWD.pfnFinishUpdate = hwSym("FinishUpdate",NULL);
HWD.pfnDraw2DLine = hwSym("Draw2DLine",NULL);
HWD.pfnDrawPolygon = hwSym("DrawPolygon",NULL);
HWD.pfnSetBlend = hwSym("SetBlend",NULL);
HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL);
HWD.pfnSetTexture = hwSym("SetTexture",NULL);
HWD.pfnReadRect = hwSym("ReadRect",NULL);
HWD.pfnGClipRect = hwSym("GClipRect",NULL);
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL);
HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL);
HWD.pfnSetPalette = hwSym("SetPalette",NULL);
HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL);
HWD.pfnDrawMD2 = hwSym("DrawMD2",NULL);
HWD.pfnSetTransform = hwSym("SetTransform",NULL);
HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL);
// check gl renderer lib
if (HWD.pfnGetRenderVersion() != VERSION)
I_Error ("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n");
#ifdef _WIN32_WCE
vid.width = 320;
vid.height = 240;
#else
vid.width = 640; // hack to make voodoo cards work in 640x480
vid.height = 480;
#endif
/*
* We want at least 1 bit R, G, and B,
* and at least 16 bpp. Why 1 bit? May be more?
*/
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
if (!OglSdlSurface(vid.width, vid.height, (USE_FULLSCREEN)))
if (!OglSdlSurface(vid.width, vid.height, !(USE_FULLSCREEN)))
rendermode = render_soft;
}
#else
rendermode = render_soft; //force software mode when there no HWRENDER code
#endif

Method I used:

#ifdef HWRENDER
rendermode = render_opengl;
HWD.pfnInit = hwSym("Init",NULL);
HWD.pfnFinishUpdate = hwSym("FinishUpdate",NULL);
HWD.pfnDraw2DLine = hwSym("Draw2DLine",NULL);
HWD.pfnDrawPolygon = hwSym("DrawPolygon",NULL);
HWD.pfnSetBlend = hwSym("SetBlend",NULL);
HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL);
HWD.pfnSetTexture = hwSym("SetTexture",NULL);
HWD.pfnReadRect = hwSym("ReadRect",NULL);
HWD.pfnGClipRect = hwSym("GClipRect",NULL);
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL);
HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL);
HWD.pfnSetPalette = hwSym("SetPalette",NULL);
HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL);
HWD.pfnDrawMD2 = hwSym("DrawMD2",NULL);
HWD.pfnSetTransform = hwSym("SetTransform",NULL);
HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL);
// check gl renderer lib
if (HWD.pfnGetRenderVersion() != VERSION)
I_Error ("The version of the renderer doesn't match the version of the executable\n");
#ifdef _WIN32_WCE
vid.width = 320;
vid.height = 240;
#else
vid.width = 640; // make voodoo cards work in 640x480
vid.height = 480;
#endif
/*
* We want at least 1 bit R, G, and B,
* and at least 16 bpp. Why 1 bit? May be more?
*/
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
if (!OglSdlSurface(vid.width, vid.height, (USE_FULLSCREEN)))
if (!OglSdlSurface(vid.width, vid.height, !(USE_FULLSCREEN)))
rendermode = render_opengl;
#else
rendermode = render_opengl; // OpenGL by default
#endif


There's different code in the windows version, just search for in the code for "-opengl" and you should find what you're looking for
 
Thank you. I have been looking in the wrong places all this time.
EDIT: It looks like this in Win:
Code:
#ifdef HWRENDER
	if (M_CheckParm("-3dfx") || M_CheckParm("-glide"))
		rendermode = render_glide;
	else if (M_CheckParm("-opengl") || M_CheckParm("-minigl"))
		rendermode = render_opengl; // MiniGL is considered like OpenGL in the main code
	else if (M_CheckParm("-d3d"))
		rendermode = render_d3d;
	else
		rendermode = render_soft;
And I changed it to this:
Code:
#ifdef HWRENDER
	if (M_CheckParm("-3dfx") || M_CheckParm("-glide"))
		rendermode = render_glide;
	else if (M_CheckParm("-software"))
		rendermode = render_soft; // This allows for a software force
	else if (M_CheckParm("-d3d"))
		rendermode = render_d3d;
	else
		rendermode = render_opengl;
So now you can type -software in the command line to go software, (but in my little mod, it'll look stupid.)
 
What? Do you mean that you can't go software from that with the net launcher? Well, that is true, with check boxes, but the net launcher has a command line in main options.
 
Sky Ninja said:
What? Do you mean that you can't go software from that with the net launcher? Well, that is true, with check boxes, but the net launcher has a command line in main options.
So for software mode on your mod I'm guessing your gonna have to create a batch file with -software for software mode then =/
 
Silent_Snipe said:
Sky Ninja said:
What? Do you mean that you can't go software from that with the net launcher? Well, that is true, with check boxes, but the net launcher has a command line in main options.
So for software mode on your mod I'm guessing your gonna have to create a batch file with -software for software mode then =/
That's an option. It can still easily be done through the launcher, and the old launcher's code it supplied, so I could try and make one to work with this. (Note, I said try. I have extremely limited experience with this stuff.)
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top