DarkLord84
11-13-2006, 04:21 PM
Hi
I'm completely new to OpenGL and I'm having some trouble trying to get some of the sample codes working.
I've been mainly using the website
http://nehe.gamedev.net
and I have been looking at the lessons and demos but I'm having some difficulty when I try to compile it with the command line.
I have the csgl.dll ,csgl.native.dll, csgl-base.dll and glut32.dll in my Windows\system folder and I also have the glut.h header in my include folder.
When I go to compile the lesson1 C# code it says "'CsGL' could not be found"
and the namespace 'OpenGLControl' could not be found.
I ran lesson two and it works fine.
Could some one please look at this code and tell what's wrong?
using System;
using System.Drawing;
using System.Windows.Forms;
using CsGL.OpenGL;
namespace Lesson1
{
public class OurView : OpenGLControl
{
public OurView(): base()
{
this.KeyDown += new KeyEventHandler(OurView_OnKeyDown);
}
protected void OurView_OnKeyDown(object Sender, KeyEventArgs kea)
{
//if escape was pressed exit the application
if (kea.KeyCode == Keys.Escape)
{
Application.Exit();
}
}
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GL.glLoadIdentity();
}
protected override void InitGLContext()
{
GL.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
GL.glClearDepth(1.0f); // Depth Buffer Setup
GL.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
GL.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
Size s = Size;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(45.0f, (double)s.Width /(double) s.Height, 0.1f, 100.0f);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
}
}
public class MainForm : System.Windows.Forms.Form // Will show us the OpenGL window
{
private Lesson1.OurView view;
public MainForm()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(640, 480);
this.Name = "MainForm";
this.Text = "NeHe's Lesson 1 in C# (by Joachim Rohde)";
this.view = new Lesson1.OurView(); // view
this.view.Parent = this;
this.view.Dock = DockStyle.Fill; // Will fill whole form
}
static void Main()
{
Application.Run(new MainForm());
}
}
}
Any help would be greatly appreciated, thanks
I'm completely new to OpenGL and I'm having some trouble trying to get some of the sample codes working.
I've been mainly using the website
http://nehe.gamedev.net
and I have been looking at the lessons and demos but I'm having some difficulty when I try to compile it with the command line.
I have the csgl.dll ,csgl.native.dll, csgl-base.dll and glut32.dll in my Windows\system folder and I also have the glut.h header in my include folder.
When I go to compile the lesson1 C# code it says "'CsGL' could not be found"
and the namespace 'OpenGLControl' could not be found.
I ran lesson two and it works fine.
Could some one please look at this code and tell what's wrong?
using System;
using System.Drawing;
using System.Windows.Forms;
using CsGL.OpenGL;
namespace Lesson1
{
public class OurView : OpenGLControl
{
public OurView(): base()
{
this.KeyDown += new KeyEventHandler(OurView_OnKeyDown);
}
protected void OurView_OnKeyDown(object Sender, KeyEventArgs kea)
{
//if escape was pressed exit the application
if (kea.KeyCode == Keys.Escape)
{
Application.Exit();
}
}
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GL.glLoadIdentity();
}
protected override void InitGLContext()
{
GL.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
GL.glClearDepth(1.0f); // Depth Buffer Setup
GL.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
GL.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
Size s = Size;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(45.0f, (double)s.Width /(double) s.Height, 0.1f, 100.0f);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
}
}
public class MainForm : System.Windows.Forms.Form // Will show us the OpenGL window
{
private Lesson1.OurView view;
public MainForm()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(640, 480);
this.Name = "MainForm";
this.Text = "NeHe's Lesson 1 in C# (by Joachim Rohde)";
this.view = new Lesson1.OurView(); // view
this.view.Parent = this;
this.view.Dock = DockStyle.Fill; // Will fill whole form
}
static void Main()
{
Application.Run(new MainForm());
}
}
}
Any help would be greatly appreciated, thanks