Jump to content


Newbie with a bit of difficulty


  • You cannot reply to this topic
1 reply to this topic

#1 DarkLord84

    New Member

  • Members
  • Pip
  • 1 posts

Posted 14 November 2006 - 12:21 AM

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

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 14 November 2006 - 02:56 AM

You might have to add a reference to the CsGL assembly to your project. In the Solution Explorer you should find a folder called References; right-click and choose Add Reference, then either find CsGL in the list or if it's not there, click Browse and navigate to the file.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users