Code Monkey home page Code Monkey logo

opentk / opentk Goto Github PK

View Code? Open in Web Editor NEW
3.1K 149.0 625.0 131.91 MB

The Open Toolkit library is a fast, low-level C# wrapper for OpenGL, OpenAL & OpenCL. It also includes windowing, mouse, keyboard and joystick input and a robust and fast math library, giving you everything you need to write your own renderer or game engine. OpenTK can be used standalone or inside a GUI on Windows, Linux, Mac.

Home Page: https://opentk.net

License: Other

C# 91.31% F# 4.59% Batchfile 0.01% PowerShell 0.10% Tcl 0.48% Ruby 1.44% Python 2.07%
c-sharp opengl opengl-es graphics-library game-development math-library scientific-visualization openal opencl graphics

opentk's Introduction

OpenTK

OpenTK is a large project. There are many components to work on, and we'd welcome almost any contribution. The community is friendly, welcoming and always ready to help you get your PRs merged!

We have a very active discord server, if you need help, want to help, or are just curious, come join us!

Discord

The Open Toolkit library is a fast, low-level C# binding for OpenGL, OpenGL ES, OpenAL, and OpenCL. It runs on all major platforms and powers hundreds of apps, games and scientific research.

Use OpenTK to add cross-platform 3d graphics, audio, compute and haptics to your C# application. Integrate it into your existing user interface or use it standalone without any external dependencies.

OpenTK comes with simple and easy to follow tutorials for learning modern OpenGL. These are written by the community and represent all of the best practices to get you started.

Learn how to use OpenTK here: https://github.com/opentk/LearnOpenTK

Older OpenTK 3 tutorials here: https://opentk.net/learn/index.html

Project website: https://opentk.net

Official git repository: https://github.com/opentk/opentk

Build Status

Platform Status
Windows Build status
Mono/Linux Build status

Features

  • Create cutting-edge graphics with OpenGL 4.6 and OpenGL ES 3.0
  • Spice up your GUI with 3d acceleration
  • Improve your code flow with strong types and inline documentation
  • Windowing systems to help get you started
  • Input, and other game essentials.
  • Performant, highly optimized and reliable linear algebra library
  • Write once run everywhere

OpenTK is available for Windows, Linux, Mac OS X, *BSD and SteamOS. It can be used standalone or integrated into a GUI (Windows.Forms, WPF, GTK+, Qt, VTK, ...)

An old, unsupported version of OpenTK 1.0 may be included in the Xamarin Android and iOS distribution. The Xamarin fork is not supported or maintained by this project.

Adding support for mobile again is a future goal of the OpenTK project, but is somewhat frustrated by Apple's deprecation of OpenGL. Contributions to re-add support for these platforms are welcomed.

Instructions

OpenTK is available as a NuGet Package.

As of OpenTK 4.8 "Visual C++ Redistributable 2015" is not longer required to run OpenTK 4 on windows. For earlier versions of OpenTK 4 you can install any version of OpenTK.redist.glfw >= 3.3.8.35 to remove the "Visual C++ Redistributable 2015" requirement. See https://github.com/opentk/glfw-redist for more details.

News

2022-09-24

OpenTK 5.0.0 is still under active development and usage.

Preview releases are running non-trivial applications successfully on .Net 6 across all platforms.

Please drop by the discord for the latest updates!

2020-10-02

OpenTK 4.0.0 is released with full availability.

Key changes:

  • Full support for .Net Core 3.1
  • Brand new GLFW-based windowing system
  • Brand new GLFW-based input system
  • Removed all platform-specific backends (and fixed every xplat bug!)
  • Math library performance improvements and fixes
  • All new OpenAL bindings
  • All new OpenCL Bindings
  • Total restructure of all packages into a modular system with a number of packages. The OpenTK Nuget package is now a metapackage that will automatically download all of these for you.

OpenTK 4.0.0 is entirely MIT licensed.

We're excited to see what you can build with this!

https://www.nuget.org/packages/OpenTK

2020-04-06

Oops! Forgot to update the news! OpenTK 4.0.0 PREVIEW is now available on Nuget.

https://www.nuget.org/packages/OpenTK

2020-04-06

OpenTK 3.2.0 is available.

This adds bindings for the wgl_dx_interop extension and support for joysticks with > 64 buttons.

https://www.nuget.org/packages/OpenTK/3.2.0

2019-08-04

OpenTK 3.1.0 is available.

https://www.nuget.org/packages/OpenTK/3.1.0

https://www.nuget.org/packages/OpenTK.GLControl/3.1.0

2018-10-19

Work is well underway on OpenTK 4.0, which targets .netstandard 2.0.

We would welcome any contributions!

Click here to view the tracking issue.

2018-06-07

OpenTK 3.0.1 is available.

https://www.nuget.org/packages/OpenTK/3.0.1

https://www.nuget.org/packages/OpenTK.GLControl/3.0.1

2018-01-05

OpenTK 3.0.0 is available.

https://www.nuget.org/packages/OpenTK/3.0.0

https://www.nuget.org/packages/OpenTK.GLControl/3.0.0

Building from source

To build OpenTK from source you just need to clone the git repo and open OpenTK.sln in Visual Studio 2019 or later.

git clone https://github.com/opentk/opentk   # Download source code from git
cd opentk                                    # Enter the source directory
# open OpenTK.sln

Alternatively if you want to build using our buildscript you can use build.cmd / build.sh which require .net 6 to be installed.

git clone https://github.com/opentk/opentk   # Download source code from git
cd opentk                                    # Enter the source directory
./build.cmd / ./build.sh                     # Run the build script for your platform

To specify a specific target run:

./build.cmd -t <Target>

Contributing

OpenTK uses and encourages Early Pull Requests. Please don't wait until you're done to open a PR!

  1. Install Git and the .Net Core SDK
  2. Fork OpenTK
  3. Create a branch on your fork.
  4. Add an empty commit to start your work off (and let you open a PR): git commit --allow-empty -m "start of [thing you're working on]"
  5. Open a Pull request with [WIP] in the title. Do this before you actually start working.
  6. Make your commits in small, incremental steps with clear descriptions.
  7. Tag a maintainer when you're done and ask for a review!

Click here for good first issues.

Click here for everything we need help with.

Requirements

  • Windows (7/8,10), Linux, Mac OS X, *BSD, SteamOS, Android or iOS
  • For graphics, OpenGL drivers or a suitable emulator, such as ANGLE
  • For audio, OpenAL drivers or OpenAL Soft
  • To develop desktop applications: Visual Studio, Rider, or the command line tools.
  • To develop Android applications: Visual Studio and Xamarin
  • To develop iOS applications: Visual Studio, Xamarin and XCode

Documentation

API Documentation is available on the official website or inline from favourite IDE.

You can also browse the full API on the official website

Additional information can be found in the OpenTK Manual.

Technical documentation about the implementation of OpenTK can be found in the Technical Wiki.

Need Help?

Come chat with us on Discord.

We're happy to help with anything from learning OpenGL to advanced OpenTK questions.

License

The Open Toolkit is distributed under the permissive MIT/X11 license and is absolutely free.

opentk's People

Contributors

andykorth avatar arakis avatar boybaykiller avatar calvinwilkinson avatar devvoid avatar frassle avatar frederikja163 avatar freezylemon avatar g7chogxh avatar glopesdev avatar harry-cpp avatar hughph avatar imdreamerdev avatar jvbsl avatar leezer3 avatar malcolmstill avatar mv10 avatar nepnet avatar nihlus avatar nogginbops avatar ollhax avatar perksey avatar pjb3005 avatar realvictorprm avatar robmaister avatar thefiddler avatar tzachshabtay avatar utkumaden avatar varon avatar vperus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opentk's Issues

GraphicsMode.Index never set on linux

I'm using 1.1B3 where you write you solved the problem of Issue #17, but it still does not work for me. I always get:

OpenTK.Graphics.GraphicsModeException: Invalid or unsupported GraphicsMode.
at OpenTK.X11GLControl..ctor (OpenTK.Graphics.GraphicsMode mode, System.Windows.Forms.Control control) [0x0004b] in /home/littwin/opentk-2013-12-15/Source/GLControl/X11GLControl.cs:80
at OpenTK.GLControlFactory.CreateGLControl (OpenTK.Graphics.GraphicsMode mode, System.Windows.Forms.Control control) [0x00062] in /home/littwin/opentk-2013-12-15/Source/GLControl/GLControlFactory.cs:49

With OpenTK 1.0 everything works for me. Same code also works with Windows and 1.1B3. The exception comes, because the index attribute gets not set. And searching the project reveals no position, where this even could happen. So I compared it with 1.0 and you removed the LazySelectGraphicsMode() call:

    public IntPtr? Index
    {
        get
        {
            LazySelectGraphicsMode();
            return index;
        }
        set { index = value; }
    }

so where should it now get set and why does it never get set? Tried to copy the lazy select code back, but that also did not work. Then I get an exception that EGL is not supported. Adding it to compatibility did not help, or I did it wrong.

