Csharp Csgl error message

The following program is taken from  nehe tutorial C sharp using csgl.... It shows a error message in the statement
base.onsizechanged
could anyone solve this error
jsbsudhaAsked:
Who is Participating?
 
ikeworkConnect With a Mentor Commented:
did you download csgl from:

http://sourceforge.net/project/downloading.php?group_id=33241&use_mirror=ovh&filename=csgl.1.4.1.dll.zip&60279498

then unzip it and execute libinstall/install.bat

make sure CsGL-namespace is loaded into your project, if not add c:\windows\system32\csgl.dll to project
0
 
ikeworkCommented:
what error? can you paste it?
0
 
jsbsudhaAuthor Commented:
/* Lesson 05 of NeHe Productions in C#
   created by Sabine Felsinger*/

using System;
using System.Windows.Forms;
using System.Drawing;
using CsGL.OpenGL;

namespace lesson05
{
      public class OurView : OpenGLControl
      {
            public float rtri;                  // rtri is for rotating the pyramid
            public float rquad;                  // rquad is for rotating the quad

            public bool finished;

            public OurView() : base()
            {
                  this.KeyDown += new KeyEventHandler(OurView_OnKeyDown);
                  finished = false;
            }
            
            protected void OurView_OnKeyDown(object Sender, KeyEventArgs kea)
            {
                  //if escape was pressed exit the application
                  if (kea.KeyCode == Keys.Escape)
                  {
                        finished = true;
                  }
            }

            public override void glDraw()
            {
                  GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);      // Clear the Screen and the Depth Buffer
                  GL.glMatrixMode(GL.GL_MODELVIEW);            // Modelview Matrix
                  GL.glLoadIdentity();                              // reset the current modelview matrix
                  GL.glTranslatef(-1.5f,0.0f,-6.0f);            // move 1.5 Units left and 6 Units into the screen
                  GL.glRotatef(rtri,0.0f,1.0f,0.0f);            // rotate the Pyramid on it's Y-axis
                  rtri+=0.2f;                                                // rotation angle

                  GL.glBegin(GL.GL_TRIANGLES);                  // start drawing a triangle, always counterclockside (top-left-right)
                  GL.glColor3f(1.0f,0.0f,0.0f);                  // Red
                  GL.glVertex3f(0.0f,1.0f,0.0f);                  // Top of Triangle (Front)
                  GL.glColor3f(0.0f,1.0f,0.0f);                  // green
                  GL.glVertex3f(-1.0f,-1.0f,1.0f);            // left of Triangle (front)
                  GL.glColor3f(0.0f,0.0f,1.0f);                  // blue
                  GL.glVertex3f(1.0f,-1.0f,1.0f);                  // right of triangle (front)

                  GL.glColor3f(1.0f,0.0f,0.0f);                  // red
                  GL.glVertex3f(0.0f,1.0f,0.0f);                  // top of triangle (right)
                  GL.glColor3f(0.0f,0.0f,1.0f);                  // blue
                  GL.glVertex3f(1.0f,-1.0f,1.0f);                  // left of triangle (right)
                  GL.glColor3f(0.0f,1.0f,0.0f);                  // green
                  GL.glVertex3f(1.0f,-1.0f,-1.0f);            // right of triangel (right)

                  GL.glColor3f(1.0f,0.0f,0.0f);                  // red
                  GL.glVertex3f(0.0f,1.0f,0.0f);                  // top of triangle (back)
                  GL.glColor3f(0.0f,1.0f,0.0f);                  // green
                  GL.glVertex3f(1.0f,-1.0f,-1.0f);            // left of triangle (back)
                  GL.glColor3f(0.0f,0.0f,1.0f);                  // blue
                  GL.glVertex3f(-1.0f,-1.0f,-1.0f);            // right of triangle (back)

                  GL.glColor3f(1.0f,0.0f,0.0f);                  // red
                  GL.glVertex3f(0.0f,1.0f,0.0f);                  // top of triangle (left)
                  GL.glColor3f(0.0f,0.0f,1.0f);                  // blue
                  GL.glVertex3f(-1.0f,-1.0f,-1.0f);            // left of triangle (left)
                  GL.glColor3f(0.0f,1.0f,0.0f);                  // green
                  GL.glVertex3f(-1.0f,-1.0f,1.0f);            // right of triangle (left)
                  GL.glEnd();

                  GL.glLoadIdentity();                              // reset the current modelview matrix
            GL.glTranslatef(1.5f,0.0f,-7.0f);            // move 1.5 Units right and 7 into the screen
                  GL.glRotatef(rquad,1.0f,1.0f,1.0f);            // rotate the quad on the X,Y and Z-axis
                  rquad-=0.15f;                                          // rotation angle

