Click here to Skip to main content
12,697,525 members (26,911 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB OpenGL VB.NET
Hello Everyone,

What I am trying to do is:
1) Create a polygon, create a texture and apply it to polygon.

Next when I want to draw a line, which is a continuous line, I need to re-draw the scene every time.

Do I also need to re-draw the polygon??? Because if I dont, it wont appear in the scene and If I do, then the line drawing becomes VERY slow.

Attaching the code:

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        If e.Button = MouseButtons.Left Then
            painting = True
            If startingPoint.X = 0 And startingPoint.Y = 0 Then
                startingPoint = PointToScreen(e.Location)
            End If
        End If
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If (painting) Then
            endPoint = PointToScreen(e.Location)
            Gl.glViewport(0, 0, Me.Width, Me.Height)
            Glu.gluOrtho2D(0, Me.Width, Me.Height, 0)
            For Each l As line In lineList
            Gl.glColor3f(0, 100, 0)
            'Use this to give a line width
            'Use the statement below to enable stipple --
            Gl.glLineStipple(1, &H101)
            Gl.glVertex2f(startingPoint.X, startingPoint.Y)
            Gl.glVertex2f(endPoint.X, endPoint.Y)

            'Use the statement below to disable the stipple effect for the previously drawn lines
            img.imgFile = "D:\\Desert.jpg"
        End If
    End Sub

    Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        If (painting) Then
            painting = False
            'endPoint = e.Location
            Dim obj As New line
            obj.setStart = startingPoint
            obj.setEnd = endPoint
            startingPoint = endPoint
        End If

    End Sub
Posted 16-Aug-12 1:17am

1 solution

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

Solution 1

It is required to redraw both texture and line for every frame.

            img.imgFile = "D:\\Desert.jpg"

Is texture loading necessary for each mouse movement ?

Normally redrawing a texture and line won't create slow rendering.

If any processing which is not related to the mouse movement, and takes much time, then we can use an intermediate texture to hold the output of heavy task. For every frame we can draw that texture with line drawing.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2017
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