|
|
@ -1,6 +1,25 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Runtime.InteropServices; |
|
|
using System.Runtime.InteropServices; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Managed equivalent of texture_t
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0, CharSet = CharSet.Ansi)] |
|
|
|
|
|
public struct QTexture |
|
|
|
|
|
{ |
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string name; |
|
|
|
|
|
public uint width, height; |
|
|
|
|
|
public IntPtr glTexture; // Pointer to gltexture_t
|
|
|
|
|
|
public IntPtr fullBright; // Pointer to gltexture_t
|
|
|
|
|
|
public IntPtr warpImage; // Pointer to gltexture_t
|
|
|
|
|
|
|
|
|
|
|
|
public uint TextureNum => QGLTexture.TexNumFromPtr(glTexture); |
|
|
|
|
|
public uint FullBrightNum => QGLTexture.TexNumFromPtr(fullBright); |
|
|
|
|
|
public uint WarpImageNum => QGLTexture.TexNumFromPtr(warpImage); |
|
|
|
|
|
|
|
|
|
|
|
// Rest of the fields are left out, so we don't unnecessarily marshal any unused data
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Managed equivalent of gltexture_t
|
|
|
/// Managed equivalent of gltexture_t
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
@ -23,6 +42,10 @@ public class QGLTexture |
|
|
public char shirt; |
|
|
public char shirt; |
|
|
public char pants; |
|
|
public char pants; |
|
|
public int visFrame; |
|
|
public int visFrame; |
|
|
|
|
|
|
|
|
|
|
|
// Conveniently make use of the fact that texNum is the first field in QGLTexture,
|
|
|
|
|
|
// so we don't have to marshal the entire struct to get the texture number out of it.
|
|
|
|
|
|
public static uint TexNumFromPtr(IntPtr ptr) => ptr == IntPtr.Zero ? 0 : unchecked((uint)Marshal.ReadInt32(ptr)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
|