Output of glxinfo:
[littwin@fedora lib]$ glxinfo
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: Parallels Inc
server glx version string: 1.4
server glx extensions:
GLX_EXT_texture_from_pixmap, GLX_SGIX_fbconfig
client glx vendor string: Parallels Inc
client glx version string: 1.4
client glx extensions:
GLX_ARB_get_proc_address, GLX_EXT_texture_from_pixmap, GLX_SGIX_fbconfig
GLX version: 1.4
GLX extensions:
GLX_ARB_get_proc_address, GLX_EXT_texture_from_pixmap, GLX_SGIX_fbconfig
OpenGL vendor string: Parallels and ATI Technologies Inc.
OpenGL renderer string: Parallels using ATI Radeon HD 6770M OpenGL Engine
OpenGL version string: 2.1 ATI-1.14.21
OpenGL shading language version string: 1.2
OpenGL extensions:
GL_ARB_depth_texture, GL_ARB_draw_buffers, GL_ARB_fragment_program,
GL_ARB_fragment_program_shadow, GL_ARB_fragment_shader,
GL_ARB_framebuffer_object, GL_ARB_half_float_pixel,
GL_ARB_half_float_vertex, GL_ARB_imaging, GL_ARB_map_buffer_range,
GL_ARB_multisample, GL_ARB_multitexture, GL_ARB_occlusion_query,
GL_ARB_pixel_buffer_object, GL_ARB_point_parameters, GL_ARB_point_sprite,
GL_ARB_shader_objects, GL_ARB_shader_texture_lod,
GL_ARB_shading_language_100, GL_ARB_shadow, GL_ARB_shadow_ambient,
GL_ARB_texture_border_clamp, GL_ARB_texture_compression,
GL_ARB_texture_compression_rgtc, GL_ARB_texture_cube_map,
GL_ARB_texture_env_add, GL_ARB_texture_env_combine,
GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3,
GL_ARB_texture_float, GL_ARB_texture_mirrored_repeat,
GL_ARB_texture_non_power_of_two, GL_ARB_texture_rectangle,
GL_ARB_texture_rg, GL_ARB_transpose_matrix, GL_ARB_vertex_blend,
GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_vertex_shader,
GL_ARB_window_pos, GL_ATI_separate_stencil, GL_ATI_texture_env_combine3,
GL_ATI_texture_float, GL_ATI_texture_mirror_once, GL_EXT_abgr,
GL_EXT_bgra, GL_EXT_bindable_uniform, GL_EXT_blend_color,
GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate,
GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_clip_volume_hint,
GL_EXT_compiled_vertex_array, GL_EXT_draw_buffers2,
GL_EXT_draw_range_elements, GL_EXT_fog_coord, GL_EXT_framebuffer_blit,
GL_EXT_framebuffer_multisample, GL_EXT_framebuffer_object,
GL_EXT_framebuffer_sRGB, GL_EXT_geometry_shader4,
GL_EXT_gpu_program_parameters, GL_EXT_multi_draw_arrays,
GL_EXT_packed_depth_stencil, GL_EXT_packed_float, GL_EXT_provoking_vertex,
GL_EXT_rescale_normal, GL_EXT_secondary_color,
GL_EXT_separate_specular_color, GL_EXT_shadow_funcs,
GL_EXT_stencil_two_side, GL_EXT_stencil_wrap, GL_EXT_texture3D,
GL_EXT_texture_array, GL_EXT_texture_compression_dxt1,
GL_EXT_texture_compression_s3tc, GL_EXT_texture_edge_clamp,
GL_EXT_texture_env_add, GL_EXT_texture_env_combine,
GL_EXT_texture_filter_anisotropic, GL_EXT_texture_integer,
GL_EXT_texture_lod_bias, GL_EXT_texture_mirror_clamp,
GL_EXT_texture_rectangle, GL_EXT_texture_sRGB,
GL_EXT_texture_shared_exponent, GL_EXT_vertex_array_bgra,
GL_NV_blend_square, GL_NV_depth_clamp, GL_NV_fog_distance,
GL_NV_light_max_exponent, GL_NV_texgen_reflection,
GL_NV_texture_rectangle, GL_SGIS_generate_mipmap,
GL_SGIS_texture_edge_clamp, GL_SGIS_texture_lod, GL_SGI_color_matrix

2 GLX Visuals
visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav

id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat

0x021 24 tc 1 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x041 32 tc 1 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None

8 GLXFBConfigs:
visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav

id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat

0x042 24 tc 1 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x043 24 tc 1 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x044 32 tc 1 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x045 32 dc 1 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x046 24 tc 1 24 0 r . . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x047 24 tc 1 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x048 32 tc 1 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x049 32 dc 1 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None

System is fedora 19 under Parallels 9. glxgears and compilations with OpenTK 1.0 work fine.

My testcode is a simple window form with a green background. Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenTK.Graphics.OpenGL;
using OpenTK;

namespace GLControlTest
{
public partial class Form1 : Form
{
GLControl gl;
bool loaded = false;
public Form1()
{
InitializeComponent();
//gl = new GLControl();
var mode = new OpenTK.Graphics.GraphicsMode(new OpenTK.Graphics.ColorFormat(32), 24, 8, 0);
gl = new GLControl(mode);
gl.Dock = DockStyle.Fill;
Controls.Add(gl);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
loaded = true;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (!loaded) return;
GL.ClearColor(Color.Green);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
gl.SwapBuffers();
}
}
}

Any ideas what I could do to get it running under linux?

Slow performance + artifacts

Hi,

A user of my application is reporting very slow performance and visual artifacts. His computer is:
Windows 7 professional 64 bit, service pack 1
Nvidia NVS 4200M (date: 4/18/2013, version: 9.18.13.2000)

The beta3 worked fine for him, but beta4 crashes and the latest develop code (as of commit 7f64945) runs again but now has the poor performance/visuals.

He uploaded this movie showing the problem. I'm not sure why the video is upside down, but he is attempting to rotate the house rendering by clicking and dragging his mouse around:
http://sharesend.com/45d9pbih

I do not have a tracer log but can request that if necessary. Let me know if any other information is needed.

NuGet Support

Have you considered adding a NuGet package for OpenTK? There's a couple of unofficial ones floating about, usually makes it easier to keep references up to date as OpenTK is updated, and to quickly add it to new projects. Also nicer for sharing example code as you don't have to worry about lib paths etc!

I currently use one named opentk_unofficial, but would be nice to have a properly maintained one.

Regards;
Richard Moss

Fallback mode errors on linux

For some reason, the mapping to graphic modes seem not to work as supposed on linux. Th eused system is a Fedora 19 run unter Parallels simulating an ATI card. glxinfo gives the following modes:

    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x021 24 tc  1  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x041 32 tc  1  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None

8 GLXFBConfigs:
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x042 24 tc  1  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x043 24 tc  1  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x044 32 tc  1  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x045 32 dc  1  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x046 24 tc  1  24  0 r  . .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x047 24 tc  1  32  0 r  . .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x048 32 tc  1  32  0 r  . .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x049 32 dc  1  32  0 r  . .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None

Using this simple test program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenTK.Graphics.OpenGL;
using OpenTK;

namespace GLControlTest
{
    public partial class Form1 : Form
    {
        GLControl gl;
        bool loaded = false;
        public Form1()
        {
            InitializeComponent();
            //gl = new GLControl();
            //var mode = new OpenTK.Graphics.GraphicsMode(new OpenTK.Graphics.ColorFormat(32), 24, 8, 4); // Does not work on computer without AA support
            var mode = new OpenTK.Graphics.GraphicsMode(new OpenTK.Graphics.ColorFormat(32), 24, 8, 0); // Does work
            gl = new GLControl(mode,1,0,0);
            gl.Dock = DockStyle.Fill;
            Controls.Add(gl);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            loaded = true;
            Invalidate();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (!loaded) return;
            Console.WriteLine (gl.GraphicsMode.ToString());
            GL.ClearColor(Color.Green);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            gl.SwapBuffers();
        }
    }
}

I get for the first mode version:

OpenTK.Graphics.GraphicsModeException: Requested GraphicsMode not available.
  at OpenTK.Platform.X11.X11GraphicsMode.SelectGraphicsMode (ColorFormat color, Int32 depth, Int32 stencil, Int32 samples, ColorFormat accum, Int32 buffers, Boolean stereo) [0x00050] in /home/littwin/opentk-2013-12-15/Source/OpenTK/Platform/X11/X11GraphicsMode.cs:51 
  at OpenTK.Platform.X11.X11GLContext..ctor (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, IGraphicsContext shared, Boolean direct, Int32 major, Int32 minor, GraphicsContextFlags flags) [0x0003a] in /home/littwin/opentk-2013-12-15/Source/OpenTK/Platform/X11/X11GLContext.cs:48 

no fallback to one of the supported modes without anti-aliasing.

For the second mode version I get the output:

Index: 33, Color: 24 (8880), Depth: 24, Stencil: 8, Samples: 0, Accum: 0 (0000), Buffers: 2, Stereo: False

also index 65 would match the given values 100%.

Examples.Tutorial.Textures throws an exception on Ubuntu

System.Drawing.Bitmap doesn't seem supported, changing the paths to absolute paths does nothing to help.

Exception occured in example Examples.Tutorial.Textures: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.String filename, Boolean useIcm) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.String filename) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (string)
  at Examples.Tutorial.Textures..ctor () [0x00000] in <filename unknown>:0 
  at Examples.Tutorial.Textures.Main () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParameters) [0x00000] in <filename unknown>:0 
  at System.Type.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args) [0x00000] in <filename unknown>:0 
  at Examples.Program.LaunchExample (System.String type) [0x00000] in <filename unknown>:0 

Resizing GameWindow causes it to move offscreen.

Setting the Width property of a GameWindow will cause the window to reposition itself in the upper-left corner of the screen in such a way that the title bar is off the screen. Setting the Height property doesn't seem to do this.

I've only tested this in Windows XP, so I'm not sure if the same behavior affects Vista/7/8, or any other platform.

GamePadState.Triggers: Wrong range using XBox360 Controller for Windows

  • GamePadState.Triggers assumes a short value range. (0-32767)
  • However, the XBox360 Controller for Windows outputs a byte range (0-255)
  • The Trigger values will always be very, very small contrary to the expected 0.0-1.0 float range.
  • This may be a general problem with all controllers, but I only have the one mentioned above available for testing.
  • It works correctly when using the Joystick input API, where the triggers will just be defined as a single axis between -1.0 and 1.0

[Mono] Title and borders disappear after returning from fullscreen

Under Mono (but not .NET), calling WindowState = OpenTK.WindowState.Fullscreen and then WindowState = OpenTK.WindowState.Normal restores the drawing surface(ClientRectangle) to its former position and size, but the title and borders do not reappear.

