adityatan's picture

OpenTK Example

Hi there,

I followed the very first example provided in the OpenTK manual. The data builds successfully; however as it runs, the glControl1 still come out white.

Below is the code. Please help. I'm pretty sure that I'm missing a setup step. Thanks.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

namespace Trial003
{
public partial class Form1 : Form
{
bool loaded = false;

public Form1()
{
InitializeComponent();
}

private void glControl1_Load(object sender, EventArgs e)
{
loaded = true;
GL.ClearColor(Color.SkyBlue);
}

private void glControl1_Paint(object sender, PaintEventArgs e)
{
if (!loaded)
return;
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
glControl1.SwapBuffers();
}
}
}


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hortus Longus's picture

Hi.

Errors from the past. :-) What OS and what version of OpenTK/OpenTK.GLControl you are using?

And, please:

if (code_listing)
{
  use the code-formatter (the 5th button for C#), right? ;-)
}
adityatan's picture

Hi there,

I used the latest OS and the latest version of OpenTK. I am using VS2008, by the way, in Windows 7 using Mac's Bootcamp.

Sorry, I don't get your last comment; I'm new :)

Thanks.

Hortus Longus's picture

Strange. Are you sure, do you have your glControl1_Paint connected to the paint event of glControl1? Please look three times. :-)

adityatan wrote:

Sorry, I don't get your last comment; I'm new :)

Means:
if you copy your code and past it here, it looks so:
private void glControl1_Load(object sender, EventArgs e)
{
loaded = true;
GL.ClearColor(Color.SkyBlue);
}
then, mark this code and press the button of your programming language and it looks so:

    private void glControl1_Load(object sender, EventArgs e)
    {
      loaded = true;
      GL.ClearColor(Color.SkyBlue);
    }

Agreed that it is better to read?