Have Byte Ptr , need Float Ptr

BlitzMax Forums/BlitzMax Beginners Area/Have Byte Ptr , need Float Ptr

Difference(Posted 2004) [#1]
glMap2f takes a Float Ptr as last argument it seems, I have my float data in a bank, I can get the Byte Ptr but BM says 'unable to convert form Byte Ptr to Float Ptr'

How do I make a Float Ptr to a bank ?


Warren(Posted 2004) [#2]
I'm pretty sure you can cast variables. Can you post some code to illustrate the problem?


Difference(Posted 2004) [#3]
Local mybank

mybank=CreateBank(192)

Local bufPtr:Byte Ptr
bufPtr= BankBuf(mybank)

glMap2f GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, bufPtr


skidracer(Posted 2004) [#4]
untested...
Local a:Byte Ptr
Local b:Float Ptr=Float Ptr(a)



Difference(Posted 2004) [#5]
@skidracer : wont that give me a pointer to a, not to the data a is pointing at?


Kanati(Posted 2004) [#6]
That does look more like **a (to use C syntax)

but I think his example is to show a cast of a into a float pointer.


marksibly(Posted 2004) [#7]
Hi,

Skids correct, ie:
mybank=CreateBank(192) 

Local bufPtr:Byte Ptr 
bufPtr= BankBuf(mybank) 

glMap2f GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, Float Ptr( bufPtr )



Difference(Posted 2004) [#8]
Ok, thanks, I'll try that out!


Difference(Posted 2004) [#9]
Thanks. That worked well.

Now I have a type that I want to send to glMaterialfv

glMaterialfv declare is: Function glMaterialfv(face_,pname_,params_:Float Ptr)

Type color4f
Field r#,g#,b#,a#
End Type

Local ambient:color4f = New color4f
ambient.r=0.2
ambient.g=0.2
ambient.b=0.2
ambient.a=1

All these gives an errors:
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient)

glLightfv(GL_LIGHT0, GL_AMBIENT, Float Ptr(ambient))

glLightfv(GL_LIGHT0, GL_AMBIENT, Float Ptr(ambient.r))


[EDIT] glLightfv(GL_LIGHT0, GL_AMBIENT, Varptr(ambient.r)) seems ok, but not too elegant ?


Difference(Posted 2004) [#10]
See what it was for here:
Utah Teapot for BlitzMax - http://www.blitzbasic.com/Community/posts.php?topic=41645