Skip to content

Commit

Permalink
- merged removement of OpenGL related functions from utility library and
Browse files Browse the repository at this point in the history
  new animation parameter getter methods from develop branch
  • Loading branch information
horde3d committed Oct 9, 2013
1 parent 6a96ec5 commit 1485897
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Horde3D.cs" />
<Compile Include="Horde3D_Import.cs" />
<Compile Include="OpenGL.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Horde3D_Properties.cs" />
<Compile Include="Horde3DUtils.cs" />
Expand Down
21 changes: 19 additions & 2 deletions Horde3D/Bindings/C#/Source/Horde3D .NET/Horde3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ public enum H3DNodeParams
/// (may not be smaller than LodDist2) (default: infinite)
/// LodDist4F - Distance to camera from which on LOD4 is used
/// (may not be smaller than LodDist3) (default: infinite)
/// AnimCountI - Number of active animation stages [read-only]
/// </summary>
public enum H3DModel
{
Expand All @@ -431,7 +432,8 @@ public enum H3DModel
LodDist1F,
LodDist2F,
LodDist3F,
LodDist4F
LodDist4F,
AnimCountI
}

/// <summary>
Expand Down Expand Up @@ -1650,6 +1652,21 @@ public static void setupModelAnimStage(int node, int stage, int animationRes, in
NativeMethodsEngine.h3dSetupModelAnimStage(node, stage, animationRes, layer, startNode, additive);
}

/// <summary>
/// This function gets the current animation time and weight for a specified stage of the specified model.</summary>
/// <remarks>
/// The time corresponds to the frames of the animation and the animation is looped if the time is higher than the maximum number of frames in the Animation resource.
/// The weight is used for animation blending and determines how much influence the stage has compared to the other active stages.
/// </remarks>
/// <param name="node">handle to the node to be accessed</param>
/// <param name="stage">index of the animation stage to be accessed</param>
/// <param name="time">variable where the time of the animation stage will be stored</param>
/// <param name="weight">variable where the blend weight of the animation stage will be stored</param>
public static void getModelAnimParams(int node, int stage, out float time, out float weight)
{
NativeMethodsEngine.h3dGetModelAnimParams(node, stage, out time, out weight);
}

/// <summary>
/// This function sets the current animation time and weight for a specified stage of the specified model.</summary>
/// <remarks>
Expand Down Expand Up @@ -1863,4 +1880,4 @@ protected LibraryIncompatibleException(SerializationInfo info, StreamingContext
{
}
}
}
}
28 changes: 1 addition & 27 deletions Horde3D/Bindings/C#/Source/Horde3D .NET/Horde3DUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,6 @@ public static bool dumpMessages()
return NativeMethodsUtils.h3dutDumpMessages();
}

/// <summary>
/// This utility function initializes an OpenGL rendering context in a specified window component.
/// </summary>
/// <param name="hDC">handle to device context for which OpenGL context shall be created</param>
/// <returns>true in case of success, otherwise false</returns>
public static bool initOpenGL(int hDC)
{
return NativeMethodsUtils.h3dutInitOpenGL(hDC);
}

/// <summary>
/// This utility function destroys the previously created OpenGL rendering context.
/// </summary>
public static void releaseOpenGL()
{
NativeMethodsUtils.h3dutReleaseOpenGL();
}

/// <summary>
/// This utility function displays the image rendered to the previously initialized OpenGL context on the screen by copying the OpenGL backbuffer to the window front buffer.
/// </summary>
public static void swapBuffers()
{
NativeMethodsUtils.h3dutSwapBuffers();
}

/// <summary>
/// This function returns the search path of a specified resource type.
/// </summary>
Expand Down Expand Up @@ -266,4 +240,4 @@ public static void showFrameStats(int fontMaterialRes, int panelMaterialRes, int
NativeMethodsUtils.h3dutShowFrameStats(fontMaterialRes, panelMaterialRes, mode);
}
}
}
}
12 changes: 1 addition & 11 deletions Horde3D/Bindings/C#/Source/Horde3D .NET/Horde3DUtils_Import.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ internal static class NativeMethodsUtils
[return: MarshalAs(UnmanagedType.U1)] // represents C++ bool type
internal static extern bool h3dutDumpMessages();

[DllImport(UTILS_DLL), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.U1)] // represents C++ bool type
internal static extern bool h3dutInitOpenGL(int hDC);

[DllImport(UTILS_DLL), SuppressUnmanagedCodeSecurity]
internal static extern void h3dutReleaseOpenGL();

[DllImport(UTILS_DLL), SuppressUnmanagedCodeSecurity]
internal static extern void h3dutSwapBuffers();

