Click here to Skip to main content
15,743,541 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)
Dim r = 45
Gl.glOrtho(-r, r, -r * (_height / _width), r * (_height / _width), -r, r)

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


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?

Volynsky Alex 10-Aug-12 5:47am    
Please see here:
videepmishraa 10-Aug-12 6:16am    
The video is a nice demonstration. But that has been done with GDI+ and I am trying to do it with OpenGL.
The reason I am using OpenGL is because when I draw rectangles, I want to change their properties too!!!

1 solution

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.
Share this answer
videepmishraa 14-Aug-12 5:51am    
Thank You,
I have another question:
How to make a surface which can re-draw it from time to time?


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900