C Classes with Constructors, etc

BlitzMax Forums/BlitzMax Programming/C Classes with Constructors, etc

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ok, here's what I've done.

hgehelp Module
Strict

Module glimmer.hgehelp

ModuleInfo "Version 1.0"
ModuleInfo "Author: Phil Ings"


Import "-lhge"
Import "-lhgehelp"

Import "hgehelpwrapper.cpp"


Extern "C"
   Function CreateHGESprite:hgeSprite( t%, x#, y#, w#, h# )
   Function CopyHGESprite:hgeSprite( p:hgeSprite )
   Function DestroyHGESprite( p:hgeSprite )
End Extern



Extern "Win32"

	Type hgeSprite
			
		Method Constructor1:hgeSprite(Tex:Int,X:Float,Y:Float,W:Float,H:Float)
		Method Constructor2(Spr:hgeSprite)
		Method Destructor()
		
		Method Operator:hgeSprite(Spr:hgeSprite)
	
		Method Render(X:Float,Y:Float)
		Method RenderEx(X:Float,Y:Float,Rot:Float,HScale:Float,VScale:Float)
		Method RenderStretch(X1:Float,Y1:Float,X2:Float,Y2:Float)
		Method Render4V(X0:Float,Y0:Float,X1:Float,Y1:Float,X2:Float,Y2:Float,X3:Float,Y3:Float)
		
		Method SetTexture(Tex:Int)
		Method SetTextureRect(X:Float,Y:Float,W:Float,H:Float)
		Method Set_Color(Col:Int,I:Int)
		Method SetZ(Z:Float,I:Int)
		Method SetBlendMode(Blend:Int)
		Method SetHotSpot(X:Float,Y:Float)
		Method SetFlip(BX:Int,BY:Int)
		
		Method GetTexture:Int()
		Method GetTextureRect(X:Float Var,Y:Float Var,W:Float Var,H:Float Var)
		Method Get_Color:Int(I:Int)
		Method GetZ:Float(I:Int)
		Method GetBlendMode:Int()
		Method GetHotSpot(X:Float Var,Y:Float Var)
		Method GetFlip(BX:Float Var, BY:Float Var)
		
		Method GetBoundingBox:Int(X:Float,Y:Float,Rect:Int) ' RETURNS AND TAKES hgeRect REALLY
		Method GetBoundingBoxEx:Int(X:Float,Y:Float,Rot:Float,HScale:Float,VScale:Float,Rect:Int) ' RETURNS AND TAKES hgeRect REALLY
		Method GetWidth:Float()
		Method GetHeight:Float()
		
		Method _hgeSprite()
		
		Field Quad:Int ' ACTUALLY IT IS AN hgeQuad
		Field TX:Float
		Field TY:Float
		Field Width:Float
		Field Height:Float
		Field HotX:Float
		Field HotY:Float
		Field BXFlip:Int,BYFlip:Int

	End Type

End Extern


And the CPP as you have it listed above. I get a memory access violation if I call any of the methods though, so I don't think I've got it quite right.

And yes, I know a couple of classes I haven't done yet have been replaced with Ints, but those are not the ones I'm calling, and there's no point me doing every class until I've got my technique down pat.

The functions are not returning null hgeSprite's BTW. I check for that.