Bmx-NG Error: Expression must be a variable
BlitzMax Forums/Brucey's Modules/Bmx-NG Error: Expression must be a variable
| ||
This happens with multi-dim arrays but single-dim arrays are fine. I added the k array in the example.'Module sidesign.minib3d Strict ' TGlobal.bmx Type TGlobal Global j#[16,2] Global k#[16*2] ' single dim Function AntiAlias(samples:Int) Select samples Case 1 RestoreData j2 End Select For Local i:Int=0 Until samples ReadData j[i,0],j[i,1] 'ReadData k[i],k[i+1] Next End Function End Type ' data.bmx #j2 DefData 0.25,0.75,0.75,0.25 Using win7 tdm mingw 64 4.8.1. |
| ||
Feel free to report issues on github too. I'm less likely to forget about them there ;-) Thanks! |
| ||
Error: Subexpression for 'Ptr' must be a variable This is a similar multi-dim array error where you can't pass it as a pointer. I added ambient2 to show it works for single-dim arrays. 'Module Openb3d.Openb3d Strict ' TLight.bmx Type TLight 'Extends TEntity Global no_lights:Int Ptr ' number of lights - 0 Global ambient#[8,4] ' [0.0,0.0,0.0,1.0] Global ambient2#[8*4] ' single dim Function GetLightValues() For Local i%=0 To no_lights[0]-1 glGetLightfv(GL_LIGHT0+i, GL_AMBIENT, Varptr(ambient[i,0])) 'glGetLightfv(GL_LIGHT0+i, GL_AMBIENT, Varptr(ambient2[i])) Next End Function End Type |
| ||
Ok, I'll have a go. I was wondering if I should post issues there instead. Just wasn't sure which repo to post to! |
| ||
For things that compile with the legacy compiler but don't with NG, this is probably the better place to raise them : https://github.com/bmx-ng/bcc/issues |
| ||
Those two issues should be sorted now. |
| ||
Tested and it works now, thanks! Openb3d builds without changes and the sl_bumpmap example (which uses Get/SetLightValues) is working, in fact all Openb3d examples I tested worked! The only problem is that it won't do fullscreen but this is not a feature I ever liked much anyway. |
| ||
Does it "do fullscreen" for you when compiled with vanilla then there is a bug with NG (module, BCC), else it might be a bug in the sample, the module or in connection with your computer setup. bye Ron |
| ||
The only problem is that it won't do fullscreen but this is not a feature I ever liked much anyway. Is there a specific error? |
| ||
I tested this properly and fullscreen is working in NG, so sorry for the mistake. Minib3d behaves a bit different to Openb3d when setting depth,mode in Graphics3d. This is actually a bug in Minib3d, when you set depth,mode to 0,1 the screen goes black but you can exit it doesn't crash. This also happens if depth,mode is 0,0 in release and is because depth is 16 when running in 32bit. Openb3d depth,mode has to be 32,1 or DesktopDepth(),1 for fullscreen to work. I did find another issue though. When I run Minib3d example tex_render in NG debug mode the cube texture goes black (but this works in Bmx legacy debug), "BackBufferToTex" would seem to be the problem. In Openb3d the same tex_render example works in NG debug. |
| ||
When I run Minib3d example tex_render in NG debug mode the cube texture goes black Ok, found this is a bug with Minib3d and not NG. It goes black because the width/height are overwritten in TTexture CreateTexture as the code uses the same name for those parameters as some local variables. Solution is just to rename them. Strange how it only happens in debug x86/x64 but is fine in release and in legacy Bmx debug/release... |
| ||
Do you have a small example that replicates the issue? Thanks :-) |
| ||
Ok, this is a bit odd it looks like the problem is actually in pixmap.Window rather than the same named vars in the loop. It doesn't return width/height in debug. I'm using tdm gcc 5.1.0.Framework brl.standardio Import brl.pixmap Strict Local mytex:TTexture2=TTexture2.CreateTexture2( 128,128 ) Print "mytex.width="+mytex.width+" mytex.height="+mytex.height Type TTexture2 Field pixmap:TPixmap Field width:Int,height:Int Function CreateTexture2:TTexture2(width:Int,height:Int,flags:Int=1,frames:Int=1,tex:TTexture2=Null) If tex=Null Then tex:TTexture2=New TTexture2 tex.pixmap=CreatePixmap(width*frames,height,PF_RGBA8888) Local pixmap:TPixmap Print "tex.pixmap.width="+tex.pixmap.width+" tex.pixmap.height="+tex.pixmap.height For Local i:Int=0 To 0 pixmap=tex.pixmap.Window(width,0,width,height) Print "pixmap.width="+pixmap.width+" pixmap.height="+pixmap.height tex.width=pixmap.width tex.height=pixmap.height Local width:Int=pixmap.width Local height:Int=pixmap.height Print "width="+width+" height="+height Next Return tex End Function End Type |
| ||
Thanks. The issue appears to be with args not being correctly added to the local function scope, which results in incorrect generation of internal local variable names. This isn't a problem in release mode, but becomes one in debug mode because local scope variables are declared at the start of the scope. The "width" arg for your pixmap.Window is then incorrectly referenced to the Local width variable declared later... :o) |
| ||
SuperStrict Framework Brl.StandardIO Function Test:int(param:int) print "function param: "+ param For local i:int = 0 to 0 print "before local param: "+ param local param:int = 20 print "after local param: "+ param Next End Function Test(10) Output vanilla: function param: 10 before local param: 10 after local param: 20 Output NG: function param: 10 before local param: 10 after local param: 20 So this isn't mixed (at least it does not look that way). bye Ron |
| ||
Derron, you didn't run it in debug? |
| ||
Lol...of course not. Somehow I forgot to check "debug" in MaxIDE ... thought it was on (as I use "MaxIDE" just when debugging my game) but MaxIDE of NG does not share its settings with MaxIDE of vanilla, so NG built a release variant. Excuse my mistake. bye Ron |
| ||
Should be fixed now. |
| ||
Thanks. Rebuilt bcc and brl.mod. Do I need to rebuild mods for this? I'm not sure but I don't think so. The example now gives: "Unhandled exception:Pixmap coordinates out of bounds" in debug and works in release, width/height are good before being passed to pixmap.Window. |
| ||
You should probably rebuild everything with this change. Unhandled exception Dunno, but the generated variables look correct now in the example code you provided. The pixmap is created with a width of 128, and a height of 128 The code says : pixmap=tex.pixmap.Window(width,0,width,height) So, pixmap=tex.pixmap.Window(128,0,128,128) Isn't that out of bounds? According to the assert : x>=0 And width>=0 And x+width<=Self.width So, 128>=0 And width>=0 And 128+128<=128 which is false. There are no assertions in Release mode. Unless I'm reading it wrong? |
| ||
Looking at the minib3d source on GitHub, the original example multiplies the first arg by zero on the first instance:pixmap=tex.pixmap.Window(x*width,0,width,height) which would give a valid pixmap window : pixmap=tex.pixmap.Window(0*128,0,128,128) :-) |
| ||
Doh! My bad, should've left the x in. Sorry about that. And I was too lazy to build sidesign and test, oops. And yes, I had to rebuild sidesign to get tex_render example working in debug. But it works! |