• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By elect
      ok, so, we are having problems with our current mirror reflection implementation.
      At the moment we are doing it very simple, so for the i-th frame, we calculate the reflection vectors given the viewPoint and some predefined points on the mirror surface (position and normal).
      Then, using the least squared algorithm, we find the point that has the minimum distance from all these reflections vectors. This is going to be our virtual viewPoint (with the right orientation).
      After that, we render offscreen to a texture by setting the OpenGL camera on the virtual viewPoint.
      And finally we use the rendered texture on the mirror surface.
      So far this has always been fine, but now we are having some more strong constraints on accuracy.
      What are our best options given that:
      - we have a dynamic scene, the mirror and parts of the scene can change continuously from frame to frame
      - we have about 3k points (with normals) per mirror, calculated offline using some cad program (such as Catia)
      - all the mirror are always perfectly spherical (with different radius vertically and horizontally) and they are always convex
      - a scene can have up to 10 mirror
      - it should be fast enough also for vr (Htc Vive) on fastest gpus (only desktops)

      Looking around, some papers talk about calculating some caustic surface derivation offline, but I don't know if this suits my case
      Also, another paper, used some acceleration structures to detect the intersection between the reflection vectors and the scene, and then adjust the corresponding texture coordinate. This looks the most accurate but also very heavy from a computational point of view.

      Other than that, I couldn't find anything updated/exhaustive around, can you help me?
      Thanks in advance
    • By Enerjak
      protected void menuImage_ChildClick(Object sender, EventArgs e) { if(pbxPhoto.Image != null && sender is MenuItem) { MenuItem mi = (MenuItem)sender; pbxPhoto.SizeMode = modeMenuArray[mi.Index]; pbxPhoto.Invalidate(); } } I'm trying to make one click function to handle multiple menus. Using this code does not work when I click the menu buttons after the image is loaded in the picture box. Here is where I set the event handler of both menu items. 
      // // menuStretch // this.menuStretch.Name = "menuStretch"; this.menuStretch.Size = new System.Drawing.Size(152, 22); this.menuStretch.Text = "S&tretch to Fit"; this.menuStretch.Click += new System.EventHandler(this.menuImage_ChildClick); // // menuActual // this.menuActual.Name = "menuActual"; this.menuActual.Size = new System.Drawing.Size(152, 22); this.menuActual.Text = "&Actual Size"; this.menuActual.Click += new System.EventHandler(this.menuImage_ChildClick); Menu Stretch and Menu Actual are ToolStripMenuItems, which don't have an index variable as I've noticed. How do I get this to work? Otherwise I have to make a separate event function per menu item, which, depending on the amount of image properties, could be a a lot. 
    • By Dave Haylett
      Hi there,
      I need a simple(ish) MP3 player for my C# WPF project. Sound isn't a major player in my project, but I do need to be able to play a couple of MP3s at the same time (loaded in as Content).
      I'm currently using the standard MediaPlayer library just to get a placeholder in there, but it does not meet these requirements:
      * Looping - no matter what I try, there's always a split-second break in the sound when it comes to looping (a few of the sounds are short tune loops, and the brief pause when looping really stands out like a sore... ear...!)
      * Mixing - at times I need to play a couple of samples simultaneously, but I don't believe MediaPlayer can support this. Having said this I've not tried invoking more than one MediaPlayer class at the same time.
      Are there any suggestions? I've browsed through NuGet but I'm surprised I can't find anything really useful.
    • By Hitler!ewqe
      till now 
      i made almost perfect mouse selection unit 
      i mean rts style c# mouse scrtips 
      this works almost all of the warc3 game mouse function 
      now i want to unit to move with navmesh 
      please help me 
      this doesn work T.T 
      im so sorry guys i forgot if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
      this im so sorry 
    • By Francisco Tufr
      Hi everyone! I'm currently working on a series of books about 2D Shader Development.

      The idea is to synthesize a bunch of techniques that are specifically useful for 2D, even if they work on 3D as well.

      I released the first book last week. It's 4.99 on Amazon or free on the series website, https://www.2dshaders.com

      This is an independent initiative, I don't work for any publisher whatsoever. The contents of the books are the result of a 4-year span where I started teaching this in Argentina and USA, always making the workshop better. Now I'm expanding it to make more sense in book form.

      I'd love to hear your opinions on the idea and if you get the book let me know what you think.

      By the way, the examples are in Unity, but the concepts from the book should be easily transferable to any graphics api/engine.

      Hope you like it!
  • Advertisement
  • Advertisement

OpenGL C# Windows Forms and OpenTK (glControl)

Recommended Posts


I am working on a recent project and I have been learning how to code in C# using OpenGL libraries for some graphics. I have achieved some quite interesting things using TAO Framework writing in Console Applications, creating a GLUT Window. But my problem now is that I need to incorporate the Graphics in a Windows Form so I can relate the objects that I render with some .NET Controls.

To deal with this problem, I have seen in some forums that it's better to use OpenTK instead of TAO Framework, so I can use the glControl that OpenTK libraries offer. However, I haven't found complete articles, tutorials or source codes that help using the glControl or that may insert me into de OpenTK functions. Would somebody please share in this forum some links or files where I can find good documentation about this topic? Or may I use another library different of OpenTK?


Share this post

Link to post
Share on other sites

Seems you did not search enougth. I found THIS in the top 3 results from googel and it seems to be very very beginners friendly.

Ohterwise the native way round for GL in C# uses a window handle to generate the render target from. A Winforms control class has a property to grab its HWND Window Handle so you could pass that as IntPtr (or on the other side as void*) into some GL setup code. I did this a lot of times and it works regardless of the control you use.

To orevent flickering on frequent updates you need just to override some painting settings in your window

    ControlStyles.AllPaintingInWmPaint | 
    ControlStyles.UserPaint | 


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement