ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


engine_info

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
engine_info [2019/04/22 05:57] – [IsOpenGL] korshunengine_info [2019/08/26 04:13] (current) – removed korshun
Line 1: Line 1:
-====== Source port and renderer identification ====== 
- 
-ACSUtils provides functions to identify the exact source port (ZDoom, GZDoom, Zandronum) and renderer (software, OpenGL). 
- 
-===== Identifying source port ===== 
- 
-==== Detection method ==== 
- 
-The detection module first checks for presence of [[zan>GetPlayerAccountName]], which is a Zandronum-exclusive function. It returns a string (usually an empty string) if it exists, while unimplemented ACS functions return 0. If the function is present, the port is assumed to be Zandronum. 
- 
-If the port is not Zandronum, the detection module attempts to spawn an actor of type [[zdoom>Classes:DynamicLight|DynamicLight]], which is present in GZDoom, but not in ZDoom. If the actor spawns successfully, the port is assumed to be GZDoom. 
- 
-If both these checks fail, the port is assumed to be ZDoom. 
- 
-==== Caching ==== 
- 
-The above checks are not rerun every time the source port is queried. After identification, the type of the source port is saved into a map variable. Subsequent queries simply return the value of that variable. 
- 
-==== IdentifySourcePort ==== 
-''int IdentifySourcePort()'' 
- 
-Identifies the engine that the mod is running in and returns one of the following constants: 
-  * ''PORT_ZDOOM'' -- ZDoom 
-  * ''PORT_GZDOOM'' -- GZDoom 
-  * ''PORT_ZANDRONUM'' -- Zandronum 
- 
-==== IsGZDoom ==== 
-''bool IsGZDoom()'' 
- 
-Returns true if the port is GZDoom or a derivative. 
- 
-<note important>This function returns true for Zandronum, since Zandronum is a derivative of GZDoom and includes its OpenGL renderer.</note> 
-<note tip>If you want to check for OpenGL renderer, don't use this function. Use ''IsOpenGL''.</note> 
- 
-==== IsZandronum ==== 
-''bool IsZandronum()'' 
- 
-Returns true if the port is Zandronum or a derivative. 
- 
-==== GetPortName ==== 
-''str GetPortName()'' 
- 
-Returns the name of the source port as a string, one of ''"ZDoom"'', ''"GZDoom"'', ''"Zandronum"''. 
- 
-=== Example usage === 
- 
-<code> 
-print(s:"This mod is running on ", s:GetPortName()); 
-</code> 
- 
- 
-===== Identifying renderer ===== 
- 
-==== IsOpenGL ==== 
-''bool IsOpenGL()'' 
- 
-Returns true if the engine is currently running in an OpenGL renderer. 
- 
-<note important>Calling this function serverside is an error, because the server has no renderer at all. Nonetheless, this function will return true in that case, because the OpenGL renderer generally has less restrictions.</note> 
- 
-==== Detection method ==== 
- 
-This function first calls ''IsGZDoom'' to check if the port is GZDoom or a derivative like Zandronum. If the port is not a GZDoom derivative, it can't have the OpenGL renderer, and this function returns false. This is to prevent detecting the OpenGL renderer when ZDoom is run with a config from GZDoom which has ''vid_renderer=1''. 
- 
-If the port is confirmed to be a GZDoom derivative, this function checks for two CVars: ''vid_renderer'' and ''gl_nogl''. This function only returns true if ''vid_renderer'' is true and ''gl_nogl'' is false. 
- 
-The result is not cached in any way, because the renderer can be changed mid-game. 
- 
-<note important>Do not save the result in a variable yourself. Always call ''IsOpenGL'' to check for the renderer, because it can be changed mid-game.</note> 
- 
-