Mojo2 does not build with latest BMK and BCC

BlitzMax Forums/Brucey's Modules/Mojo2 does not build with latest BMK and BCC

seriouslee(Posted 2016) [#1]
Pulled the latest bmk, bcc, brl.mod and pub.mod this evening for NG. When I tried to recompile my project using mojo2, I got the following warnings:


Compile Warning: In call to Function glBufferData:Int(Local target_:Int,Local size_:Int,Local data_:Byte Ptr,Local usage_:Int). Argument #2 is "Long" but declaration is "Int".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;162;0]

Compile Warning: In call to Method TDrawList.Transform(Local ix:Float,Local iy:Float,Local jx:Float,Local jy:Float,Local tx:Float,Local ty:Float). Argument #1 is "Double" but declaration is "Float".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;1795;0]

Compile Warning: In call to Method TDrawList.Transform(Local ix:Float,Local iy:Float,Local jx:Float,Local jy:Float,Local tx:Float,Local ty:Float). Argument #2 is "Double" but declaration is "Float".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;1795;0]

Compile Warning: In call to Method TDrawList.Transform(Local ix:Float,Local iy:Float,Local jx:Float,Local jy:Float,Local tx:Float,Local ty:Float). Argument #3 is "Double" but declaration is "Float".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;1795;0]

Compile Warning: In call to Method TDrawList.Transform(Local ix:Float,Local iy:Float,Local jx:Float,Local jy:Float,Local tx:Float,Local ty:Float). Argument #4 is "Double" but declaration is "Float".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;1795;0]

Compile Warning: In call to Function glColorMask:Int(Local red_:Byte,Local green_:Byte,Local blue_:Byte,Local alpha_:Byte). Argument #1 is "Int" but declaration is "Byte".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;3122;0]

Compile Warning: In call to Function glColorMask:Int(Local red_:Byte,Local green_:Byte,Local blue_:Byte,Local alpha_:Byte). Argument #2 is "Int" but declaration is "Byte".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;3122;0]

Compile Warning: In call to Function glColorMask:Int(Local red_:Byte,Local green_:Byte,Local blue_:Byte,Local alpha_:Byte). Argument #3 is "Int" but declaration is "Byte".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;3122;0]

Compile Warning: In call to Function glColorMask:Int(Local red_:Byte,Local green_:Byte,Local blue_:Byte,Local alpha_:Byte). Argument #4 is "Int" but declaration is "Byte".
[C:/BMXng/mod/mky.mod/mojo2.mod/graphics.bmx;3122;0]



The project does not compile with a very long list of errors. I've reverted back to the older bmk and bcc, keeping brl.mod and pub.mod and the project compiles fine after rebuilding mods.


Derron(Posted 2016) [#2]
Seems you use the newly introduced "-w" param (should be included in Brucey's MaxIDE already).
So instead of stopping the compilation it only prints warnings (concerning param widening and overload-functionality).


To get rid of them: fix these issues :-)


What has changed?
With the introduction of "overloadable functions/methods" Brucey also needed to check for given params. Now it does not find the function-definition "glBufferData:Int(int,long,byte ptr, int)" because it does not exist (but it could, as "overloading" is now possible).
The original function is "glBufferData:Int(int,int,byte ptr, int)" but you are not calling it.
Solution: go to line 162 of the blamed graphics.bmx and change the line to glBufferData GL_ELEMENT_ARRAY_BUFFER,int(idxs.Size()),idxs._buf,GL_STATIC_DRAW".
The reason is: Size() returns a Long in BMX-NG (>4GB support) which vanilla does not.


Ok so what about this "-w"-param for BMK? It then let's you compile this code unchanged as long as there is only exactly _one_ definition of the called function (read: "overload" is not used).
When I blamed that same problem to Brucey the solution was to output a warning, so the developer knows at which line he uses vague assumptions about data types. So the end is that you get a list of warnings (with the chance to fix it) instead of breaking the compilation each time without knowing what there might be else left to fix.


@ "local varname:type, local ..."
I assume this is kind of a bug, there is no need to have this long-style there.


As you only got compile warnings (else you would only have the first problem printed, not the follow ups) you already used "-w". What _errors_ did you get as you mentioned it is no longer compileable.


bye
Ron


seriouslee(Posted 2016) [#3]
Yes, I am using the latest and greatest MaxIDE using the "-w" param.

I opened graphics.bmx and applied the appropriate castings. The module compiles now without warnings.

The project also compiles and executes without error. I like the warning messages. They certainly helped fix these issues. But the methods that produced the warnings did not compile, so it seems like they are not warnings but errors.

Also, it looks like math functions are returning doubles as we can see in the method below:

Rem
bbdoc: Rotates the current 2d matrix.
end rem
Method Rotate( rz:Float )
	Transform Float( Cos( rz ) ),Float( -Sin( rz ) ),Float( Sin( rz ) ),Float( Cos( rz ) ),0,0
End Method


Casting the math functions back to a float resolves the issue, but that seems like it could break a lot of things, or maybe they've always returned doubles but BMax auto casted it? I'm guessing here.


Brucey(Posted 2016) [#4]
The latest mojo2 should build cleanly with the very latest bcc.

The latest bcc has been updated so that you shouldn't need to do things like cast from False to Byte...


seriouslee(Posted 2016) [#5]
Thanks, Brucey!

Mojo2 compiles cleanly, but when I try to use it, I get an exception_access_violation. I do not get line number information, but in debug it looks like it is in the InitVbos function being called from InitMojo2.

This is Windows 10, bcc version is 0.76, bmk is 3.11. GCC version is 5.1.0. Compile options in IDE are debug, threaded, build gui app, quickscan, and overload warnings. Compiling x64.

EDIT:

I'm trying to run the mojotest from the examples folder as a baseline. Get the following errors:


[100%] Linking:mojotest.debug.mt.exe
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/sdlsystem.debug.mt.win32.x64.a(glue.c.debug.mt.win32.x64.o): In function `bmx_SDL_EmitSDLEvent':
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/glue.c:143: undefined reference to `sdl_sdlsystem_TSDLMultiGesture__getGesture'
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/glue.c:145: undefined reference to `sdl_sdlsystem_TSDLMultiGesture__freeGesture'
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/glue.c:143: undefined reference to `sdl_sdlsystem_TSDLMultiGesture__getGesture'
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/glue.c:145: undefined reference to `sdl_sdlsystem_TSDLMultiGesture__freeGesture'
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/glue.c:143: undefined reference to `sdl_sdlsystem_TSDLMultiGesture__getGesture'
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/glue.c:145: undefined reference to `sdl_sdlsystem_TSDLMultiGesture__freeGesture'
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/sdlsystem.debug.mt.win32.x64.a(glue.c.debug.mt.win32.x64.o): In function `bmx_SDL_EventFilter':
C:/BmxTest/mod/sdl.mod/sdlsystem.mod/glue.c:487: undefined reference to `sdl_sdlsystem_TSDLSystemDriver__eventFilter'
Build Error: Failed to link C:/BmxTest/mod/mky.mod/mojo2.mod/examples/mojotest/mojotest.debug.mt.exe




Brucey(Posted 2016) [#6]
Oops. Apologies.

Should be all working now (updated mky project).


seriouslee(Posted 2016) [#7]
That did the trick. Mojotest compiles and run cleanly. Thanks, again.

And no apologies are necessary! I appreciate ALL you do in Blitz and for the community. Thanks!


Dabhand(Posted 2016) [#8]
I've built a new Windows package (0.76),wrapped it up and plonked it over at bmxng.com... With a little note stating the "-w" parameter when building modules.

Should keep people at bay for a bit! :D

Dabz