VB.NET和OpenGL绘图 [英] VB.NET and OpenGL Drawing

查看:107
本文介绍了VB.NET和OpenGL绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我刚开始使用一些openglProgramming.

我正在使用Tao OpenGL库.

这是我的问题:

在2D模式下绘制矩形时,是否总是需要重新绘制旧矩形?
还是有办法只画新的?

我在这里做的是:

Hello Everyone,

I just started off with some openglProgramming.

I am using the Tao OpenGL library.

Here is my question:

When I am drawing rectangles in 2d, do I always have to re-draw old rectangles?
or is there a way that I draw only new ones?

What I am doing here is:

Gl.glViewport(0, 0, Me.Width, Me.Height)
Gl.glClearColor(0.5F, 0.5F, 0.5F, 0.5F)
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT)
Gl.glMatrixMode(Gl.GL_PROJECTION)
Gl.glLoadIdentity()
Dim r = 45
Gl.glOrtho(-r, r, -r * (_height / _width), r * (_height / _width), -r, r)
Gl.glPushMatrix()

Gl.glColor3f(1.0F, 0.5F, 0.5F)
Gl.glBegin(Gl.GL_LINE_LOOP)
Gl.glVertex2f(0, 10)
Gl.glVertex2f(10, 10)
Gl.glVertex2f(10, 20)
Gl.glVertex2f(0, 20)
Gl.glEnd()

Gl.glPopMatrix()
Gl.glFlush()
Gdi.SwapBuffers(hDC)



当我再次绘制时,我需要重新运行此代码...
那么有必要重画还是有其他出路?

-Videep



And when I draw again, I need to re-run this code...
So is it necesssary to re-draw or is there another way out?

-Videep

推荐答案

除非您绘制其他一些可以绘制到屏幕上的表面,否则,您必须重新绘制所有内容.为什么?因为如果在绘图表面上拖动另一个窗口,则所有内容都会在屏幕上被覆盖,并且当该表面重新显示时必须重新绘制.

不管使用哪种绘图API(GDI或OpenGl),概念都相同.
Unless you draw to some other surface that, itself, can be drawn to the screen, yes, you have to redraw everything. Why? Because if you drag another window acrossed your drawing surface everything will get overwritten on screen and have to be redrawn when the surface come back into view.

It doesn''t matter which drawing API you use, GDI or OpenGl, the concepts are still the same.


这篇关于VB.NET和OpenGL绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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