问题描述
我正在尝试使用sharpgl在c#中绘制线条,但是当我编译代码时,它给我的控制台充满了白色而不是线条,如何解决这个问题或者我的代码中是否有任何错误。这是代码。
private static int width = 400,height = 300;
static void Main( string [] args)
{
Glut.glutInit();
Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
Glut.glutInitWindowSize(宽度,高度);
Glut.glutCreateWindow(OpenGL教程);
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();
}
stat ic 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);
}
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);
}
推荐答案
这篇关于如何使用sharpgl(C#)绘制线条。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!