Skip to content

Draw lines using sharpgl (C#).

Muhammad Adeel

Asked Jan 28, 2015, 7:50 PM EST1 answer
Share
LinkedInX
I am trying to draw line in c# using sharpgl but when i compile the code it gives me the console with full of white color not the line,how to solve this this problem or is there any mistake in my code.Here is the code.


 private static int width = 400, height = 300;
static void Main(string[] args)
{

Glut.glutInit();
Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
Glut.glutInitWindowSize(width, height);
Glut.glutCreateWindow("OpenGL Tutorial");

init();
Glut.glutDisplayFunc(OnDisplay);
Glut.glutMainLoop();
}
private static void OnDisplay()
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
Gl.glColor3f(0.0f, 0.4f, 0.2f);
Gl.glBegin(Gl.GL_LINES);

Gl.glVertex2i(180, 15);
Gl.glVertex2i(10, 145);
Gl.glEnd();
Gl.glFlush();
}
static void init()
{
Gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
Gl.glMatrixMode(Gl.GL_PROJECTION);
// Gl.glLoadIdentity();
Gl.glOrtho(0.0, 200.0, 0.0, 1.0, -1.0, 1.0);

}

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi! Can you please post this problem in the GitHub issue tracker!? I will have a look at your problem, but we like to collect the problems there. I will of course post the possible answer here! :) https://github.com/dwmkerr/sharpgl/
    0