Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Caraf G

Posted on 2000-04-06
11
Medium Priority
?
180 Views
Last Modified: 2010-05-02
For an extra 50 -

Further to our discussion on using CopyMemory to pass lists about:
I am getting an error with reading the memory.  Is there a maximum size of memory that I can copy?

I am now passing more points (as I need ordered triangles for OpenGL)

Dim mysglcoord() As sglCoordinate3D
Dim mycoords As Single
Dim i As Long

ReDim mysglcoord(1 To MyTSB.numTriangleCoords)

mycoords = MyTSB.sglTriangleCoords
CopyMemory VarPtr(mysglcoord(1)), mycoords, 12 * (MyTSB.numTriangleCoords)

Call glBegin(GL_TRIANGLES)
For i = 1 To MyTSB.numTriangleCoords
  Call glColor3f(1#, 1#, 0#)
  Call glVertex3f(mysglcoord(i).x, mysglcoord(i).y, mysglcoord(i).z)
Next i
Call glEnd
Call glFlush

I get the message:
The instruction at "0x77f970ab" referenced memory at "0x0ab7200". The memory could not be "read".

You know, the standard crashing error.  The size of the operation is all I can think of.
0
Comment
Question by:MitchBroadhead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 1

Author Comment

by:MitchBroadhead
ID: 2689225
The error occurs on the line CopyMemory
0
 
LVL 1

Author Comment

by:MitchBroadhead
ID: 2689320
OK I have realised that the Ptr is a long instead of a single.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2689384
Does that mean you solved the problem?

If not, can you post the type definition for MyTSB?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:MitchBroadhead
ID: 2689411
No I haven't solved the problem.

MyTSB.sglTriangleCoords fills an array:

Type VertexCoord
 x as single
 y as single
 z as single
end type

redim vertCoord(1 to numTriangleCoords) as vertexcoord

Then passes VarPtr(vertcoord(1)) back as a long.

0
 
LVL 1

Author Comment

by:MitchBroadhead
ID: 2689414
Public Function sglTriangleCoords() As Long
Dim pointCounter As Long
Dim i As Long
Dim j As Long
Dim sglCoords() As VertexCoordinate

pointCounter = 1

ReDim sglCoords(1 To numTriangleCoords)

For i = 1 To MyTSB.SurfacePolygonIndices.Npolygons
   For j = 1 To MyTSB.SurfacePolygonIndices.SurfacePolygon(i).Nsides
     sglCoords(pointCounter) = MyTSB.VertexCoords.VertexCoordinate(MyTSB.SurfacePolygonIndices.SurfacePolygon(i).IndicesShort(j) + 1)
     pointCounter = pointCounter + 1
   Next j
 Next i

sglTriangleCoords = VarPtr(sglCoords(1))
'sglTriangleCoords = sglCoords(1)
End Function
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2689451
Hmmmm. Should be OK. A Single is 4 bytes too.

Perhaps a completely different tack is needed here. You may have to do some class programming after all...
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2689477
Ok, look at this idea:

1) Create a DLL with the following class (Class1)

Option Explicit
Private Type VertexCoordinate
    a As Single
    b As Single
    c As Single
End Type
Private arrTheThreeSinglesArray() As VertexCoordinate
Public Sub FillIt(lngLBound As Long, lngUBound As Long)

Dim lngCounter As Long
ReDim arrTheThreeSinglesArray(lngLBound To lngUBound)
For lngCounter = lngLBound To lngUBound
    arrTheThreeSinglesArray(lngCounter).a = lngCounter * 1
    arrTheThreeSinglesArray(lngCounter).b = lngCounter * 2
    arrTheThreeSinglesArray(lngCounter).c = lngCounter * 3
Next

End Sub
Public Property Get tLBound() As Long

tLBound = LBound(arrTheThreeSinglesArray)

End Property
Public Property Get tUBound() As Long

tUBound = UBound(arrTheThreeSinglesArray)

End Property
Public Property Get tA(Index As Long) As Single

tA = arrTheThreeSinglesArray(Index).a

End Property
Public Property Get tB(Index As Long) As Single

tB = arrTheThreeSinglesArray(Index).b

End Property
Public Property Get tC(Index As Long) As Single

tC = arrTheThreeSinglesArray(Index).c

End Property

0
 
LVL 10

Accepted Solution

by:
caraf_g earned 200 total points
ID: 2689478
Then, the calling program could use it as follows:

Option Explicit
Private Type VertexCoordinate
    a As Single
    b As Single
    c As Single
End Type
Private Sub Command1_Click()

Dim objX As Class1
Dim typY As VertexCoordinate
Set objX = New Class1
objX.FillIt 1, 3

Dim lngCounter As Long

For lngCounter = 1 To 3
    typY.a = objX.tA(lngCounter)
    typY.b = objX.tB(lngCounter)
    typY.c = objX.tC(lngCounter)
    'Now you can use typY here
Next

End Sub
0
 
LVL 1

Author Comment

by:MitchBroadhead
ID: 2689517
won't this slow the performance somewhat?
I'll give it a go though!!
0
 
LVL 1

Author Comment

by:MitchBroadhead
ID: 2689542
The display flickers a bit when rotating the shape, but its good!!
Thanx again Caraf :)
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2689583
Glad I could help!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question