Drawtext crashes in NG

BlitzMax Forums/BlitzMax Programming/Drawtext crashes in NG

xlsior(Posted February) [#1]
I'm trying to use an array of types, but am running into a problem: The following code works OK in stock blitzmax, but crashes in Blitzmax NG with an unhandled exception error: "Unhandled Exception:Unable to calculate tex size"

If I remark out either one of the drawtext lines it runs without error, but with both in place it crashes. Latest NG, using TDM GCC 5.1.0


Graphics 1280,1024
SeedRnd(MilliSecs())

Type UnitSpec
	Field xpos:Int
	Field ypos:Int
End Type

Global Enemy:Unitspec[100]

For Local tt:Int=1 To 20
	Print tt
	Enemy[tt]=New Unitspec
	Enemy[tt].xpos=Rand(100,800)
	Enemy[tt].ypos=Rand(100,800)
	DrawText("1",Enemy[tt].xpos,Enemy[tt].ypos)
	DrawText("2",Enemy[tt].xpos,(Enemy[tt].ypos-20))
Next

Flip
WaitKey()



grable(Posted February) [#2]
That error is from one of the GL backends, most likely it got a texture with 0 width & height.
Try one of the other backends and see if one of them works instead.
As for the reason for that error, it might be that whatever font DrawText uses is not loaded properly.


xlsior(Posted February) [#3]
OK, it does indeed look like it is DrawText that's blowing up for me.

This works:

DrawText("33",100,100)
DrawText("33333333333",200,100)

This fails:
DrawText("33333333334",200,100)

I can print whatever single character, however many times, but as soon as I attempt to print a different character it can't load it and blows up.

I tried switching to the DX graphics driver but that fails altogether.
I'll recompile all modules, and see if that makes a difference. :-?


xlsior(Posted February) [#4]
Hm... Can't recompile mods, brl.mod/blitz.mod is blowing up on compilation, whole bunch of 'conflicting type' errors.


grable(Posted February) [#5]
Hmm, that is a weird bug for sure. Yeah, i think maybe your NG is borked :/ No harm in re-downloading it i guess.


Derron(Posted February) [#6]
With current bcc-ng I get some other errors (make sure to use an older revision - maybe before the HurryStarfish-function-pointer-merge - as this is running fine here).

Using that BCC and an uptodate-brl.mod/pub.mod your example does not crash.


bye
Ron


FireballStarfish(Posted February) [#7]
Getting type errors in blitz.mod is strange - I don't think they're related to my commits at least, because I am not getting them here.
A known issue that does exist right now though is that BRL.Reflection will not compile with the latest bcc. This will be dealt with soon, but for a quick workaround on your end (assuming you have the latest BRL.Reflection for NG from here), you can change line 1925 from
list.Sort( True, compareFunction)
to
list.Sort( True, Byte Ptr compareFunction)



Derron(Posted February) [#8]
I think his code should not use reflection stuff (only maxlua.mod imports brl.reflection). I proposed the "previous commit" because with this BCC I was able to compile all the basic modules which the newer ones were not able to achieve. So I did not say it was your commit. It was just a "marker".


bye
Ron


xlsior(Posted February) [#9]
OK, loading the latest version of bcc this morning and changing line 1925 in reflection.bmx to list.Sort( True, Byte Ptr compareFunction)

brl.mod and pub.mod recompile now,

and my drawtext example runs properly without crashing.

(Not completely out of the woods yet though, there's other modules that don't compile yet, like bah.freeimage for example:
[ 99%] Processing:freeimage.bmx
Compile Error: Unable to convert from () to Int().
[c:/code/blitzmaxNG510/mod/bah.mod/freeimage.mod/freeimage.bmx;2095;0]
Build Error: failed to compile (-1) c:/code/blitzmaxNG510/mod/bah.mod/freeimage.mod/freeimage.bmx



As far as downloading an older version: Is there some way to check out a specific version or date of a branch through git or the github site without having to redownload each file explicitly?


Brucey(Posted February) [#10]
The recent function pointer enhancements (things like proper arg/return type-checking) have had some knock-on effects elsewhere, which is requiring some tweaks to code in places.

We thank you for your patience whilst I work on un-breaking things.

I've now made pub.stdc SuperStrict... which appears to resolve the FreeImage issue.


xlsior(Posted February) [#11]
I've now made pub.stdc SuperStrict... which appears to resolve the FreeImage issue.



Looks like it did, now doing a full recompile of everything to see if there's anything else that fails.


Derron(Posted February) [#12]
As far as downloading an older version: Is there some way to check out a specific version or date of a branch through git or the github site without having to redownload each file explicitly?




And then




bye
Ron


xlsior(Posted February) [#13]
Thanks!

Easy if you know it, but not very intuitive.