Object requests

BlitzMax Forums/BlitzMax Programming/Object requests

JoshK(Posted 2008) [#1]
It would make sense for objects to automatically be converted into float pointers, since they already get converted automatically into byte pointers. For example:

Type TVec4
Field x#,y#,z#,w#
EndType

Function Vec4:TVec4(x#,y#,z#,w#)
Local v:TVec4=New TVec4
v.x=x
v.y=y
v.z=z
v.w=w
return v
EndFunction

glColor4fv vec4(1,1,1,1)

Or maybe something like this:

glColor4fv entity.color



It would also be nice if the 8-byte header for objects could be done away with or moved somewhere else, and if null objects had a byte ptr of 0. I do not know if these two things are possible, but it would make it work better with CPP. Right now, if Blitz is passed a null pointer for an object, it thinks the object is valid. I have to detect if the object pointer=8 to see if the object was actually valid or a null pointer.


fredborg(Posted 2008) [#2]
Use:
glColor4fv Varptr(entity.color.x)


JoshK(Posted 2008) [#3]
I know but that is gay. Especially since this does work:

MemCopy v1,v2,16


Rone(Posted 2008) [#4]
I think thats also possible(nothing testet):

glColor4fv ( Float Ptr(Byte Ptr(v1)) )

or simply:

Type TVec4
Field d:float[4]
EndType

glColor4fv(v1.d[0])


Czar Flavius(Posted 2008) [#5]
I don't understand what this is.


markcw(Posted 2008) [#6]
Isn't it built-in type casting for objects?


JoshK(Posted 2008) [#7]
Here's somewhere where it would really help:


PositionEntity entity,Vec3(1,1,1)

or

PositionEntity entity,[1.0,1.0,1.0]

That would be so much cooler. I could also make my math operations work for either a math class or an arbitrary float pointer. Offloading math code into CPP code would be easier, and it would be nicer for the programmer to be able to use either a vec3 or a float array.