I am looking for complete guide how to compile wxMax

Started by takis76, July 17, 2019, 18:17:36

Previous topic - Next topic

takis76

I will write my game to 1.52 for now because all modules which I have so far work (More modules will be added in the future and depends of the games I will develop).
And when the NG will be ready with the same modules, I will recompile the game with the NG version too. (I do this to check if both versions of BlitzMax are working perfectly).

Derron

You should raise issues for stuff not working - else you can wait a long long long time until "out of luck" someone is using your "now not working" module XYZ and raises an issue. As said, not all 3rd party modules are necessarily maintained by Brucey/active users and if nobody uses them (publically) then nobody will  be aware of bugs, errors, ...


I do not know why you already seem to have given up with NG again? Did you do how I suggested here (and at github) ? What was the next error you encountered? Was it a similar one and you fixed it on your own and now were presented a newer one?


bye
Ron

takis76

Quote
You are using a more recent brl.mod than 0.105 - leading to this issue for "graphics modules". Just append "x:int var, y:int var" to the function definition in that srs.mod file and the error should be done.

You mean inside the file: d3d11graphics_ng.bmx
To change this:


'TGraphics
Method GetSettings:Int( width:Int Var,height:Int Var,depth:Int Var,hertz:Int Var,flags:Int Var)
width = _width
height = _height
depth = _depth
hertz = _hertz
flags = _flags
EndMethod


With this:



'TGraphics
Method GetSettings:Int(width:Int Var, height:Int Var, depth:Int Var, hertz:Int Var, flags:Int Var, x:int var, y:int var)
width = _width
height = _height
depth = _depth
hertz = _hertz
flags = _flags
EndMethod


It wasn't fixed... (Or I need to change something else).

We will talk again tomorrow...

dawlane

#93
Quote
   'TGraphics
   Method GetSettings:Int(width:Int Var, height:Int Var, depth:Int Var, hertz:Int Var, flags:Int Var, x:int var, y:int var)
      width = _width
      height = _height
      depth = _depth
      hertz = _hertz
      flags = _flags
   EndMethod

It wasn't fixed... (Or I need to change something else).

If you have been creating empty methods because of abstraction, or had to add additional parameters. Then use the IDE's Search in files(Shift+Ctrl+F) for the method name in question in the mod directory to find any custom type where the method is implemented. It will give you clues on how things need to be done. But you will have to look through the module sources of where you have made the empty methods or added additional parameters to see how it's been put together and work out the changes to make.

For example TGLGraphics implements GettSettings like so.
Method GetSettings( width Var,height Var,depth Var,hertz Var,flags Var, x Var, y Var ) Override
Assert _context
Local w,h,d,r,f,xp,yp
bbGLGraphicsGetSettings _context,w,h,d,r,f ' This more than likely will be a C/C++ function/method.
width=w
height=h
depth=d
hertz=r
flags=f
x=-1
y=-1
End Method

While TMax2DGraphics implements GettSettings like this.
Method GetSettings( width Var,height Var,depth Var,hertz Var,flags Var, x Var, y Var ) Override
Local w,h,d,r,f,xp,yp
_graphics.GetSettings w,h,d,r,f,xp,yp '  This will be an identifier that will in turn be another BlitzMax custom data type that may implement C/C++ code.
width=w
height=h
depth=d
hertz=r
flags=f
x=-1
y=-1
End Method

Derron

> It wasn't fixed... (Or I need to change something else).

So ... you seem to like worm everything out of us (Germans would say "require us to pull everything out of your nose" :-)). Why not give us the new error message instead? Yes, surely better to let us guess.


bye
Ron

takis76

I posted the issue in the Github and they suggested to replaces my method with this one:


'TGraphics
Method GetSettings:Int(width:Int Var, height:Int Var, depth:Int Var, hertz:Int Var, flags:Int Var, x:Int Var, y:Int Var)
width = _width
height = _height
depth = _depth
hertz = _hertz
flags = _flags
x = 0
y = 0
EndMethod


But it still not fixed.

New Error:

[  7%] Processing:d3d11graphics_ng.bmx
Compile Error: Can't create instance of type TD3D11Graphics due to abstract Method TGraphics.Position:Int(x:Int,y:Int).
[C:/Users/Takis/Desktop/BlitzMax/bmx-ng/mod/srs.mod/d3d11graphics.mod/d3d11graphics_ng.bmx;119;0]
Build Error: failed to compile (-1) C:/Users/Takis/Desktop/BlitzMax/bmx-ng/mod/srs.mod/d3d11graphics.mod/d3d11graphics_ng.bmx