(OnResize doesn't seem to affect this result - tested with base.OnResize(e) as well as entirely blank.)

Weird fonts/menus with GLControl, Winforms

I have had a couple users experience strange fonts and menu positioning in our WinForms application, which uses the beta1 release of OpenTK's GLControl. I was really surprised to see that, while the control appears in only one area of our application, the fonts/menus affected are outside the control. How is this even possible?

I have uploaded a user's screenshots of the bad behavior:
http://i.imgur.com/VCkfixH.png
and the good behavior:
http://i.imgur.com/hHeBJFX.png

One user has a Dell Alienware laptop with Windows 7 64-bit, and another user is using the latest version of Parallels Desktop on Mac Mavericks OSX.

We verified that the previous OpenTK nightly build (2012-03-15) worked correctly for the latter user (I'm awaiting a response from the former user).

What other information can I provide?

Thanks,
Scott

ig4icd32.dll crash

I have a user that is getting a crash using OpenTK 1.1 betas (both 1 and 3). We have confirmed that everything works correctly if he uses the OpenTK 1.0 nightly files (2012-03-05).

Here is his computer information:

  • Windows 7 - 64 Bit
  • NVIDIA NVS 4200M
  • Driver Version: NVIDIA 9.18.13.3182
  • Driver Date: 11/11/2013

And here is the crash message:
Problem signature:
Problem Event Name: APPCRASH
Application Name: BEopt.exe
Application Version: 2.1.0.1
Application Timestamp: 52ab7b51
Fault Module Name: ig4icd32.dll
Fault Module Version: 8.15.10.2321
Fault Module Timestamp: 4d745e3e
Exception Code: c00000fd
Exception Offset: 00127152
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1033
Additional Information 1: 13ae
Additional Information 2: 13ae37d1b8ccccc792ecaa96e26f0cc0
Additional Information 3: 18e5
Additional Information 4: 18e56ce40c91f03826398e1625a90f7b

I attempted to use a debug version of OpenTK to capture the log (via a Trace Listener) but the crash occurs before the log is written.

How can I help resolve this issue?

Thanks,
Scott

Review build warnings

A typical build on a modern version of Mono/.Net results in roughly 160 warnings. We should review these warnings and either fix them or silence them when harmless (e.g. unused private field warning for reserved fields in interop structures.)

When using OpenTK + SDL2, any consequent GameWindow will not fire Mouse events

When using OpenTK with SDL2, any GameWindow opened after first will not fire Mouse events. Works fine with just OpenTK.

Example:
I've got a GameWindow inheriting class that has "Mouse.ButtonDown += Mouse_ButtonDown;" in it's OnLoad. If I spawn more than one window of this class (in sucession - first window closed then second one opened) then this event will no longer fire.

Xbox 360 controller does not report dpad changes

In OpenTK 1.1, after the introduction of hats I'm still not able to detect changes in the dpad on my wired Xbox 360 controller. The device is shown as having 1 hat, but the neither of the hats/axes/buttons change when I use the dpad. Everything else gets detected just fine. As far as I know the dpad should be reported either as 2 axes or as a hat. I can supply more details if requested.

Show COMPSIZE() hints in the documentation tooltips

OpenGL functions with array parameters, such as DrawRangeElements, are decorated with COMPSIZE() hints that describe how the array size is calculated. For instance:

        <command>
            <proto>void <name>glDrawRangeElements</name></proto>
            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
            <param><ptype>GLuint</ptype> <name>start</name></param>
            <param><ptype>GLuint</ptype> <name>end</name></param>
            <param><ptype>GLsizei</ptype> <name>count</name></param>
            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
        </command>

The last parameter has len="COMPSIZE(count,type)", which means that its length is determined by the count and type parameters (and not from mode as one might expect.)

It would be nice to display these hints in our documentation tooltips.

This requires the following changes:

  • Generator.Convert.GLXmlParser: read len attributes from gl.xml and store them in our signatures.xml
  • Generator.Bind.Parameter: add ComputeSize property
  • Generator.Bind.XmlSpecReader: set ComputeSize properties for relevant parameters
  • Generator.Bind.CSharpSpecWriter: generate doc comments for ComputeSize properties

The last step is the most complicated one, because doc comments do not currently pass through the data model, but are generated directly from the xml manpages of OpenGL via xslt.

Cannot open GameWindow after one was closed when using SDL

Taking a simple example application, has a windows form with one button, in the button code I do this:

using (SimpleWindow example = new SimpleWindow()) { example.Run(); }

Now, without SDL2.dll, I can do this all day - I can spawn however many windows I need (closing current one before opening another). However, with SDL2.dll, when I close a window, after a certain time passes, if I try to spawn another window, I get this when doing .Run():

A callback was made on a garbage collected delegate of type 'OpenTK!OpenTK.Platform.SDL2.EventFilter::Invoke'.
This may cause application crashes, corruption and data loss.
When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.

[Graphics] Add OpenGL error detection to the new calli-based bindings

Debug versions of OpenTK used to detect and convert OpenGL errors into exceptions. This functionality is missing from the new calli-based bindings.

This requires the following modifications to the Generator.Rewrite project.

  • Wrap all OpenGL and OpenGL ES entry point, excluding GL.GetError(), with:
using (new ErrorHelper(GraphicsContext.CurrentContext))
{
  // calli
}
  • Add the following code to GL.Begin():
GraphicsContext.ErrorChecking = false;
  • Add the following code to GL.End():
GraphicsContext.ErrorChecking = true;

This functionality is very useful when testing OpenTK applications, so it would be nice to implement in the new bindings. This only affects debug builds, so performance of release builds is not impacted.

[Win] 1.1 beta4 crash using Remote Desktop

The 1.1 beta4 crashes in my application when used in a Windows Remote Desktop connection. The beta3 worked fine.

The crash occurs in my code on the following line, which was the result of a resize event being fired on the form load:
GL.Viewport(0, 0, w, h)

Here is the log with the error:

A first chance exception of type 'System.DllNotFoundException' occurred in OpenTK.dll
SDL2 init failed with exception: System.DllNotFoundException: Unable to load DLL 'SDL2.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at OpenTK.Platform.SDL2.SDL.WasInit(SystemFlags flags)
   at OpenTK.Configuration.DetectSdl2() in c:\Users\resbldg\Documents\OpenTK\1.1\Source\OpenTK\Configuration.cs:line 207
SDL2 is not supported
Detected configuration: Windows / .Net
Loaded opengl32.dll: 135069696
A first chance exception of type 'System.DllNotFoundException' occurred in OpenTK.dll
GraphicsMode.Default = Index: , Color: 32 (8888), Depth: 16, Stencil: 0, Samples: 0, Accum: 0 (0000), Buffers: 2, Stereo: False
Creating GraphicsContext.
    GraphicsMode: Index: , Color: 32 (8888), Depth: 16, Stencil: 0, Samples: 0, Accum: 0 (0000), Buffers: 2, Stereo: False
    IWindowInfo: Windows.WindowInfo: Handle 459418, Parent (null)
    GraphicsContextFlags: Default
    Requested version: 1.0
    DisplayDevice 1 (primary) supports 1 resolutions.
    [WGL] Creating temporary context to load extensions
    Setting pixel format... [WGL] ChoosePixelFormatARB not supported on this context
A first chance exception of type 'OpenTK.Graphics.GraphicsModeException' occurred in OpenTK.dll
    Destroying window: Windows.WindowInfo: Handle 459412, Parent (null)
A first chance exception of type 'System.AccessViolationException' occurred in OpenTK.dll
An unhandled exception of type 'System.AccessViolationException' occurred in OpenTK.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Let me know if I can provide more information.

GL.ReadPixels behaving differently on 2 PCs

Background can be found here: http://www.opentk.com/node/3434
New version ( Commit d9afed2 ) did not resolve the issue.

Test case can be constructed as follows (assumes Visual Studio is used). This was constructed using the latest version ( Commit d9afed2 ) of OpenTK:

  1. Create Windows Forms project

  2. Add references to OpenTK.dll and OpenTK.GLControl.dll

  3. Add GLControl to main program form

  4. Set Dock property to Fill

  5. Create class variables w and h (both of type int), and p of type Point.

  6. Create override for the forms OnLoad() event

  7. Update OnLoad event with the following code:

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            GL.ClearColor(Color.Black);
            GL.Enable(EnableCap.DepthTest);

            w = ClientSize.Width;
            h = ClientSize.Height;

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, w, 0, h, -1, 1);
            GL.Viewport(0, 0, w, h);
            GL.PointSize(3f);

            if (IterateBitmap())
                MessageBox.Show("Found pixels\nFirst pixel at x = " + p.X + ", y = " + p.Y, "Success");
            else
                MessageBox.Show("Did not find pixels", "Failure");

            Close();
        }
  1. Add function to draw an arbitrary polygon:
        private void DrawBox()
        {
            // TODO: Just a box for now, but need to test with circle and some QuickFont text!
            GL.Begin(PrimitiveType.Polygon);
            GL.Color3(Color.Gray);
            GL.Vertex2(w / 3, h / 3);
            GL.Vertex2(w / 3, 2 * h / 3);
            GL.Vertex2(2 * w / 3, 2 * h / 3);
            GL.Vertex2(2 * w / 3, h / 3);
            GL.End();
        }
  1. Add functions to call polygon drawing routine, and then to read the pixels and iterate over them:
        private bool IterateBitmap()
        {
            bool found = false;
            DrawBox();
            Bitmap bmp = GrabScreenshot();

            // Iterate over bitmap pixels. When a non-black and non-white pixel is found, update the initial height array
            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    Color c = bmp.GetPixel(x, y);  // Slow! But can refine the area to iterate at a later date
                    if (c.R != 0 || c.G != 0 || c.B != 0)
                    {
                        // I would expect this loop to be entered if GL.ReadPixels() had detected the pixels created by DrawBox()
                        found = true;
                        p = new Point(x, y);
                        break;
                    }
                }
                if (found) break;
            }
            bmp.Dispose();

            return found;
        }

        public Bitmap GrabScreenshot()
        {
            // Read OpenGL buffer into a bitmap so we can iterate the pixels
            Bitmap bmp = new Bitmap(glControl1.ClientSize.Width, glControl1.ClientSize.Height);
            System.Drawing.Imaging.BitmapData data =
                bmp.LockBits(glControl1.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
                             System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            ErrorCode ec = GL.GetError();
            GL.Flush();
            GL.ReadBuffer(ReadBufferMode.Back);
            GL.ReadPixels(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height, PixelFormat.Bgr,
                          PixelType.UnsignedByte, data.Scan0);
            ec = GL.GetError();
            bmp.UnlockBits(data);
            bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);

            return bmp;
        }

KeyboardKeyEventArgs vs KeyPressEventArgs

In this example I use the event based input mechanism to detect keypress input events. However then I must switch to the stateless input mechanism of the game window.

window.KeyPress += (object sender, KeyPressEventArgs e) => {
    if (window.Keyboard[Key.Escape])
        window.Close();
};

However, I noticed that KeyDown or KeyUp events, offer KeyboardKeyEventArgs, where they offer both a Key and a Scancode field.

Should KeyPress event do the same as well by design?

[NuGet] GLControl doesn't add to VS2012 Toolbox when installed via NuGet

This issue was originally reported here, and repro'd by the Fiddler who believes it happens with NuGet installed OpenTk but not manual installed OpenTk:

I can't get GLControl to appear in the VS2012 toolbox - I'm trying the OpenTK "Building a Windows.Forms + GLControl based application" tutorial.

I have: VS2012. A new Windows Forms project. OpenTK 1.1.1456.5398 and OpenTK.GLControl 1.1.1456.5398 installed in my solution via NuGet. They show up in the project references.

When I use the "choose items" dialog in the toolbox, and find the dll OpenTK.GLControl.dll it eventually tells me:

---------------------------
 Microsoft Visual Studio
 ---------------------------
 There are no components in 'R:\...\OpenGLTest1\packages\OpenTK.GLControl.1.1.1456.5398\lib\NET40\OpenTK.GLControl.dll' that can be placed on the toolbox.
 ---------------------------

