Читаю статью:
http://www.rsdn.ru/article/files/dotnet/OpenGLBase
Копирую оттуда
#region Imports
и пытаюсь просто нарисовать фон:
public GraphEngine()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
SetStyle(ControlStyles.ResizeRedraw, true);
PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR();
pfd.Initialize();
hDC = GetDC(Handle);
int i = ChoosePixelFormat(hDC, ref pfd);
SetPixelFormat(hDC, i, ref pfd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
glClearColor(1, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
wglDeleteContext(hRC);
hRC = IntPtr.Zero;
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// GraphEngine
//
this.Name = "GraphEngine";
this.Size = new System.Drawing.Size(80, 80);
this.SizeChanged += new System.EventHandler(this.GraphEngine_SizeChanged);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.GraphEngine_Paint);
}
#endregion
/// <summary>
/// We need to override this event
/// </summary>
/// <param name="pevent"></param>
protected override void OnPaintBackground(PaintEventArgs pevent)
{
// Do nothing to prevent erazing background by Windows
return;
}
private void GraphEngine_SizeChanged(object sender, System.EventArgs e)
{
//base.OnSizeChanged(e);
double Aspect = Width <= Height ? (double)Height/Width : (double)Width/Height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 1.5, 0.1, 10000.0);
glViewport(0, 0, Width, Height);
}
private void GraphEngine_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
glClear(GL_COLOR_BUFFER_BIT);
//SwapBuffers(hDC);
glFlush();
}
Он, зараза, фон не рисует, а хватает кусок экрана.
То же самое, если оставляю исходный код статьи
что не так, подскажите новичку!!!