/// <summary> /// Helper function to handle the inconvenient fact that the packing for RenderModel_TextureMap_t is /// different on Linux/OSX (4) than it is on Windows (8) /// </summary> /// <param name="pRenderModel">native pointer to the RenderModel_TextureMap_t</param> /// <returns></returns> private RenderModel_TextureMap_t MarshalRenderModel_TextureMap(System.IntPtr pRenderModel) { if ((System.Environment.OSVersion.Platform == System.PlatformID.MacOSX) || (System.Environment.OSVersion.Platform == System.PlatformID.Unix)) { var packedModel = (RenderModel_TextureMap_t_Packed)Marshal.PtrToStructure(pRenderModel, typeof(RenderModel_TextureMap_t_Packed)); RenderModel_TextureMap_t model = new RenderModel_TextureMap_t(); packedModel.Unpack(ref model); return(model); } else { return((RenderModel_TextureMap_t)Marshal.PtrToStructure(pRenderModel, typeof(RenderModel_TextureMap_t))); } }
public abstract void FreeTexture(ref RenderModel_TextureMap_t pTexture);
public override void FreeTexture(ref RenderModel_TextureMap_t pTexture) { CheckIfUsable(); VRNativeEntrypoints.VR_IVRRenderModels_FreeTexture(m_pVRRenderModels,ref pTexture); }
internal static extern void VR_IVRRenderModels_FreeTexture(IntPtr instancePtr, ref RenderModel_TextureMap_t pTexture);
} // 0x00000001801DA030-0x00000001801DA0D0 // Methods public void Unpack(ref RenderModel_TextureMap_t unpacked) { } // 0x00000001801DA010-0x00000001801DA030
public IntPtr rubTextureMapData; // 0x08 // Constructors public RenderModel_TextureMap_t_Packed(RenderModel_TextureMap_t unpacked) { unWidth = default; unHeight = default; rubTextureMapData = default; } // 0x00000001801DA030-0x00000001801DA0D0
// Token: 0x0600200C RID: 8204 RVA: 0x0009E67F File Offset: 0x0009C87F public void Unpack(ref RenderModel_TextureMap_t unpacked) { unpacked.unWidth = this.unWidth; unpacked.unHeight = this.unHeight; unpacked.rubTextureMapData = this.rubTextureMapData; }
// Token: 0x0600200B RID: 8203 RVA: 0x0009E659 File Offset: 0x0009C859 public RenderModel_TextureMap_t_Packed(RenderModel_TextureMap_t unpacked) { this.unWidth = unpacked.unWidth; this.unHeight = unpacked.unHeight; this.rubTextureMapData = unpacked.rubTextureMapData; }
public static GLRenderModel Create(string name, RenderModel_t renderModel, RenderModel_TextureMap_t diffuseTexture) { // create and bind a VAO to hold the state for this model int vao = OpenGLUtil.CreateVertexArrayObject(); GL.BindVertexArray(vao); // populate the vertex buffer int vbo = OpenGLUtil.CreateBufferObject(); GL.BindBuffer(BufferTarget.ArrayBuffer, vbo); GL.BufferData(BufferTarget.ArrayBuffer, Marshal.SizeOf<RenderModel_Vertex_t>() * (int)renderModel.unVertexCount, renderModel.rVertexData, BufferUsageHint.StaticDraw); // identity the components in teh vertex buffer GL.EnableVertexAttribArray(0); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, Marshal.SizeOf<RenderModel_Vertex_t>(), Marshal.OffsetOf<RenderModel_Vertex_t>("vPosition")); // this might have to be size of 4? GL.EnableVertexAttribArray(1); GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, Marshal.SizeOf<RenderModel_Vertex_t>(), Marshal.OffsetOf<RenderModel_Vertex_t>("vNormal")); GL.EnableVertexAttribArray(2); GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, Marshal.SizeOf<RenderModel_Vertex_t>(), Marshal.OffsetOf<RenderModel_Vertex_t>("rfTextureCoord0")); // create and populate the index buffer int indexBuffer = OpenGLUtil.CreateBufferObject(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBuffer); GL.BufferData(BufferTarget.ElementArrayBuffer, Marshal.SizeOf<ushort>() * (int)renderModel.unTriangleCount * 3, renderModel.rIndexData, BufferUsageHint.StaticDraw); GL.BindVertexArray(0); // create and populate the texture int texture = OpenGLUtil.CreateTexture(); GL.BindTexture(TextureTarget.Texture2D, texture); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, diffuseTexture.unWidth, diffuseTexture.unHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte, diffuseTexture.rubTextureMapData); GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, new[] { (int)TextureParameterName.ClampToEdge }); GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, new[] { (int)TextureParameterName.ClampToEdge }); GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, new[] { (int)TextureMagFilter.Linear }); GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, new[] { (int)TextureMinFilter.LinearMipmapLinear }); // *****missing stuff about anisotropy ***** // not sure if this is right float largest = GL.GetFloat((GetPName)0x84FF); GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)0x84FE, largest); GL.BindTexture(TextureTarget.Texture2D, 0); return new GLRenderModel(vbo, indexBuffer, vao, texture, (int)renderModel.unTriangleCount * 3, name); }