Various online solutions to that are proposed (not specific to GLControl) - including drag/drop of the DLL right onto the toolbox (also doesn't do anything), restarted VS completely (doesn't help), compiling the project first then restarting VS (doesn't help).

The Fiddler says:

I can reproduce this in VS2013 when using the nuget package. If I uninstall the nuget package and reference OpenTK.dll and OpenTK.GLControl.dll directly from a local installation, then it appears to be working correctly.

DisplayDevice.Default

I've been trying to do a simple thing: Change fullscreen mode and resolution. However I was having problems with the RestoreResolution() method, as it seemed to have no effect. After a lot of searching and trial and error, I discovered an old post in the forums that is still relevant: http://www.opentk.com/node/2840.

Simply by storing my own reference to DisplayDevice.Default when the application starts and using this to control my resolution changes fixes the problems of RestoreResolution() not working. The forum posts suggests that the DefaultDevice object is being recreated and therefore the original_resolution field is reset.

FrameEventArgs.Time Inconsistencies

Original thread: http://www.opentk.com/node/3485

I've modified the HelloGL3 example included with OpenTK to show how the issue can be replicated.

The relevant code is located in the OnUpdateFrame method. I'm simply wasting CPU time on every update and outputting the times of FrameEventArgs.Time and Stopwatch every time FrameEvenArgs reaches 1 second.

// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.

using System;
using System.Diagnostics;
using System.IO;

using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;

namespace Examples.Tutorial
{
    [Example("OpenGL 3.0", ExampleCategory.OpenGL, "3.x", Documentation="HelloGL3")]
    public class HelloGL3 : GameWindow
    {
        string vertexShaderSource = @"
#version 130

precision highp float;

uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;

in vec3 in_position;
in vec3 in_normal;

out vec3 normal;

void main(void)
{
  //works only for orthogonal modelview
  normal = (modelview_matrix * vec4(in_normal, 0)).xyz;

  gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1);
}";

        string fragmentShaderSource = @"
#version 130

precision highp float;

const vec3 ambient = vec3(0.1, 0.1, 0.1);
const vec3 lightVecNormalized = normalize(vec3(0.5, 0.5, 2.0));
const vec3 lightColor = vec3(0.9, 0.9, 0.7);

in vec3 normal;

out vec4 out_frag_color;

void main(void)
{
  float diffuse = clamp(dot(lightVecNormalized, normalize(normal)), 0.0, 1.0);
  out_frag_color = vec4(ambient + diffuse * lightColor, 1.0);
}";

        int vertexShaderHandle,
            fragmentShaderHandle,
            shaderProgramHandle,
            modelviewMatrixLocation,
            projectionMatrixLocation,
            vaoHandle,
            positionVboHandle,
            normalVboHandle,
            eboHandle;

        Vector3[] positionVboData = new Vector3[]{
            new Vector3(-1.0f, -1.0f,  1.0f),
            new Vector3( 1.0f, -1.0f,  1.0f),
            new Vector3( 1.0f,  1.0f,  1.0f),
            new Vector3(-1.0f,  1.0f,  1.0f),
            new Vector3(-1.0f, -1.0f, -1.0f),
            new Vector3( 1.0f, -1.0f, -1.0f), 
            new Vector3( 1.0f,  1.0f, -1.0f),
            new Vector3(-1.0f,  1.0f, -1.0f) };

        int[] indicesVboData = new int[]{
             // front face
                0, 1, 2, 2, 3, 0,
                // top face
                3, 2, 6, 6, 7, 3,
                // back face
                7, 6, 5, 5, 4, 7,
                // left face
                4, 0, 3, 3, 7, 4,
                // bottom face
                0, 1, 5, 5, 4, 0,
                // right face
                1, 5, 6, 6, 2, 1, };

        Matrix4 projectionMatrix, modelviewMatrix;

        public HelloGL3()
            : base(640, 480,
            new GraphicsMode(), "OpenGL 3 Example", 0,
            DisplayDevice.Default, 3, 0,
            GraphicsContextFlags.ForwardCompatible | GraphicsContextFlags.Debug)
        { }

        protected override void OnLoad (System.EventArgs e)
        {
            VSync = VSyncMode.On;

            CreateShaders();
            CreateVBOs();
            CreateVAOs();

            // Other state
            GL.Enable(EnableCap.DepthTest);
            GL.ClearColor(System.Drawing.Color.MidnightBlue);
        }

        void CreateShaders()
        {
            vertexShaderHandle = GL.CreateShader(ShaderType.VertexShader);
            fragmentShaderHandle = GL.CreateShader(ShaderType.FragmentShader);

            GL.ShaderSource(vertexShaderHandle, vertexShaderSource);
            GL.ShaderSource(fragmentShaderHandle, fragmentShaderSource);

            GL.CompileShader(vertexShaderHandle);
            GL.CompileShader(fragmentShaderHandle);

            Debug.WriteLine(GL.GetShaderInfoLog(vertexShaderHandle));
            Debug.WriteLine(GL.GetShaderInfoLog(fragmentShaderHandle));

            // Create program
            shaderProgramHandle = GL.CreateProgram();

            GL.AttachShader(shaderProgramHandle, vertexShaderHandle);
            GL.AttachShader(shaderProgramHandle, fragmentShaderHandle);

            GL.LinkProgram(shaderProgramHandle);

            Debug.WriteLine(GL.GetProgramInfoLog(shaderProgramHandle));

            GL.UseProgram(shaderProgramHandle);

            // Set uniforms
            projectionMatrixLocation = GL.GetUniformLocation(shaderProgramHandle, "projection_matrix");
            modelviewMatrixLocation = GL.GetUniformLocation(shaderProgramHandle, "modelview_matrix");

            float aspectRatio = ClientSize.Width / (float)(ClientSize.Height);
            Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, aspectRatio, 1, 100, out projectionMatrix);
            modelviewMatrix = Matrix4.LookAt(new Vector3(0, 3, 5), new Vector3(0, 0, 0), new Vector3(0, 1, 0));

            GL.UniformMatrix4(projectionMatrixLocation, false, ref projectionMatrix);
            GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);
        }

        void CreateVBOs()
        {
            GL.GenBuffers(1, out positionVboHandle);
            GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
            GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
                new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
                positionVboData, BufferUsageHint.StaticDraw);

            GL.GenBuffers(1, out normalVboHandle);
            GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
            GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
                new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
                positionVboData, BufferUsageHint.StaticDraw);

            GL.GenBuffers(1, out eboHandle);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
            GL.BufferData(BufferTarget.ElementArrayBuffer,
                new IntPtr(sizeof(uint) * indicesVboData.Length),
                indicesVboData, BufferUsageHint.StaticDraw);

            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
        }

        void CreateVAOs()
        {
            // GL3 allows us to store the vertex layout in a "vertex array object" (VAO).
            // This means we do not have to re-issue VertexAttribPointer calls
            // every time we try to use a different vertex layout - these calls are
            // stored in the VAO so we simply need to bind the correct VAO.
            GL.GenVertexArrays(1, out vaoHandle);
            GL.BindVertexArray(vaoHandle);

            GL.EnableVertexAttribArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
            GL.BindAttribLocation(shaderProgramHandle, 0, "in_position");

            GL.EnableVertexAttribArray(1);
            GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
            GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
            GL.BindAttribLocation(shaderProgramHandle, 1, "in_normal");

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);

            GL.BindVertexArray(0);
            stopwatch = new Stopwatch();
            stopwatch.Reset();
            stopwatch.Start();
            argsTime = 0;
        }

        Stopwatch stopwatch;
        double argsTime;
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            // Every time the stopwatch hits 1 second, output both timers and clear them.
            argsTime += e.Time;
            if(stopwatch.Elapsed.TotalSeconds >= 1)
            {
                stopwatch.Stop();
                Console.WriteLine("Stopwatch time: {0}", stopwatch.Elapsed.TotalMilliseconds);
                Console.WriteLine("ArgsTime time: {0}", argsTime * 1000);
                argsTime = 0;
                stopwatch.Reset();
                stopwatch.Start();
            }

            // Do some intensive work.
            // This block of code has no meaning, it's only used to waste CPU time to
            // create a gap between FrameEventArgs.Time and the Stopwatch time.
            for(long i = 0; i < 3000000; ++i)
            {
                long j = i * i;
            }

            Matrix4 rotation = Matrix4.CreateRotationY((float)e.Time);
            Matrix4.Mult(ref rotation, ref modelviewMatrix, out modelviewMatrix);
            GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);

            if (Keyboard[OpenTK.Input.Key.Escape])
                Exit();
        }

        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.BindVertexArray(vaoHandle);
            GL.DrawElements(BeginMode.Triangles, indicesVboData.Length,
                DrawElementsType.UnsignedInt, IntPtr.Zero);

            SwapBuffers();
        }

        [STAThread]
        public static void Main()
        {
            using (HelloGL3 example = new HelloGL3())
            {
                Utilities.SetWindowTitle(example);
                example.Run(30);
            }
        }
    }
}

Reopening of bug 2506? GLControl inside a user control crashes during design time

I would like to fill a request to reopen bug 2506:
http://www.opentk.com/node/2506

I've tried both compiling OpenTK 1.1-rc1 from sources and the current release (opentk-2014-01-15) to no avail.

My code compiles and runs fine, but visual studio 2012 crashes when I enter design mode for a form into which I put a custom user control that contains a docked GLControl.

Copied from link above, the workflow looks like this:

  1. Create new WinForms project
  2. Add new user control called UserControl1
  3. Drop a GLControl on to the user control
  4. Rebuild project
  5. Drop UserControl1 on to main form
  6. GLControl should crash

Add hardware cursor support

Continuing from here: http://www.opentk.com/node/3443?page=1

This post describes how to implement hardware cursors on Windows: http://www.mimicprod.net/2010/09/hardware-cursor-in-opengl/

SDL provides a cursor API, but the documentation states that it is black-and-white only (it is possible that the documentation is out of date here.)

We still need to find out how this works on X11 and Carbon.

Ideally, our public API will take an array of 32bit RGBA values with a specific layout. This way we remain agnostic to any platform-specific cursor format (e.g. windows .ico files, .png images etc etc) and we avoid System.Drawing which is broken and not portable.

Unstable "frames per second"

CPU = AMD Phenom 9500 Quad-Core
OS = Windows 7 - 32bit
OpenTK = last develop version (1.1.1469.43853)

Test conditions:
VSync = VSyncMode.On;
this.Title = "GameWindowSimple (Vsync: " + VSync.ToString() + ") " + " FPS: " + (1f / e.Time).ToString("0.");

Problems:

  1. The FPS is constantly oscillating, understand their value should be constant to the monitor refresh rate (60 Hz).
  2. The code calculates the FPS, when inserted into "override void OnUpdateFrame()" indicates an FPS of about 1000 FPS. Within OnUpdateFrame () has no effect Vsync.

Code of test:

// This code was written for the OpenTK library and has been released
// to the Public Domain.
// It is provided "as is" without express or implied warranty of any kind.

using System;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;

namespace Examples.Tutorial
{
    /// <summary>
    /// Demonstrates the GameWindow class.
    /// </summary>
    //[Example("GameWindow Simple", ExampleCategory.OpenTK, "GameWindow", 1, Documentation = "GameWindowSimple")]
    public class SimpleWindow : GameWindow
    {
        public SimpleWindow() : base(800, 600)
        {
            VSync = VSyncMode.On;
            Keyboard.KeyDown += Keyboard_KeyDown;
        }

        #region Keyboard_KeyDown

        /// <summary>
        /// Occurs when a key is pressed.
        /// </summary>
        /// <param name="sender">The KeyboardDevice which generated this event.</param>
        /// <param name="e">The key that was pressed.</param>
        void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
        {
            if (e.Key == Key.Escape)
                this.Exit();

            if (e.Key == Key.F11)
                if (this.WindowState == WindowState.Fullscreen)
                    this.WindowState = WindowState.Normal;
                else
                    this.WindowState = WindowState.Fullscreen;

            if (e.Key == Key.F12)
                if (VSync == VSyncMode.On)
                    VSync = VSyncMode.Off;
                else
                    VSync = VSyncMode.On;
        }

