Problems with adding 'r_shadows' Created 8 years ago2016-01-10 05:40:08 UTC by James Luke James Luke

Created 8 years ago2016-01-10 05:40:08 UTC by James Luke James Luke

Posted 8 years ago2016-01-10 05:45:11 UTC Post #328170
So I was looking through some of the Spirit of Half-Life 1.9 shadow code and I thought it was really cool. But even when when I compiled it correctly, it doesn't work. So I tried to fix it on the 2.3 SDK, but I keep on getting a strange error...
User posted image
From...
User posted image
= Off Topic =
LOL! Didn't realize I put tears...
= On Topic =

All the code I have changed/added:

(hud.cpp)
CVAR_CREATE("r_shadows", "0", FCVAR_ARCHIVE );
(StudioModelRenderer.cpp)
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
(StudioModelRenderer.cpp)
[quote]
void (*GL_StudioDrawShadow)(void);

__declspec(naked) void DrawShadows(void)
{
glDepthMask( 1 );
_asm 
{
	push ecx;
	jmp [GL_StudioDrawShadow];
}
}
[/quote]

I'm quite a scrub when it comes to coding... Also, this is for a mod I'm working on. Any help would be great, thanks.
Posted 8 years ago2016-01-10 06:10:08 UTC Post #328171
Usually a linker error like that means that your project references aren't set up properly. I don't think including a reference to gl.h is enough, you need to add the dynamic library and make sure the linker is referencing it. I don't know the details of doing it but Google the error you get and you'll find plenty of instructions.

Note that using any OpenGL operation will prevent your mod players from using the software or DirectX renderers. Also the changes you made look quite Windows-specific, so you won't be able to build OSX or Linux versions of your mod with that code. Additionally if you're not incredibly familiar with programming, you're going to have a very difficult time implementing anything complicated using OpenGL. Finally I've never heard of SOHL having a version 1.9, so what you're using is probably someone's unofficial fork and will probably be unstable and experimental. Well, more unstable than SOHL is already.
Penguinboy PenguinboyHaha, I died again!
Posted 8 years ago2016-01-10 21:30:48 UTC Post #328172
It's not unstable. It's just a custom build. Some things added, some things removed, some things works better, than in any other SoHL versions after v1.2 (which is the last official version, btw). Can't say what is exactly wrong with r_shadows, but I know that this feature works via specific hack and possibly in v1.9 it has been disabled by a reason (Unkle Mike is the author of this build, and I know that he didn't like those shadows, because they're too primitive).

P. S. For those who didn't know that, there are few custom builds of SoHL by Unkle Mike - v1.3, v1.6, v1.7 & v1.9 (last).
Posted 8 years ago2016-01-11 00:17:40 UTC Post #328177
Interesting, I didn't know that.

As for being stable or not, in my opinion SOHL has a habit of getting more unstable as the version number goes up. People have just hacked on top of Valve's god-awful code without spending time taking care of code quality or maintainability. The SDK is a big mess, and SOHL is just an even bigger mess. I wish somebody would spend some time fixing the SDK and building a nice clean implementation of SOHL on top of it.

This is based on my experience with SOHL 1.8 so hopefully 1.9 is better. 1.8 has some stupid stuff such as the AI sparks in debug mode, crashing on shutdown, and breaking a bunch of scripted sequence and weapon animations.
Penguinboy PenguinboyHaha, I died again!
Posted 8 years ago2016-01-11 02:26:56 UTC Post #328184
Right click on the client project, Properties, go into the Linker section and Input sub-section and add "opengl32.lib" to the additional dependencies. Clean the solution and build again.
Posted 8 years ago2016-01-11 19:04:23 UTC Post #328193
Right click on the client project, Properties, go into the Linker section and Input sub-section and add "opengl32.lib" to the additional dependencies. Clean the solution and build again.
That at least made me compile the solution, thanks. But testing it inside of the game, it freezes up and crashes.

Perhaps I'm missing something, or there is a more efficient way of doing this.
snip snip
Note that using any OpenGL operation will prevent your mod players from using the software or DirectX renderers. Also the changes you made look quite Windows-specific, so you won't be able to build OSX or Linux versions of your mod with that code. Additionally if you're not incredibly familiar with programming, you're going to have a very difficult time implementing anything complicated using OpenGL.
snip snip
I understand that doing that and getting it to work will make it only Windows, but most people use Windows anyway. Also, about the OpenGL, I'm sure just about everyone with a modern-ish computer uses OpenGL to run Half-Life.
Posted 8 years ago2016-01-11 23:07:52 UTC Post #328194
Can you run the mod through Visual Studio's debugger and tell me on which line it crashes?
Posted 8 years ago2016-01-12 00:54:52 UTC Post #328196
Can you run the mod through Visual Studio's debugger and tell me on which line it crashes?
I haven't set up debugging in my mod, but when I did and ran it with the 'r_shadows' code. I looked through the debug log and this is all I can really find.
snip snip

The thread 'Win32 Thread' (0x26b4) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x284) has exited with code 0 (0x0).
GL_SIZES: r:8 g:8 b:8 a:0 depth:24

snip snip

First-chance exception at 0x028a6a10 in hl.exe: 0xC0000005: Access violation writing location 0x00000000.

snip snip
There's a lot more to the log; here's the full: http://pastebin.com/mBFYxskY

I just think adding back the stencil shadows isn't a good idea maybe, but I don't know of any easy-intermediate way of adding shadows. Just to make it look that 'much' prettier.

But anyways, thanks again.
Posted 8 years ago2016-01-13 23:19:58 UTC Post #328221
Just by curiosity, have you tried to replace the call "DrawShadows()" by it's content (glDepthMask( 1 ) with the assembly code) ?
Posted 8 years ago2016-01-14 02:53:11 UTC Post #328229
Alas, no. I'm not familiar with Assembly or any of the code to call it. I think the notes referred to something about bypassing the locked CVar to run the code.
Posted 8 years ago2016-01-14 18:10:46 UTC Post #328254
What I meant is comment the whole "DrawShadows" procedure, it should look like this (notice the * and *):

/*__declspec(naked) void DrawShadows(void)
{
// Here is DrawShadows's code, I removed it here to avoid flood/whatever
}*/

And according to the SoHL 1.9 source code I've found, you should have this code :

if (CVAR_GET_FLOAT("r_shadows") == 1 && gEngfuncs.GetViewModel() != m_pCurrentEntity)
{
DrawShadows();
}

Replace "DrawShadows();" by the original code (which is the glDepthMask(1); and assembly code).
Posted 8 years ago2016-01-18 05:17:11 UTC Post #328340
And according to the SoHL 1.9 source code I've found, you should have this code :

if (CVAR_GET_FLOAT("r_shadows") == 1 && gEngfuncs.GetViewModel() != m_pCurrentEntity)
{
DrawShadows();
}

Replace "DrawShadows();" by the original code (which is the glDepthMask(1); and assembly code).
So the glDepthMask(1) and the _asm and all that in the if r_shadows == 1? I tried that and it doesn't work.

[quote]
snip
		GL_StudioDrawShadow = (void(*)(void))(((unsigned int)IEngineStudio.GL_StudioDrawShadow) + 32);
		if (CVAR_GET_FLOAT("r_shadow") == 1 && gEngfuncs.GetViewModel() != m_pCurrentEntity)
		{
			glDepthMask( 1 );
			_asm 
			{
				push ecx;
				jmp [GL_StudioDrawShadow];
			}
		}
snip
[/quote]

Anyways, thanks once again for putting up with my tiny coding knowledge.
You must be logged in to post a response.