                  GL.glBegin(GL.GL_QUADS);                        // start drawing a quad
                  GL.glColor3f(0.0f,1.0f,0.0f);                  // green top
                  GL.glVertex3f(1.0f,1.0f,-1.0f);                  // top right (top)
            GL.glVertex3f(-1.0f,1.0f,-1.0f);            // top left (top)
                  GL.glVertex3f(-1.0f,1.0f,1.0f);                  // bottom left (top)
                  GL.glVertex3f(1.0f,1.0f,1.0f);                  // bottom right (top)

                  GL.glColor3f(1.0f,0.5f,0.0f);                  // orange
                  GL.glVertex3f(1.0f,-1.0f,1.0f);                  // top right (bottom)
                  GL.glVertex3f(-1.0f,-1.0f,1.0f);            // top left (bottom)
                  GL.glVertex3f(-1.0f,-1.0f,-1.0f);            // bottom left (bottom)
                  GL.glVertex3f(1.0f,-1.0f,-1.0f);            // bottom right (bottom)

                  GL.glColor3f(1.0f,0.0f,0.0f);                  // red
                  GL.glVertex3f(1.0f,1.0f,1.0f);                  // top right (front)
                  GL.glVertex3f(-1.0f,1.0f,1.0f);                  // top left (front)
                  GL.glVertex3f(-1.0f,-1.0f,1.0f);            // bottom left (front)
                  GL.glVertex3f(1.0f,-1.0f,1.0f);                  // bottom right (front)

                  GL.glColor3f(1.0f,1.0f,0.0f);                        // yellow
                  GL.glVertex3f(-1.0f,1.0f,-1.0f);            // top right (back)
                  GL.glVertex3f(1.0f,1.0f,-1.0f);                  // top left (back)
                  GL.glVertex3f(1.0f,-1.0f,-1.0f);            // bottom left (back)
                  GL.glVertex3f(-1.0f,-1.0f,-1.0f);            // bottom right (back)
      
                  GL.glColor3f(0.0f,0.0f,1.0f);                  // blue
                  GL.glVertex3f(-1.0f,1.0f,1.0f);                  // top right (left)
                  GL.glVertex3f(-1.0f,1.0f,-1.0f);            // top left (left)
                  GL.glVertex3f(-1.0f,-1.0f,-1.0f);            // bottom left (left)
                  GL.glVertex3f(-1.0f,-1.0f,1.0f);            // bottom right (left)

                  GL.glColor3f(1.0f,0.0f,1.0f);                  // violett
                  GL.glVertex3f(1.0f,1.0f,-1.0f);                  // top right (right)
                  GL.glVertex3f(1.0f,1.0f,1.0f);                  // top left (right)
                  GL.glVertex3f(1.0f,-1.0f, 1.0f);            // bottom left (right)
                  GL.glVertex3f(1.0f,-1.0f,-1.0f);            // bottom right (right)
                  GL.glEnd();

            }

            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);                                                // type of depth test
                  GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);      // nice perspective calculations
                  //rtri = 30.0f;                  define the rotation angle in the start position of the triangle
                  //rquad = 30.0f;            define the rotation angle in the start position of the quad
            }

            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      
      {
            private lesson05.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 lesson 05 in C# (by Sabine Felsinger)";
                  this.view = new lesson05.OurView();                  
                  this.view.Parent = this;
                  this.view.Dock = DockStyle.Fill; // Will fill whole form
                  this.Show();
            }

            static void Main()
            {
                  MainForm form = new MainForm();

                  while ((!form.view.finished) && (!form.IsDisposed))            // refreshing the window, so it rotates
                  {
                        form.view.glDraw();
                        form.Refresh();
                        Application.DoEvents();
                  }

                  form.Dispose();
            }
      }
}
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jsbsudhaAuthor Commented:
Exception error in the statement

base.OnSizeChanged(e);

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();
            }
0
 
ikeworkCommented:
and which exception?  "division by zero"? if yes, check that "s.Height" is not zero in protected override void OnSizeChanged(EventArgs e)
0
 
jsbsudhaAuthor Commented:
please wait I will check it by opening my file
0
 
jsbsudhaAuthor Commented:
type initialization exception was hadled in the statement  base.onchanged(e)
0
 
jsbsudhaAuthor Commented:
I am running the above Csharp program in  VS2005 ....I am getting the error message as

Type initialiazation exception for csgl.OSLib unhanled
0
 
ikeworkCommented:
can you show the code of base.onchanged(e) and the line the exception was thrown?
0
 
jsbsudhaAuthor Commented:
the jpg file
pic.jpg
0
 
ikeworkCommented:
can you click "view detail" and post it here?
0
 
jsbsudhaAuthor Commented:
view details
pic2.jpg
0
 
ikeworkCommented:
it says: "the dll csgl.native.dll could not be found"

did you install csgl properly?
0
 
jsbsudhaAuthor Commented:
Could you tell me the exact procedure what I have to do
to install csgl in your project
0
 
ikeworkCommented:
post-overlapping .. check my last comment ;)
0
All Courses

From novice to tech pro — start learning today.