        #endregion

        #region OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color.MidnightBlue);
        }

        #endregion

        #region OnResize

        /// <summary>
        /// Respond to resize events here.
        /// </summary>
        /// <param name="e">Contains information on the new GameWindow size.</param>
        /// <remarks>There is no need to call the base implementation.</remarks>
        protected override void OnResize(EventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
        }

        #endregion

        #region OnUpdateFrame

        /// <summary>
        /// Add your game logic here.
        /// </summary>
        /// <param name="e">Contains timing information.</param>
        /// <remarks>There is no need to call the base implementation.</remarks>
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
        }

        #endregion

        #region OnRenderFrame

        /// <summary>
        /// Add your game rendering code here.
        /// </summary>
        /// <param name="e">Contains timing information.</param>
        /// <remarks>There is no need to call the base implementation.</remarks>
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            this.Title = "GameWindowSimple (Vsync: " + VSync.ToString() + ") " + "  FPS: " + (1f / e.Time).ToString("0.");

            GL.Clear(ClearBufferMask.ColorBufferBit);

            GL.Begin(BeginMode.Triangles);

            GL.Color3(Color.MidnightBlue);
            GL.Vertex2(-1.0f, 1.0f);
            GL.Color3(Color.SpringGreen);
            GL.Vertex2(0.0f, -1.0f);
            GL.Color3(Color.Ivory);
            GL.Vertex2(1.0f, 1.0f);

            GL.End();

            this.SwapBuffers();
        }

        #endregion

        #region public static void Main()

        /// <summary>
        /// Entry point of this example.
        /// </summary>
        [STAThread]
        public static void Main()
        {
            using (SimpleWindow example = new SimpleWindow())
            {
                // Get the title and category  of this example using reflection.
                //Utilities.SetWindowTitle(example);
                //example.Run(30.0, 0.0);
                example.Run();
            }
        }

        #endregion
    }
}

[Mono] WindowBorder always returns Resizable

On Mono (on Win7 x64), the WindowBorder property always returns WindowBorder.Resizable, no matter what the current border state is. (Works as expected under .NET)

However, setting WindowBorder to Hidden or Fixed still makes the borders function as expected - but setting it back to Resizable will fail.

(I haven't seen the internal code in question, but this is consistent with a check that border_state != new_border_state. Naturally, this would make all attempts to set Resizable fail.)

X11 misreported as unsupported platform

Hi,

I'm writing an application using OpenTK under Ubuntu. I switched my code over to use the version in GitHub, and encountered the following error:
When I launch my application, I get a PlatformNotSupportedException. (the message for that is unhelpful, mind, but that's another issue). I checked one of the included examples in case something changed, but nothing fundamental changed about the way things are called, and it throws the same exception.

Some digging leads me to conclude that X11 support is not checked under the correct circumstances (in Platform.Configuration.Init()) . It is only checked if:

  1. the selected platform backend is not the default one (it's an elseif)
  2. we're running on Linux or the backend is set to PlatformBackend.PreferX11

For now, I've just commented out the else if around the runningOnX11 check, as a quick hack to fix it, and this does indeed make the program run normally. I'm not completely read in on all the code so I'm not sure what the best way to fix it would be. My layman opinion is that it seems like Configuration should only check what's available, and then Factory decides which backend to create (since it already does most of the leg work for this in Factory.Factory()), but the simplest way would be to just change the conditions for the DetectX11() call to be made.

HTH,

Roy

Windows DPI scaling is causing the GameWindow size to scale, which is correct, but there is no way to find out the unscaled size of the GameWindow.

Reported Width and Height of GameWindow is scaled by the Windows DPI scaling.
This is correct, but there is no way to know what the non-scaled Width and Height are set to. This is useful when saving the window size and position.

Example: Create a window with size 640 by 480. Windows desktop DPI scaling is set to 150%. GameWindow width is 960 and height is 720 which is correct. If we save those values and use them upon next start, the window will grow another 150% in size.

Maybe there could be new properties such as UnscaledWidth and UnscaledHeight.

GLControl flicker when covered by window

Originally posted at http://www.opentk.com/node/3456

"I have been working for 2 years with 2010 opengl version with no problems. I have updated to 2013 and now, with ATI, if a tooltip or child window overlaps the opengl context, that dirty region is repainted, but not the rest! Any Idea?"

The issue appears to be caused by d9afed2 and disappears when reverted.

However, according to MSDN, the changes brought in by this commit are suggested or required for OpenGL on Windows. From http://msdn.microsoft.com/en-us/library/windows/desktop/dd369049(v=vs.85).aspx

"An OpenGL window has its own pixel format. Because of this, only device contexts retrieved for the client area of an OpenGL window are allowed to draw into the window. As a result, an OpenGL window should be created with the WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles. Additionally, the window class attribute should not include the CS_PARENTDC style."

Which means that according to the official documentation, this commit is actually correct.

More information about the impact of this change is required:

  • is this issue specific to Ati cards, or does it also appear on Nvidia / Intel?
  • is it possible that this limitation was relaxed on Vista+ (due to the DWM)? If we revert this commit, do we still get correct behavior on WinXP?

OpenTK-develop detect OpenGL version as 1.1.0 and renderer GDI Generic

I downloaded this version to check KeyDown and KeyUp overriding and everything works fine, great. The problem is that to make a diagnosis of OpenGL (examples) I indicates an incorrect version of the OpenGL renderer.

Show this:
Vendor: Microsoft Corporation
Renderer: GDI Generic
GL Version: 1.1.0

and an earlier version of OpenTK shows this:

Vendor: ATI Technologies Inc.
Renderer: ATI Radeon HD 3800 Series
GL Version: 3.1.11672 Compatibility Profile Context

Output debug window:

GraphicsMode.Default = Index: , Color: 32 (8888), Depth: 16, Stencil: 0, Samples: 0, Accum: 0 (0000), Buffers: 2, Stereo: False
Primera excepción del tipo 'System.DllNotFoundException' en OpenTK.dll
SDL2 init failed with exception: System.DllNotFoundException: No se puede cargar el archivo DLL 'SDL2.dll': No se puede encontrar el módulo especificado. (Excepción de HRESULT: 0x8007007E)
en OpenTK.Platform.SDL2.SDL.WasInit(SystemFlags flags)
en OpenTK.Configuration.DetectSdl2() en c:\Users\Miguel\Downloads\opentk-develop\Source\OpenTK\Configuration.cs:línea 207
SDL2 is not supported
Detected configuration: Windows / .Net
Loaded opengl32.dll: 1491206144
SetProcessDPIAware() returned True
Primera excepción del tipo 'System.DllNotFoundException' en OpenTK.dll
DisplayDevice 1 (primary) supports 90 resolutions.
Creating GraphicsContext.
GraphicsMode: Index: , Color: 32 (8888), Depth: 16, Stencil: 0, Samples: 0, Accum: 0 (0000), Buffers: 2, Stereo: False
IWindowInfo: Windows.WindowInfo: Handle 1639338, Parent (Windows.WindowInfo: Handle 1835732, Parent (null))
GraphicsContextFlags: Default
Requested version: 1.0
[WGL] Creating temporary context to load extensions
Retrieving ARB pixel formats.... failed.
Device context: -1157556890
Retrieving PFD pixel formats...
Setting pixel format... 38
Load extensions for OpenTK.Platform.Windows.Wgl... 0 extensions loaded in 4 ms.
OpenGL will be bound to window:1639338 on thread:8
Retrieving ARB pixel formats.... failed.
Device context: 1392580118
Retrieving PFD pixel formats...
Setting pixel format... 38
Falling back to GL2... success! (id: 65537)
Destroying window: Windows.WindowInfo: Handle 655888, Parent (null)
Load extensions for OpenTK.Platform.Windows.Wgl... 0 extensions loaded in 0 ms.
Load extensions for OpenTK.Platform.Windows.Wgl... 0 extensions loaded in 0 ms.
Bindings loaded in 78.6074 ms.
Entering main loop.
Destroying window: Windows.WindowInfo: Handle 1835732, Parent (null)
Disposing context 65537.
El subproceso 'vshost.RunParkingWindow' (0x78c) terminó con código 0 (0x0).
El subproceso '' (0x5d0) terminó con código 0 (0x0).
OpenTK.Platform.Factory+UnsupportedPlatform leaked, did you forget to call Dispose()?
OpenTK.Platform.Windows.WinFactory leaked, did you forget to call Dispose()?
OpenTK.Toolkit leaked, did you forget to call Dispose()?
OpenTK.Platform.Factory leaked, did you forget to call Dispose()?
El programa '[6124] Test2.vshost.exe: Administrado (v4.0.30319)' terminó con código 0 (0x0).

`GL.GetActiveUniform` truncating name to 16 characters in v1.1

I recently swapped out 1.0 for 1.1-rc1 (2014-01-15). All was well aside from one odd issue which worked without any errors in 1.0.

The problem is with the overload of GL.GetActiveUniform that accepts a StringBuilder. Usage was like this:

int len, size;
ActiveUniformType type;
var sb = new StringBuilder();
GL.GetActiveUniform(programId, uniformIndex, 256, out len, out size, out type, sb);
// do something with sb.ToString()

In 1.0, this worked fine for all my uniforms. But in 1.1, uniform names that were longer than 16 characters were getting truncated to 16 characters in length, even if I set the buffer size parameter to 64 or 256. The overload that just returns the name as a string works correctly.

I have been able to replicate the issue in a standalone example (see below). In 1.1 (and develop @ 63dd459), the output is:

uni4
uni4
uniformLen16Char
uniformLen16Char
uniformLength18C
uniformLength18Chr
uniformThatIs29C
uniformThatIs29CharactersLong

For each uniform in the shader, I'm using the two different overloads to extract the name. First, the StringBuilder version, and second, the overload that returns a string. Notice that the uniform names are truncated on the last two names which are longer than 16 characters. Not only that, but the value of the returned length variable is the correct (untruncated) length of the name.

The 1.0 output looks like this:

uni4
uni4
uniformLen16Char
uniformLen16Char
uniformLength18Chr
uniformLength18Chr
uniformThatIs29CharactersLong
uniformThatIs29CharactersLong

Full replication code:

using System;
using System.Diagnostics;
using System.Text;
using OpenTK.Graphics.OpenGL;

namespace OpenTK.ActiveUniformTest
{
    static class Program
    {
        public class TestWindow : GameWindow
        {
            private const string Vertex = @"#version 100

                uniform vec4 uni4;
                uniform vec4 uniformLen16Char;
                uniform vec4 uniformLength18Chr;
                uniform vec4 uniformThatIs29CharactersLong;

                void main() {
                    gl_Position = uni4 + uniformLen16Char + uniformLength18Chr + uniformThatIs29CharactersLong;
                }";

            private const string Fragment = "#version 100\nvoid main() { gl_FragColor = vec4(1,1,1,1); }";

            private int CreateShader(ShaderType type, string source)
            {
                var id = GL.CreateShader(type);
                GL.ShaderSource(id, source);
                GL.CompileShader(id);
                return id;
            }

            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                var id = GL.CreateProgram();
                GL.AttachShader(id, CreateShader(ShaderType.VertexShader, Vertex));
                GL.AttachShader(id, CreateShader(ShaderType.FragmentShader, Fragment));
                GL.LinkProgram(id);
                GL.UseProgram(id);

                int uniformCount;
                GL.GetProgram(id, ProgramParameter.ActiveUniforms, out uniformCount);
                for (var i = 0; i < uniformCount; i++)
                {
                    int len, size;
                    ActiveUniformType type;
                    var sb = new StringBuilder();

                    // bufSize is set to 64, so all 4 uniform names should fit
                    GL.GetActiveUniform(id, i, 64, out len, out size, out type, sb);
                    Debug.WriteLine(sb.ToString());

                    var name = GL.GetActiveUniform(id, i, out size, out type);
                    Debug.WriteLine(name);
                }
            }
        }

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            using (var window = new TestWindow()) window.Run();
        }
    }
}

GraphicsModeException when creating GLControl on X11

Using WinForms GLControl on Linux fails with:

OpenTK.Graphics.GraphicsModeException: Invalid or unsupported GraphicsMode.
  at OpenTK.X11GLControl..ctor (OpenTK.Graphics.GraphicsMode mode, System.Windows.Forms.Control control) [0x0003b] in /home/parallels/opentk/Source/GLControl/X11GLControl.cs:76 
  at OpenTK.GLControlFactory.CreateGLControl (OpenTK.Graphics.GraphicsMode mode, System.Windows.Forms.Control control) [0x00062] in /home/parallels/opentk/Source/GLControl/GLControlFactory.cs:49 
  at OpenTK.GLControl.OnHandleCreated (System.EventArgs e) [0x0004c] in /home/parallels/opentk/Source/GLControl/GLControl.cs:192 
  at System.Windows.Forms.Control.WmCreate (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ContainerControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.UserControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00000] in <filename unknown>:0 
OpenTK.Graphics.GraphicsContextMissingException: No context is current in the calling thread (ThreadId: 1).
  at OpenTK.Graphics.OpenGL.ErrorHelper..ctor (IGraphicsContext context) [0x00006] in /home/parallels/opentk/Source/OpenTK/Graphics/OpenGL/ErrorHelper.cs:61 
  at OpenTK.Graphics.OpenGL.GL.GetString (StringName name) [0x00000] in /home/parallels/opentk/Source/OpenTK/Graphics/OpenGL/GL.cs:83497 
  at Examples.WinForms.GameLoopForm.OnLoad (System.EventArgs e) [0x00063] in /home/parallels/opentk/Source/Examples/OpenTK/GLControl/GLControlGameLoop.cs:50 
  at System.Windows.Forms.Form.OnLoadInternal (System.EventArgs e) [0x00000] in <filename unknown>:0 

Tested on Ubuntu 12.04. Original report here: http://www.opentk.com/node/3472

Keyboard sticks

From http://www.opentk.com/node/3552
++ Appears to be a bug in OpenTK (when not using SDL2)

Using this to get the keyboard state:

                CurrentKeyboard = Keyboard.GetState();

Followed by a simple keyboard check like this:

                if (CurrentKeyboard.IsKeyDown(Key.Left))

(Both in the UpdateFrame method, definitely firing at 60 FPS) (I triplechecked to make sure the code fires with lots of debug output)

It generally works out fine, but sometimes the keyboard suddenly locks into one state. It will either assume the Left key is held down constantly or released constantly, regardless of it's real state.
Its sticking seems to be unrelated to any event I can identify: The window remains focused, no keys are newly pressed/release when it occurs, ...
It sometimes is stuck right at startup, sometimes it's a few seconds-minutes into running the application, sometimes it doesn't appear to stick at all.

Restarting the program un-sticks the keys.
Keys don't stick in any other programs...

EDIT: Also, the KeyPress event fires exactly as it should, clearly not effected by this bug. I guess, worst case scenario, I could try to use Key events to build my own Keyboard object... but that seems like extreme overkill.

I'm 99.9% sure everything I'm doing is correct (This is too simple + the randomness implies external causes) - is there a different way I should be reading the keyboard state, or is there an issue with OpenTK's keyboard handling, is there some setting that would bug this, or is there some driver I should be updating, it's vaguely possibly my keyboard configuration could be switched around by my OS - would that cause this, ...?
Only tested/confirmed on my Windows 7 PC (sufficient RAM / CPU power to not be relevant, AMD Radeon 7750 graphics card, ...)

[Graphics] Unicode characters in GL.ShaderSource

Originally reported here: http://www.opentk.com/node/1332

Starting with OpenGL 4.2, shaders can be encoded as UTF-8 strings. According to the GLSL spec, non-ASCII characters are only allowed in comments.

OpenTK currently marshals strings as ASCII, either through automatic marshaling (versions <= 1.0) or through manual marshaling (versions >= 1.1-beta3). The relevant code resides in https://github.com/opentk/opentk/blob/develop/Source/OpenTK/BindingsBase.cs#L153

Proposed solution:

  1. use the pointer overload of Encoding.UTF8.GetBytes() instead of Marshal.PtrToStringAnsi
  2. test that this works on all platforms (including mobile), using both ASCII and non-ASCII shaders
  3. measure performance impact
  4. if impact is significant, search for alternative solutions (e.g. strip/replace multibyte chars, or provide byte[] overloads and have the application perform the necessary marshaling)

Note that strings passed to GL.ShaderSource et al must not contain Byte Order Marks (BOMs). If they do, shader compilation will fail at runtime.

OpenGL ES error on Windows: Could not create GL context: The operation completed successfully

I tried the latest version and Simple ES 2.0 in OpenTK.Examples does not work because of some runtime exception:

Exception occured in example Examples.Tutorial.SimpleES20Window: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> OpenTK.Graphics.GraphicsContextException: Could not create GL context: The operation completed successfully.

   at OpenTK.Platform.SDL2.Sdl2GraphicsContext..ctor(GraphicsMode mode, IWindowInfo win, IGraphicsContext shareContext, Int32 major, Int32 minor, GraphicsContextFlags flags) in d:\dev\opentk-master\Source\OpenTK\Platform\SDL2\Sdl2GraphicsContext.cs:line 72
   at OpenTK.Platform.SDL2.Sdl2Factory.CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, Boolean directRendering, Int32 major, Int32 minor, GraphicsContextFlags flags) in d:\dev\opentk-master\Source\OpenTK\Platform\SDL2\Sdl2Factory.cs:line 71
   at OpenTK.Graphics.GraphicsContext..ctor(GraphicsMode mode, IWindowInfo window, Int32 major, Int32 minor, GraphicsContextFlags flags) in d:\dev\opentk-master\Source\OpenTK\Graphics\GraphicsContext.cs:line 141
   at OpenTK.GameWindow..ctor(Int32 width, Int32 height, GraphicsMode mode, String title, GameWindowFlags options, DisplayDevice device, Int32 major, Int32 minor, GraphicsContextFlags flags, IGraphicsContext sharedContext) in d:\dev\opentk-master\Source\OpenTK\GameWindow.cs:line 220
   at OpenTK.GameWindow..ctor(Int32 width, Int32 height, GraphicsMode mode, String title, GameWindowFlags options, DisplayDevice device, Int32 major, Int32 minor, GraphicsContextFlags flags) in d:\dev\opentk-master\Source\OpenTK\GameWindow.cs:line 180
   at Examples.Tutorial.SimpleES20Window..ctor(GraphicsContextFlags flags) in d:\dev\opentk-master\Source\Examples\OpenGLES\2.0\SimpleWindow20.cs:line 26
   at Examples.Tutorial.SimpleES20Window.Main() in d:\dev\opentk-master\Source\Examples\OpenGLES\2.0\SimpleWindow20.cs:line 118
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Examples.Program.LaunchExample(String type) in d:\dev\opentk-master\Source\Examples\Main.cs:line 81