Derron

So...write your own stub version of it. As stated it is for window positioning which is not supported with that renderer yet. So empty functions should do

Or use older brl.mods (provided with NG) but dunno then about other modules.


PS: They = Col and me.

Bye
Ron

takis76

#97
I posted an issue in GitHub.
The error was about Position method which wasn't exist.

Method Position:Int(x:Int Var, y:Int Var)
EndMethod

Also creating an empty method wasn't worked too.
I will try older brl. (Does it have to do with the brl)?

Derron

A type defines some methods as abstract..so every extending class needs to define the actual methods.

Srs.mod stuff "extends" from brl.graphics ...which defines such methods.

Srs.mod defines methods, but since the last srs.mod update the brl.mod received an update too. This update changed some of the methods in brl.graphics. so srs.mod needs updates too.
Col declined to update srs.mod yet - as it works with NG 0.105 .
You are using a newer brl.mod than the one of 0.105 - this leads to the errors you see and the changes you have to make (not that many).


Bye
Ron

takis76

#99
On the Github they gave a clue about missing x and y variables in methods.

In the file: d3d11graphics_ng.bmx there is one method with name GetSettings.


'TGraphics
Method GetSettings:Int(width:Int Var, height:Int Var, depth:Int Var, hertz:Int Var, flags:Int Var)
width = _width
height = _height
depth = _depth
hertz = _hertz
flags = _flags
EndMethod


It needs to be change like this:


'TGraphics
Method GetSettings:Int(width:Int Var, height:Int Var, depth:Int Var, hertz:Int Var, flags:Int Var, x:Int Var, y:Int Var)
width = _width
height = _height
depth = _depth
hertz = _hertz
flags = _flags
x = 0
y = 0
EndMethod


In the file: d3d11max2d_ng.bmx there is a method with name: CreateGraphics
The original code is this:


Method CreateGraphics:TGraphics(width:Int, height:Int, depth:Int, hertz:Int, flags:Int)
Local g:TD3D11Graphics = D3D11GraphicsDriver().CreateGraphics(width, height, depth, hertz, flags)
If Not g Return Null
Return TMax2DGraphics.Create(g, Self)
EndMethod


It needs to be replaced with this:


Method CreateGraphics:TGraphics(width:Int, height:Int, depth:Int, hertz:Int, flags:Int, x:Int, y:int)
Local g:TD3D11Graphics = D3D11GraphicsDriver().CreateGraphics(width, height, depth, hertz, flags, x, y)
If Not g Return Null
Return TMax2DGraphics.Create(g,Self)
EndMethod


There were missing the x and y variables and they need to be appended in the argument of the Method.
The module was compiled but there are other errors in the Render2Texture files:

d3d9renderimage.bmx
d3d11renderimage.bmx

In d3d11renderimage.bmx there is one method with name: Method ToPixmap:TPixmap(d3ddev:ID3D11Device, d3ddevcon:ID3D11DeviceContext)


Method ToPixmap:TPixmap(d3ddev:ID3D11Device, d3ddevcon:ID3D11DeviceContext)
Local pDesc:D3D11_TEXTURE2D_DESC = New D3D11_TEXTURE2D_DESC
_tex2D.GetDesc(pDesc)

Local pixmap:TPixmap = CreatePixmap(pDesc.Width, pDesc.Height, PF_RGBA8888)

' create a temp resource
pDesc.Usage = D3D11_USAGE_STAGING
pDesc.BindFlags = 0
pDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ
pDesc.MiscFlags = 0

Local pStage:ID3D11Texture2D
d3ddev.CreateTexture2D(pDesc, Null, pStage)
d3ddevcon.CopyResource(pStage, _tex2D)

Local map:D3D11_MAPPED_SUBRESOURCE = New D3D11_MAPPED_SUBRESOURCE
d3ddevcon.Map(pStage, 0, D3D11_MAP_READ, 0, map)
For Local y:Int = 0 Until pixmap.height
Local dst:Byte Ptr = pixmap.pixels + y * pixmap.pitch
Local src:Byte Ptr = map.pData + y * map.RowPitch
MemCopy(dst, src, pixmap.pitch)
Next
d3ddevcon.UnMap(pStage, 0)