// Utilities
[DllImport(UTILS_DLL), SuppressUnmanagedCodeSecurity]
internal static extern IntPtr h3dutGetResourcePath(h3d.H3DResTypes type);
Expand Down Expand Up @@ -84,4 +74,4 @@ internal static extern void h3dutShowText(string text, float x, float y, float s
internal static extern bool h3dutScreenshot(string filename);

}
}
}
3 changes: 3 additions & 0 deletions Horde3D/Bindings/C#/Source/Horde3D .NET/Horde3D_Import.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ internal static extern void h3dSetNodeTransform(int node, float px, float py, fl
internal static extern void h3dSetupModelAnimStage(int node, int stage, int animationRes,
int layer, string startNode, [MarshalAs(UnmanagedType.U1)]bool additive);

[DllImport(ENGINE_DLL), SuppressUnmanagedCodeSecurity]
internal static extern void h3dGetModelAnimParams(int node, int stage, out float time, out float weight);

[DllImport(ENGINE_DLL), SuppressUnmanagedCodeSecurity]
internal static extern void h3dSetModelAnimParams(int node, int stage, float time, float weight);

Expand Down
123 changes: 123 additions & 0 deletions Horde3D/Bindings/C#/Source/Horde3D .NET/OpenGL.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System;
using System.Runtime.InteropServices;