OS: Windows 8 x64
.NET version: N > 4.5 (I don't where is that information exactly, but 4.5 is the default version as far as I know)
Graphics Chipset: AMD Radeon HD 7800 Series
x64 DLLs copied to the directory with binaries

Let me know if you need more information.

Information about Mono.Cecil in Dependencies

Hi, I'm trying to update OpenTK in Fedora to recent rc version. However, we cannot ship precompiled binaries and so I need to compile Mono.Cecil as well. However, if I build the latest release form git (0.9.5), OpenTK doesn't build against it:

+ xbuild OpenTK.sln /p:Configuration=Release
XBuild Engine Version 2.10.8.0
Mono, Version 2.10.8.0
Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2011.

Build started 1/27/2014 10:20:43 PM.
__________________________________________________
Project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/OpenTK.sln" (default target(s)):
    Target ValidateSolutionConfiguration:
        Building solution configuration "Release|Any CPU".
    Target Build:
        Project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Bind/Generator.Bind.csproj" (default target(s)):
            Target PrepareForBuild:
                Configuration: Release Platform: AnyCPU
                Created directory "../../Binaries/Tools/Release/"
                Created directory "obj/Release/"
            Target GenerateSatelliteAssemblies:
            No input files were specified for target GenerateSatelliteAssemblies, skipping.
            Target CoreCompile:
                Tool /usr/bin/gmcs execution started with arguments: /noconfig /delaysign- /debug- /keyfile:../../OpenTK.snk /optimize+ /out:obj/Release/Bind.exe ../GlobalAssemblyInfo.cs CppSpecWriter.cs CSharpSpecWriter.cs FuncProcessor.cs GL2/GL4Generator.cs IBind.cs JavaSpecWriter.cs Main.cs DocProcessor.cs Settings.cs BindStreamWriter.cs EnumProcessor.cs Utilities.cs ISpecReader.cs ISpecWriter.cs Properties/AssemblyInfo.cs CL/CLGenerator.cs GL2/Generator.cs Structures/Type.cs Structures/Function.cs Structures/Constant.cs Structures/Enum.cs Structures/Delegate.cs Structures/Parameter.cs Structures/FlowDirection.cs ES/ESGenerator.cs XmlSpecReader.cs ES/ES2Generator.cs ES/ES3Generator.cs /target:exe /define:TRACE /reference:/usr/lib/mono/2.0/System.dll /reference:/usr/lib/mono/2.0/System.Xml.dll /reference:/usr/lib/mono/2.0/System.Xml.Linq.dll /reference:/usr/lib/mono/2.0/System.Core.dll /warn:4
: error CS2001: Source file `../GlobalAssemblyInfo.cs' could not be found
            Task "Csc" execution -- FAILED
            Done building target "CoreCompile" in project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Bind/Generator.Bind.csproj".-- FAILED
        Done building project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Bind/Generator.Bind.csproj".-- FAILED
        Project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Converter/Generator.Convert.csproj" (default target(s)):
            Target PrepareForBuild:
                Configuration: Release Platform: AnyCPU
                Created directory "obj/Release/"
            Target GenerateSatelliteAssemblies:
            No input files were specified for target GenerateSatelliteAssemblies, skipping.
            Target CoreCompile:
                Tool /usr/bin/gmcs execution started with arguments: /noconfig /delaysign- /debug- /keyfile:../../OpenTK.snk /optimize+ /out:obj/Release/Convert.exe ../GlobalAssemblyInfo.cs Main.cs Options.cs ESCLParser.cs Parser.cs Properties/AssemblyInfo.cs GLParser.cs GLXmlParser.cs /target:exe /define:TRACE /reference:/usr/lib/mono/2.0/System.dll /reference:/usr/lib/mono/2.0/System.Xml.dll /reference:/usr/lib/mono/2.0/System.Xml.Linq.dll /reference:/usr/lib/mono/2.0/System.Core.dll /warn:4
: error CS2001: Source file `../GlobalAssemblyInfo.cs' could not be found
            Task "Csc" execution -- FAILED
            Done building target "CoreCompile" in project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Converter/Generator.Convert.csproj".-- FAILED
        Done building project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Converter/Generator.Convert.csproj".-- FAILED
        Project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Build.UpdateVersion/Build.UpdateVersion.csproj" (default target(s)):
            Target PrepareForBuild:
                Configuration: Release Platform: AnyCPU
                Created directory "obj/Release/"
            Target GenerateSatelliteAssemblies:
            No input files were specified for target GenerateSatelliteAssemblies, skipping.
            Target CoreCompile:
                Tool /usr/bin/gmcs execution started with arguments: /noconfig /optimize+ /out:obj/Release/Build.UpdateVersion.exe Program.cs /target:exe /define:TRACE /reference:/usr/lib/mono/2.0/System.dll /warn:4
            Target DeployOutputFiles:
                Copying file from '/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Build.UpdateVersion/obj/Release/Build.UpdateVersion.exe' to '/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Binaries/Tools/Release/Build.UpdateVersion.exe'
            Target AfterBuild:
                Executing: mono ../../Binaries/Tools/Release//Build.UpdateVersion.exe
                API compatibility key: 1.1
                Build date: 2014-01-27
        Done building project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Build.UpdateVersion/Build.UpdateVersion.csproj".
        Project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Generator.Rewrite/Generator.Rewrite.csproj" (default target(s)):
            Target PrepareForBuild:
                Configuration: Release Platform: AnyCPU
                Created directory "obj/Release/"
            Target GenerateSatelliteAssemblies:
            No input files were specified for target GenerateSatelliteAssemblies, skipping.
            Target CoreCompile:
                Tool /usr/bin/gmcs execution started with arguments: /noconfig /debug:full /keyfile:../../OpenTK.snk /optimize+ /out:obj/Release/Rewrite.exe Program.cs Properties/AssemblyInfo.cs /target:exe /define:TRACE /platform:AnyCPU /reference:/usr/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll /reference:/usr/lib/mono/gac/Mono.Cecil.Mdb/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Mdb.dll /reference:/usr/lib/mono/gac/Mono.Cecil.Pdb/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Pdb.dll /reference:/usr/lib/mono/gac/Mono.Cecil.Rocks/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Rocks.dll /reference:/usr/lib/mono/2.0/System.dll /reference:/usr/lib/mono/2.0/System.Core.dll /warn:4
Program.cs(69,26): error CS0266: Cannot implicitly convert type `Mono.Cecil.Pdb.PdbReaderProvider' to `Mono.Cecil.Cil.ISymbolReaderProvider'. An explicit conversion exists (are you missing a cast?)
Program.cs(73,26): error CS0266: Cannot implicitly convert type `Mono.Cecil.Mdb.MdbReaderProvider' to `Mono.Cecil.Cil.ISymbolReaderProvider'. An explicit conversion exists (are you missing a cast?)
Program.cs(94,55): error CS0584: Internal compiler error: Method not found: 'Mono.Cecil.Rocks.Functional.Y'.
Program.cs(115,80): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `MakeArrayType' and the best extension method overload `Mono.Cecil.Rocks.TypeReferenceRocks.MakeArrayType(this Mono.Cecil.TypeReference)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil.Rocks/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Rocks.dll (Location of the symbol related to previous error)
Program.cs(115,80): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeReference'
Program.cs(156,50): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `GetConstructors' and the best extension method overload `Mono.Cecil.Rocks.TypeDefinitionRocks.GetConstructors(this Mono.Cecil.TypeDefinition)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil.Rocks/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Rocks.dll (Location of the symbol related to previous error)
Program.cs(156,50): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeDefinition'
Program.cs(156,17): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
Program.cs(157,53): error CS0841: A local variable `rewritten_constructor' cannot be used before it is declared
Program.cs(157,33): error CS1502: The best overloaded method match for `Mono.Cecil.CustomAttribute.CustomAttribute(Mono.Cecil.MethodReference)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll (Location of the symbol related to previous error)
Program.cs(157,33): error CS1503: Argument `#1' cannot convert `object' expression to type `Mono.Cecil.MethodReference'
Program.cs(279,18): error CS1928: Type `Mono.Cecil.Cil.MethodBody' does not contain a member `OptimizeMacros' and the best extension method overload `Mono.Cecil.Rocks.MethodBodyRocks.OptimizeMacros(this Mono.Cecil.Cil.MethodBody)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil.Rocks/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Rocks.dll (Location of the symbol related to previous error)
Program.cs(279,18): error CS1929: Extension method instance type `Mono.Cecil.Cil.MethodBody' cannot be converted to `Mono.Cecil.Cil.MethodBody'
Program.cs(296,116): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `GetMethods' and the best extension method overload `Mono.Cecil.Rocks.TypeDefinitionRocks.GetMethods(this Mono.Cecil.TypeDefinition)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil.Rocks/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Rocks.dll (Location of the symbol related to previous error)
Program.cs(296,116): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeDefinition'
Program.cs(296,64): error CS1502: The best overloaded method match for `Mono.Cecil.ModuleDefinition.Import(System.Type)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll (Location of the symbol related to previous error)
Program.cs(296,64): error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type'
Program.cs(296,21): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
Program.cs(304,113): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `GetConstructors' and the best extension method overload `Mono.Cecil.Rocks.TypeDefinitionRocks.GetConstructors(this Mono.Cecil.TypeDefinition)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil.Rocks/0.9.5.0__0738eb9f132ed756/Mono.Cecil.Rocks.dll (Location of the symbol related to previous error)
Program.cs(304,113): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeDefinition'
Program.cs(304,61): error CS1502: The best overloaded method match for `Mono.Cecil.ModuleDefinition.Import(System.Type)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll (Location of the symbol related to previous error)
Program.cs(304,61): error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type'
Program.cs(304,21): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
Program.cs(311,43): error CS0841: A local variable `intptr_to_voidpointer' cannot be used before it is declared
Program.cs(311,24): error CS1502: The best overloaded method match for `Mono.Cecil.Cil.ILProcessor.Emit(Mono.Cecil.Cil.OpCode, Mono.Cecil.TypeReference)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll (Location of the symbol related to previous error)
Program.cs(311,24): error CS1503: Argument `#2' cannot convert `object' expression to type `Mono.Cecil.TypeReference'
Program.cs(312,45): error CS0841: A local variable `string_constructor' cannot be used before it is declared
Program.cs(312,24): error CS1502: The best overloaded method match for `Mono.Cecil.Cil.ILProcessor.Emit(Mono.Cecil.Cil.OpCode, Mono.Cecil.TypeReference)' has some invalid arguments
                /usr/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll (Location of the symbol related to previous error)
Program.cs(312,24): error CS1503: Argument `#2' cannot convert `object' expression to type `Mono.Cecil.TypeReference'
Program.cs(620,29): error CS1729: The type `Mono.Cecil.CallSite' does not contain a constructor that takes `1' arguments
                /usr/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll (Location of the symbol related to previous error)
            Task "Csc" execution -- FAILED
            Done building target "CoreCompile" in project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Generator.Rewrite/Generator.Rewrite.csproj".-- FAILED
        Done building project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Generator.Rewrite/Generator.Rewrite.csproj".-- FAILED
    Task "MSBuild" execution -- FAILED
    Done building target "Build" in project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/OpenTK.sln".-- FAILED
Done building project "/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/OpenTK.sln".-- FAILED

Build FAILED.
Errors:

/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/OpenTK.sln (default targets) ->
(Build target) ->
/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Bind/Generator.Bind.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->

    : error CS2001: Source file `../GlobalAssemblyInfo.cs' could not be found

/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/OpenTK.sln (default targets) ->
(Build target) ->
/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Converter/Generator.Convert.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->

    : error CS2001: Source file `../GlobalAssemblyInfo.cs' could not be found

/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/OpenTK.sln (default targets) ->
(Build target) ->
/home/churchyard/rpmbuild/fedora-scm/OpenTK/opentk-1.1-rc1/Source/Generator.Rewrite/Generator.Rewrite.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->

    Program.cs(69,26): error CS0266: Cannot implicitly convert type `Mono.Cecil.Pdb.PdbReaderProvider' to `Mono.Cecil.Cil.ISymbolReaderProvider'. An explicit conversion exists (are you missing a cast?)
    Program.cs(73,26): error CS0266: Cannot implicitly convert type `Mono.Cecil.Mdb.MdbReaderProvider' to `Mono.Cecil.Cil.ISymbolReaderProvider'. An explicit conversion exists (are you missing a cast?)
    Program.cs(94,55): error CS0584: Internal compiler error: Method not found: 'Mono.Cecil.Rocks.Functional.Y'.
    Program.cs(115,80): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `MakeArrayType' and the best extension method overload `Mono.Cecil.Rocks.TypeReferenceRocks.MakeArrayType(this Mono.Cecil.TypeReference)' has some invalid arguments
    Program.cs(115,80): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeReference'
    Program.cs(156,50): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `GetConstructors' and the best extension method overload `Mono.Cecil.Rocks.TypeDefinitionRocks.GetConstructors(this Mono.Cecil.TypeDefinition)' has some invalid arguments
    Program.cs(156,50): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeDefinition'
    Program.cs(156,17): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
    Program.cs(157,53): error CS0841: A local variable `rewritten_constructor' cannot be used before it is declared
    Program.cs(157,33): error CS1502: The best overloaded method match for `Mono.Cecil.CustomAttribute.CustomAttribute(Mono.Cecil.MethodReference)' has some invalid arguments
    Program.cs(157,33): error CS1503: Argument `#1' cannot convert `object' expression to type `Mono.Cecil.MethodReference'
    Program.cs(279,18): error CS1928: Type `Mono.Cecil.Cil.MethodBody' does not contain a member `OptimizeMacros' and the best extension method overload `Mono.Cecil.Rocks.MethodBodyRocks.OptimizeMacros(this Mono.Cecil.Cil.MethodBody)' has some invalid arguments
    Program.cs(279,18): error CS1929: Extension method instance type `Mono.Cecil.Cil.MethodBody' cannot be converted to `Mono.Cecil.Cil.MethodBody'
    Program.cs(296,116): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `GetMethods' and the best extension method overload `Mono.Cecil.Rocks.TypeDefinitionRocks.GetMethods(this Mono.Cecil.TypeDefinition)' has some invalid arguments
    Program.cs(296,116): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeDefinition'
    Program.cs(296,64): error CS1502: The best overloaded method match for `Mono.Cecil.ModuleDefinition.Import(System.Type)' has some invalid arguments
    Program.cs(296,64): error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type'
    Program.cs(296,21): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
    Program.cs(304,113): error CS1928: Type `Mono.Cecil.TypeDefinition' does not contain a member `GetConstructors' and the best extension method overload `Mono.Cecil.Rocks.TypeDefinitionRocks.GetConstructors(this Mono.Cecil.TypeDefinition)' has some invalid arguments
    Program.cs(304,113): error CS1929: Extension method instance type `Mono.Cecil.TypeDefinition' cannot be converted to `Mono.Cecil.TypeDefinition'
    Program.cs(304,61): error CS1502: The best overloaded method match for `Mono.Cecil.ModuleDefinition.Import(System.Type)' has some invalid arguments
    Program.cs(304,61): error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type'
    Program.cs(304,21): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
    Program.cs(311,43): error CS0841: A local variable `intptr_to_voidpointer' cannot be used before it is declared
    Program.cs(311,24): error CS1502: The best overloaded method match for `Mono.Cecil.Cil.ILProcessor.Emit(Mono.Cecil.Cil.OpCode, Mono.Cecil.TypeReference)' has some invalid arguments
    Program.cs(311,24): error CS1503: Argument `#2' cannot convert `object' expression to type `Mono.Cecil.TypeReference'
    Program.cs(312,45): error CS0841: A local variable `string_constructor' cannot be used before it is declared
    Program.cs(312,24): error CS1502: The best overloaded method match for `Mono.Cecil.Cil.ILProcessor.Emit(Mono.Cecil.Cil.OpCode, Mono.Cecil.TypeReference)' has some invalid arguments
    Program.cs(312,24): error CS1503: Argument `#2' cannot convert `object' expression to type `Mono.Cecil.TypeReference'
    Program.cs(620,29): error CS1729: The type `Mono.Cecil.CallSite' does not contain a constructor that takes `1' arguments

     0 Warning(s)
     32 Error(s)

Time Elapsed 00:00:01.6459860

What version of Mono.Cecil is in Dependencies folder? What Configuration is used to build it (I've used net_4_0_Release)?

Forgive me, if there is a way to find out right from the shipped dll, I'm not very good with mono :(

Thanks for help.

GraphicsModeException when creating GLControl on Windows

This is a same issue as in issue#27 only for windows. On my old laptop with a NVIDEA graphics card creating a GLControl with anti-aliasing creates an Exception and Program stops. Same without anti-aliasing works fine. So I guess you need to do the mode relaxation trick you introduced in linux as well on windows. Not all drivers find the best mode on their own.

I tried also to catch the exception in the new GLControl(mode), which failed because of the lazy creation I think. Otherwise I could use a fallback on my own.

Some users seem to get even worse problems:

Problemsignatur:
Problemereignisname:    APPCRASH
Anwendungsname: RepetierHost.exe
Anwendungsversion:  1.0.0.0
Anwendungszeitstempel:  52cac230
Fehlermodulname:    ig4icd32.dll
Fehlermodulversion: 8.14.10.1930
Fehlermodulzeitstempel: 4aba6fc2
Ausnahmecode:   c0000005
Ausnahmeoffset: 0006605e
Betriebsystemversion:   6.1.7601.2.1.0.256.1
Gebietsschema-ID:   1031
Zusatzinformation 1:    0a9e
Zusatzinformation 2:    0a9e372d3b4ad19135b953a78882e789
Zusatzinformation 3:    0a9e
Zusatzinformation 4:    0a9e372d3b4ad19135b953a78882e789

This report was for 1.1beta4 and it seems to be a intel graphic card. OpenTK 1.0 worked well on the same computer, if that helps. Unfortunately I have no computer with that card on my own to verify, but quite some users seem to have:-( Also I do not understand much of these data, I guess you tried to use method not implemented in that driver?

Incorrect handling of IME messages

Originally reported here: http://www.opentk.com/node/2479

When using specific Nvidia GPUs and drivers, it appears that wglGetProcAddress takes a long time to return, to the point were loading all entry points takes time in the order seconds.

This issue does not appear to affect the SDL2 backend, or AMD/Intel GPUs. Upgrading Nvidia drivers has been known to help.

We need to find what is causing this issue and fix it. For this, we need the help of someone with a system that reproduces the problem.

CreateDummyContext throws an exception in 1.1 if there is no OpenTK context before

In 1.0, I used the method CreateDummyContext to share an external OpenGL context with OpenTK ones before any OpenTK context was created.

Now it does not work anymore, the method throws this exception:

A problem occurred: System.PlatformNotSupportedException: Operation is not supported on this platform.
at OpenTK.Platform.Utilities.CreateGetAddress()
at OpenTK.Graphics.GraphicsContext.CreateDummyContext(ContextHandle handle)

If an OpenTK context is created before the call to CreateDummyContext, everything works fine.

ArgumentOutOfRangeException when time = 0 (Examples.Tutorial.ThreadedRendering)

occurs in OpenTK develop version, only checked in window and occurs only in release version.

Exception occured in example Examples.Tutorial.ThreadedRendering: System.Reflection.TargetInvocationException: Se produjo una excepción en el destino de la invocación. ---> System.ArgumentOutOfRangeException: El argumento especificado está fuera del intervalo de valores válidos.
   en OpenTK.FrameEventArgs.set_Time(Double value) en c:\Users\Miguel\Downloads\opentk-develop\Source\OpenTK\FrameEventArgs.cs:línea 65
   en OpenTK.GameWindow.DispatchUpdateAndRenderFrame(Object sender, EventArgs e) en c:\Users\Miguel\Downloads\opentk-develop\Source\OpenTK\GameWindow.cs:línea 444
   en OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second) en c:\Users\Miguel\Downloads\opentk-develop\Source\OpenTK\GameWindow.cs:línea 415
   en OpenTK.GameWindow.Run() en c:\Users\Miguel\Downloads\opentk-develop\Source\OpenTK\GameWindow.cs:línea 350
   en Examples.Tutorial.ThreadedRendering.Main() en c:\Users\Miguel\Downloads\opentk-develop\Source\Examples\OpenTK\GameWindow\GameWindowThreaded.cs:línea 313
   --- Fin del seguimiento de la pila de la excepción interna ---
   en System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   en System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   en System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   en System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
   en Examples.Program.LaunchExample(String type) en c:\Users\Miguel\Downloads\opentk-develop\Source\Examples\Main.cs:línea 79

[X11] Mouse.SetPosition does not work when GameWindow.CursorVisible = false

Separate issue split from: #24 (comment)

In the following code, when the cursor hidden "CursorVisible = false" this is not maintained in the coordinates corresponding to the center of the window.

By contrast, when the cursor is visible "CursorVisible = true" everything works properly and keep the cursor centered in the window.

Using:
Mono 3.2.5
GTK+ 2.24.20
GTK# (2.12.0.0)

I use the installation 'OPT' of (Monodevelop + mono); see http://software.opensuse.org/download/package?project=home:tpokorra:mono&package=monodevelop-opt

using System;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;

namespace Examples.Tutorial
{
/// 
/// Demonstrates the GameWindow class.
/// 

public class SimpleWindow : GameWindow
{
public SimpleWindow() : base(800, 600)
{
   CursorVisible = false;
   Keyboard.KeyDown += Keyboard_KeyDown;
}

    #region Keyboard_KeyDown

    /// <summary>
    /// Occurs when a key is pressed.
    /// </summary>
    /// <param name="sender">The KeyboardDevice which generated this event.</param>
    /// <param name="e">The key that was pressed.</param>
    void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
    {
        if (e.Key == Key.Escape)
            this.Exit();

        if (e.Key == Key.F11)
        if (this.WindowState == WindowState.Fullscreen)
            this.WindowState = WindowState.Normal;
        else
            this.WindowState = WindowState.Fullscreen;
    }

    #endregion

    #region OnLoad

    /// <summary>
    /// Setup OpenGL and load resources here.
    /// </summary>
    /// <param name="e">Not used.</param>
    protected override void OnLoad(EventArgs e)
    {
        GL.ClearColor(Color.MidnightBlue);
    }

    #endregion

    #region OnResize

    /// <summary>
    /// Respond to resize events here.
    /// </summary>
    /// <param name="e">Contains information on the new GameWindow size.</param>
    /// <remarks>There is no need to call the base implementation.</remarks>
    protected override void OnResize(EventArgs e)
    {
        GL.Viewport(0, 0, Width, Height);

        GL.MatrixMode(MatrixMode.Projection);
        GL.LoadIdentity();
        GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
    }

    #endregion

    #region OnUpdateFrame

    /// <summary>
    /// Add your game logic here.
    /// </summary>
    /// <param name="e">Contains timing information.</param>
    /// <remarks>There is no need to call the base implementation.</remarks>
    protected override void OnUpdateFrame(FrameEventArgs e)
    {
        // Nothing to do!
        Point center = new Point(Width / 2, Height / 2);
        Point mousePos = PointToScreen(center);
        OpenTK.Input.Mouse.SetPosition(mousePos.X, mousePos.Y);
    }

    #endregion

    #region OnRenderFrame

    /// <summary>
    /// Add your game rendering code here.
    /// </summary>
    /// <param name="e">Contains timing information.</param>
    /// <remarks>There is no need to call the base implementation.</remarks>
    protected override void OnRenderFrame(FrameEventArgs e)
    {
        Title = "mouseX: " + Mouse.X + " mouseY: " + Mouse.Y;

        GL.Clear(ClearBufferMask.ColorBufferBit);

        GL.Begin(PrimitiveType.Triangles);

        GL.Color3(Color.MidnightBlue);
        GL.Vertex2(-1.0f, 1.0f);
        GL.Color3(Color.SpringGreen);
        GL.Vertex2(0.0f, -1.0f);
        GL.Color3(Color.Ivory);
        GL.Vertex2(1.0f, 1.0f);

        GL.End();

        this.SwapBuffers();
    }

    #endregion

    #region public static void Main()

    /// <summary>
    /// Entry point of this example.
    /// </summary>
    [STAThread]
    public static void Main()
    {
        using (SimpleWindow example = new SimpleWindow())
        {
            // Get the title and category  of this example using reflection.
            //Utilities.SetWindowTitle(example);
            example.Run(30.0, 0.0);
        }
    }

    #endregion
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.