You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.3 KiB
80 lines
2.3 KiB
using System;
|
|
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>
|
|
/// Managed equivalent of gltexture_t
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0, CharSet = CharSet.Ansi)]
|
|
public class QGLTexture
|
|
{
|
|
public uint texNum;
|
|
public IntPtr next;
|
|
public IntPtr owner;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string name;
|
|
public uint width;
|
|
public uint height;
|
|
public QTexPrefs flags;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = QConstants.MaxQPath)] public string sourceFile;
|
|
public UIntPtr sourceOffset;
|
|
public QTexSourceFormat sourceFormat;
|
|
public uint sourceWidth;
|
|
public uint sourceHeight;
|
|
public ushort sourceCrc;
|
|
public char shirt;
|
|
public char pants;
|
|
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 ? (uint)Marshal.ReadInt32(ptr) : 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of srcformat
|
|
/// </summary>
|
|
public enum QTexSourceFormat
|
|
{
|
|
Indexed,
|
|
Lightmap,
|
|
Rgba,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of TEXPRF_ defines
|
|
/// </summary>
|
|
[Flags]
|
|
public enum QTexPrefs: uint
|
|
{
|
|
None = 0x0000,
|
|
Mipmap = 0x0001,
|
|
Linear = 0x0002,
|
|
Nearest = 0x0004,
|
|
Alpha = 0x0008,
|
|
Pad = 0x0010,
|
|
Persist = 0x0020,
|
|
Overwrite = 0x0040,
|
|
NoPicMip = 0x0080,
|
|
FullBright = 0x0100,
|
|
NoBright = 0x0200,
|
|
ConChars = 0x0400,
|
|
WarpImage = 0x0800,
|
|
}
|