namespace Horde3DNET
{
public class OpenGL
{
[DllImport("user32.dll")]
public static extern IntPtr GetDC( IntPtr hWnd);

[DllImport("opengl32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern IntPtr wglCreateContext(IntPtr hDC);

[DllImport("opengl32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern bool wglMakeCurrent(IntPtr hDC, IntPtr hglrc);

[DllImport("opengl32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern bool wglDeleteContext(IntPtr hglrc);

[StructLayout(LayoutKind.Sequential)]
public struct PIXELFORMATDESCRIPTOR
{
public void Init()
{
nSize = (ushort)Marshal.SizeOf(typeof(PIXELFORMATDESCRIPTOR));
nVersion = 1;
dwFlags = PFD_FLAGS.PFD_DRAW_TO_WINDOW | PFD_FLAGS.PFD_SUPPORT_OPENGL | PFD_FLAGS.PFD_DOUBLEBUFFER;
iPixelType = PFD_PIXEL_TYPE.PFD_TYPE_RGBA;
cColorBits = 32;
cRedBits = cRedShift = cGreenBits = cGreenShift = cBlueBits = cBlueShift = 0;
cAlphaBits = 8;
cAlphaShift = 0;
cAccumBits = cAccumRedBits = cAccumGreenBits = cAccumBlueBits = cAccumAlphaBits = 0;
cDepthBits = 32;
cStencilBits = 8;
cAuxBuffers = 0;
iLayerType = PFD_LAYER_TYPES.PFD_MAIN_PLANE;
bReserved = 0;
dwLayerMask = dwVisibleMask = dwDamageMask = 0;
}
ushort nSize;
ushort nVersion;
PFD_FLAGS dwFlags;
PFD_PIXEL_TYPE iPixelType;
byte cColorBits;
byte cRedBits;
byte cRedShift;
byte cGreenBits;
byte cGreenShift;
byte cBlueBits;
byte cBlueShift;
byte cAlphaBits;
byte cAlphaShift;
byte cAccumBits;
byte cAccumRedBits;
byte cAccumGreenBits;
byte cAccumBlueBits;
byte cAccumAlphaBits;
byte cDepthBits;
byte cStencilBits;
byte cAuxBuffers;
PFD_LAYER_TYPES iLayerType;
byte bReserved;
uint dwLayerMask;
uint dwVisibleMask;
uint dwDamageMask;
}

[Flags]
public enum PFD_FLAGS : uint
{
PFD_DOUBLEBUFFER = 0x00000001,
PFD_STEREO = 0x00000002,
PFD_DRAW_TO_WINDOW = 0x00000004,
PFD_DRAW_TO_BITMAP = 0x00000008,
PFD_SUPPORT_GDI = 0x00000010,
PFD_SUPPORT_OPENGL = 0x00000020,
PFD_GENERIC_FORMAT = 0x00000040,
PFD_NEED_PALETTE = 0x00000080,
PFD_NEED_SYSTEM_PALETTE = 0x00000100,
PFD_SWAP_EXCHANGE = 0x00000200,
PFD_SWAP_COPY = 0x00000400,
PFD_SWAP_LAYER_BUFFERS = 0x00000800,
PFD_GENERIC_ACCELERATED = 0x00001000,
PFD_SUPPORT_DIRECTDRAW = 0x00002000,
PFD_DIRECT3D_ACCELERATED = 0x00004000,
PFD_SUPPORT_COMPOSITION = 0x00008000,
PFD_DEPTH_DONTCARE = 0x20000000,
PFD_DOUBLEBUFFER_DONTCARE = 0x40000000,
PFD_STEREO_DONTCARE = 0x80000000
}

public enum PFD_LAYER_TYPES : byte
{
PFD_MAIN_PLANE = 0,
PFD_OVERLAY_PLANE = 1,
PFD_UNDERLAY_PLANE = 255
}

public enum PFD_PIXEL_TYPE : byte
{
PFD_TYPE_RGBA = 0,
PFD_TYPE_COLORINDEX = 1
}

[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int ChoosePixelFormat(IntPtr hdc, [In] ref PIXELFORMATDESCRIPTOR ppfd);

[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern bool SetPixelFormat(IntPtr hdc, int iPixelFormat, ref PIXELFORMATDESCRIPTOR ppfd);

[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern bool SwapBuffers(IntPtr hdc);

public enum StringName : uint
{
GL_VENDOR = 0x1F00,
GL_RENDERER = 0x1F01,
GL_VERSION = 0x1F02,
GL_EXTENSIONS = 0x1F03
}
}
}
27 changes: 26 additions & 1 deletion Horde3D/Bindings/C++/Horde3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ struct H3DModel
(may not be smaller than LodDist2) (default: infinite)
LodDist4F - Distance to camera from which on LOD4 is used
(may not be smaller than LodDist3) (default: infinite)
AnimCountI - Number of active animation stages [read-only]
*/
enum List
{
Expand All @@ -503,7 +504,8 @@ struct H3DModel
LodDist1F,
LodDist2F,
LodDist3F,
LodDist4F
LodDist4F,
AnimCountI
};
};

Expand Down Expand Up @@ -1929,6 +1931,29 @@ DLL H3DNode h3dAddModelNode( H3DNode parent, const char *name, H3DRes geometryRe
DLL void h3dSetupModelAnimStage( H3DNode modelNode, int stage, H3DRes animationRes, int layer,
const char *startNode, bool additive );

/* Function: h3dGetModelAnimParams
Gets the animation stage parameters of a Model node.
Details:
This function gets the current animation time and weight for a specified stage of the
specified model. The time corresponds to the frames of the animation and the animation is
looped if the time is higher than the maximum number of frames in the Animation resource.
The weight is used for animation blending and determines how much influence the stage has compared
to the other active stages.
Parameters:
modelNode - handle to the Model node to be accessed
stage - index of the animation stage to be accessed
time - pointer to variable where the time of the animation stage will be stored
(can be NULL if not required)
weight - pointer to variable where the blend weight of the animation stage will be stored
(can be NULL if not required)
Returns:
nothing
*/
DLL void h3dGetModelAnimParams( H3DNode modelNode, int stage, float *time, float *weight );

/* Function: h3dSetModelAnimParams
Sets the animation stage parameters of a Model node.
Expand Down
52 changes: 0 additions & 52 deletions Horde3D/Bindings/C++/Horde3DUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,58 +77,6 @@ DLL void h3dutFreeMem( char **ptr );
*/
DLL bool h3dutDumpMessages();


/* Group: OpenGL-related functions */
/* Function: h3dutInitOpenGL
Initializes OpenGL.
Details:
This utility function initializes an OpenGL rendering context in a specified window component.
*Currently this function is only available on Windows platforms.*
Parameters:
hDC - handle to device context for which OpenGL context shall be created
Returns:
true in case of success, otherwise false
*/
DLL bool h3dutInitOpenGL( int hDC );

/* Function: h3dutReleaseOpenGL
Releases OpenGL.
Details:
This utility function destroys the previously created OpenGL rendering context.
*Currently this function is only available on Windows platforms.*
Parameters:
none
Returns:
nothing
*/
DLL void h3dutReleaseOpenGL();

/* Function: h3dutSwapBuffers
Displays the rendered image on the screen.
Details:
This utility function displays the image rendered to the previously initialized OpenGL context
on the screen by copying it from the backbuffer to the frontbuffer.
*Currently this function is only available on Windows platforms.*
Parameters:
none
Returns:
nothing
*/
DLL void h3dutSwapBuffers();


/* Group: Resource management */
/* Function: h3dutGetResourcePath
*Deprecated*
Expand Down
Loading

0 comments on commit 1485897

Please sign in to comment.