This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Application with OpenGL via OpenTK Library

Warning
The functionality described in this article is not available in the Community SDK edition.
You should upgrade to Engineering / Sim SDK edition to use it.

This article describes the sample located in the <UnigineSDK>/source/csharp/apps/main_winform/GLOpenTKAppForm/ folder.

The sample demonstrates how to embed Unigine into a Windows Forms application:

  • Create a Windows Forms application and embed Unigine into it.
  • Initialize OpenGL by using OpenTK library.
Notice
The sample can be run on Windows only.

Running Sample#

To run the sample, you should do the following:

  1. Prepare the development environment:
    Notice
    Microsoft .NET 6 or higher is required.
    Notice
    OpenTK library will be installed automatically when you install UNIGINE SDK.
  2. Open the Visual C# main_x64.csproj project file located in the <UnigineSDK>/source/csharp/apps/main_winform/GLOpenTKAppForm/ folder.
  3. Click the button on the toolbar (or DEBUG -> Start Debugging) to start the project.

    Windows Form Application will open.

Description of C# classes#

This sample contains 4 classes:

  • AppForm — inherits the Unigine.App class. In this class thedoUpdate(), doRender() anddoSwap() functions are overridden and call the update(), render() andswap() functions respectively.
  • AppFormControl — inherits the System.Windows.Forms.Form class. This class implements all the necessary events, which will be performed when user interacts with the application.
  • GLTKAppForm — inherits the AppForm class and initializes the graphics OpenGL API in the Windows Forms Application via the OpenTK library.
  • UnigineApp — defines the entry point of the program. C# Wrapper and Engine are initialized here.
Notice
AppForm, AppFormControl, GLTKAppForm are defined in the Unigine namespace.

See Also#

Last update: 2022-10-10
Build: ()