Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: OpenGL VB.NET
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)
 
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
Posted 10-Aug-12 0:29am
Comments
Volynsky Alex at 10-Aug-12 5:47am
   
Please see here:
http://www.youtube.com/watch?v=h7quif_8hu8
videepmishraa at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
videepmishraa at 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?
 
Thanks
-v

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

  Print Answers RSS
0 OriginalGriff 475
1 Maciej Los 349
2 Richard MacCutchan 220
3 BillWoodruff 219
4 Mathew Soji 160
0 OriginalGriff 8,759
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,269
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100