如何使用sharpgl(C#)绘制线条。 [英] How to draw lines using sharpgl (C#).

查看:123
本文介绍了如何使用sharpgl(C#)绘制线条。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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);
}

推荐答案

这是一篇关于C#中的绘制线的文章:

http://www.c-sharpcorner.com/UploadFile/mahesh/drawing-lines-in-gdi/ [ ^ ]

在窗口窗体中绘制各种形状: http://www.dotnettutorials .com / tutorials / graphics / winforms-drawing-cs / [ ^ ]
Here is an article about Draw Line in C#:
http://www.c-sharpcorner.com/UploadFile/mahesh/drawing-lines-in-gdi/[^]
Draw various shapes in a Window Form:http://www.dotnettutorials.com/tutorials/graphics/winforms-drawing-cs/[^]


这篇关于如何使用sharpgl(C#)绘制线条。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