pStage.Release_()

Return pixmap
EndMethod


You replace the line:


MemCopy(dst, src, pixmap.pitch)


With this line:


MemCopy(dst, src, size_t(pixmap.pitch))


In d3d9renderimage.bmx there is one method with name: Method OnDeviceReset(d3ddev:IDirect3DDevice9)


Method OnDeviceReset(d3ddev:IDirect3DDevice9)
Local width:Int = _persistpixmap.width
Local height:Int = _persistpixmap.height

d3ddev.CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, _texture, Null)
If _texture _texture.GetSurfaceLevel(0, _surface)

' use a staging surface to copy the pixmap into
Local stage:IDirect3DSurface9
d3ddev.CreateOffscreenPlainSurface(width, height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, stage, Null)

Local lockedrect:D3DLOCKED_RECT = New D3DLOCKED_RECT
stage.LockRect(lockedrect, Null, 0)

' copy the pixel data across
For Local y:Int = 0 Until _persistpixmap.height
Local srcptr:Byte Ptr = _persistpixmap.pixels + y * _persistpixmap.pitch
Local dstptr:Byte Ptr = lockedrect.pBits + y * lockedrect.Pitch
MemCopy dstptr, srcptr, _persistpixmap.width * 4
Next
stage.UnlockRect()

' copy from the staging surface to the render surface
d3ddev.UpdateSurface(stage, Null, _surface, Null)

' cleanup
stage.release_
_persistpixmap = Null
EndMethod


The line:


MemCopy dstptr, srcptr, _persistpixmap.width * 4


Needs to be replaced with:


MemCopy dstptr, srcptr, size_t(_persistpixmap.width * 4)


Then there is another one error in the file: d3d9renderimage.bmx
In the method with name: Method Init(d3ddev:IDirect3DDevice9, UseImageFiltering:Int)


Method Init(d3ddev:IDirect3DDevice9, UseImageFiltering:Int)
_d3ddev = d3ddev
_d3ddev.AddRef()

frames = New TD3D9RenderImageFrame[1]
frames[0] = New TD3D9RenderImageFrame.CreateRenderTarget(d3ddev, width, height)
If UseImageFiltering
TD3D9RenderImageFrame(frames[0])._magfilter=D3DTFG_LINEAR
TD3D9RenderImageFrame(frames[0])._minfilter=D3DTFG_LINEAR
TD3D9RenderImageFrame(frames[0])._mipfilter=D3DTFG_LINEAR
Else
TD3D9RenderImageFrame(frames[0])._magfilter=D3DTFG_POINT
TD3D9RenderImageFrame(frames[0])._minfilter=D3DTFG_POINT
TD3D9RenderImageFrame(frames[0])._mipfilter=D3DTFG_POINT
EndIf


'  clear the new render target surface
Local prevsurf:IDirect3DSurface9
Local prevmatrix:Float[16]
Local prevviewport:D3DVIEWPORT9 = New D3DVIEWPORT9
' get previous
d3ddev.GetRenderTarget(0, prevsurf)
d3ddev.GetTransform(D3DTS_PROJECTION, prevmatrix)
d3ddev.GetViewport(prevviewport)

' set and clear
d3ddev.SetRenderTarget(0, TD3D9RenderImageFrame(frames[0])._surface)
d3ddev.SetTransform(D3DTS_PROJECTION, _matrix)
d3ddev.Clear(0, Null, D3DCLEAR_TARGET, 0, 0.0, 0)

' reset to previous
_d3ddev.SetRenderTarget(0, prevsurf)
_d3ddev.SetTransform(D3DTS_PROJECTION, prevmatrix)
_d3ddev.SetViewport(prevviewport)

' cleanup
prevsurf.release_
EndMethod


This generates this error:
Compile Error: Unable to find overload for getviewport(D3DVIEWPORT9). Argument #1 is "D3DVIEWPORT9" but declaration is "Byte Ptr"

This line:


d3ddev.GetViewport(prevviewport)


Needs to changed:

We don't have this fix yet the developer can solve this problem.
Maybe it will need to be casted as Byte Ptr.


Derron

You can always try what happens if you cast the param to Byte Ptr.

As I said in the github issue I am not sure about it (especially not when doing all this stuff here by phone).

Even if it crashes then you might see other errors to correct meanwhile.


Bye
Ron