Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:32:08+00:00 2026-06-01T17:32:08+00:00

I was trying to follow this tutorial to make an OpenGL application on C#.

  • 0

I was trying to follow this tutorial to make an OpenGL application on C#. http://www.developerfusion.com/article/3823/opengl-in-c/2/

Later on, I tried to make the following changes:

class DrawObject : OpenGLControl
{
    public override void glDraw()
    {
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        GL.glLoadIdentity();
        GL.glBegin(GL.GL_LINE);
        GL.glLineWidth(10.0f);
        GL.glVertex3f(-3.0f, 0.0f, 0.0f);
        GL.glVertex3f(3.0f, 0.0f, 0.0f);
        GL.glEnd();
        GL.glFlush();
    }

    protected override void InitGLContext()
    {
        GL.glShadeModel(GL.GL_SMOOTH);
        GL.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
        GL.glClearDepth(1.0f);
        GL.glEnable(GL.GL_DEPTH_TEST);
        GL.glDepthFunc(GL.GL_LEQUAL);
        GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
    }

    protected override void OnSizeChanged(EventArgs e)
    {
        base.OnSizeChanged(e);

        Size s = Size;
        double aspect_ratio = (double)s.Width / (double)s.Height;
        GL.glMatrixMode(GL.GL_PROJECTION);
        GL.glLoadIdentity();

        GL.gluPerspective(45.0f, aspect_ratio, 0.1f, 100.0f);

        GL.glMatrixMode(GL.GL_MODELVIEW);
        GL.glLoadIdentity();
    }
}

public class DrawLine : Form
{
    DrawObject newObject = new DrawObject();

    public DrawLine()
    {
        Text = "Draw a line";
        newObject.Dock = DockStyle.Fill;
        Controls.Add(newObject);
    }

    public static void Main()
    {
        DrawLine drawLine = new DrawLine();
        Application.Run(drawLine);
    }
}

For some reason, I will then get an “invalid enumerant” error, at Application.Run(drawLine). Basically what I’m trying to do is to replace the part where it renders a dot on 3 specified vertices, with a part where it renders a line given 2 vertices. I do not know why the dot version does not throw this exception, but the line version does. I have referenced csgl.dll in my references, and added csgl.native.dll and made it to be published every time the solution is compiled (otherwise the whole thing wouldn’t run at all).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:32:09+00:00Added an answer on June 1, 2026 at 5:32 pm

    Don’t change state inside glBegin and glEnd (that is, don’t call glLineWidth). From the docs:

    GL_INVALID_OPERATION is generated if glLineWidth is executed between 
    the execution of glBegin and the corresponding execution of glEnd.
    

    Answer from JulianLee: glBegin must be called with GL_LINES, not GL_LINE. See comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to follow this tutorial http://www.codeguru.com/csharp/csharp/net30/article.php/c15489 I'm not able to select the sql server
I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
I'm trying to follow this tutorial - http://www.dotnetcurry.com/ShowArticle.aspx?ID=231&AspxAutoDetectCookieSupport=1 I have both the vsdoc file
I'm trying to follow this tutorial for an Accordion control in WPF: http://www.c-sharpcorner.com/UploadFile/dpatra/538/ I
I'm trying to follow this tutorial: http://jqueryfordesigners.com/fixed-floating-elements/ . The problem is that whenever the
I am trying to follow this tutorial http://damianm.com/tech/nhibernate-mvc-and-ninject/ but I am running into some
I'm trying to follow this tutorial about WP7 development: http://mobile.tutsplus.com/tutorials/windows/introduction-to-windows-mobile-7-development/ It's talking about using
I am trying to follow this tutorial (http://railscasts.com/episodes/88-dynamic-select-menus) to get dynamic select boxes working
I'm trying to follow this tutorial on binding: http://andrehoffmann.wordpress.com/2009/09/03/phonebook-tutorial-for-dummiesxcode-3-1-3/ but the app keeps crashing
I'm a postgresql user and I'm trying to follow this : http://www.postgresql.org/docs/current/interactive/sql-createtrigger.html CREATE TRIGGER

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.