Brush-Problems
BlitzMax Forums/MiniB3D Module/Brush-Problems
| ||
I have a problem with CreateSurface() under MiniB3D. The skybox should show 6 different Textures, but it always shows the bottom texture. This happens on all graphics card on all Windows-versions. My original B3D-Code runs perfect under Win XP, The MINIB3D-Code runs also perfect on Mac OsX. No problems no graphic errors. Because I have heavy performance problems with B3D under WIN7, I tried to compile the MiniB3D-Version on Windows. Only the "Peter-Scheutz"-version was able to start, but produces this problem. SuperStrict 'Import sidesign.minib3d Import "minib3dsf/minib3d.bmx" Graphics3d 1024,768,0,2 Global t:TMesh=CreateCube() Global C:TCamera=CreateCamera() ambientlight 255,255,55 moveentity c,0,2,-5 Global sky:TMesh = LoadSkyBox() Repeat moveentity c,0.01,0,0.01 Renderworld() Flip 0 Until KeyHit(key_escape) Function LoadSkyBox:TMesh() Local m:TMesh = CreateMesh(), S:TSurface, B:TBrush 'front face: '... for demonstration of the problem one face is enough: '.... 'top face: 'b=LoadBrush( "SKY_UP.jpg",49 ) b=CreateBrush(0,255,255) ' BLUE s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,1 AddVertex s,+1,+1,+1,0,0 AddVertex s,+1,+1,-1,1,0 AddVertex s,-1,+1,-1,1,1 AddTriangle s,0,1,2 AddTriangle s,0,2,3 FreeBrush b 'bottom face: 'b=LoadBrush( "SKY_DN.jpg",49 ) b=CreateBrush(0,255,0) ' GREEN s=CreateSurface( m,b ) AddVertex s,-1,-1,-1,1,0 AddVertex s,+1,-1,-1,1,1 AddVertex s,+1,-1,+1,0,1 AddVertex s,-1,-1,+1,0,0 AddTriangle s,0,1,2 AddTriangle s,0,2,3 FreeBrush b ScaleMesh m,400,60,400 FlipMesh m EntityFX m,1 Return m End Function |
| ||
I don't know what's going on, but if you create the faces in reverse order (the bottom first) they both appeared here. Changing the LoadSkybox to this, also works: |
| ||
Found the problem... this one was easy! :) on tMesh.bmx you have: Look at brush = bru.copy() - this actually overwrites the mesh brush! just comment it out (or remove it, like below), and suddenly the example works :) |
| ||
@ SLotman Thanks a lot for this help. It really works now. I would never have the heart to change something inside modules... Is this an error in the module or could there be situations where this module code is correct? Next Problem: TEXT command error If you use the TEXT command of MINIB3D you will have graphic problems with the other object in the 2D-Section. They are all black SuperStrict 'Import sidesign.minib3d Import "minib3dsf/minib3d.bmx" Graphics3d 1024,768,0,2 Global t:TMesh=CreateCube() Global C:TCamera=CreateCamera() ambientlight 255,255,55 moveentity c,0,2,-5 Global font:Timagefont=LoadImageFont( "Arial.ttf",32,True ) Repeat moveentity c,0.01,0,0.01 RenderWorld() BeginMax2D SetColor 00,100,200 DrawRect 400,400,200,200 SetImageFont font DrawText "Hallo" ,0,0 ' Text 0,0,"Hallo" Endmax2d Flip 0 Until KeyHit(key_escape) You can see a blue Rect, but if you use the TEXT command instead of the DRAWTEXT command the box will be black. A possible solution would be to use the DRAWTEXT command. Is this another error in the MINIB3D? Next Problem: Performance Problems I have heavy performance problems with the FLIP command. Already in this simple sample (first post) the FLIP need 15 msec and in the WIN-MINIB3D version of my "Catching Scale Game" (http://www.midimaster.de/download/tonleiter_demo.exe) the combination of RenderWorld(), some 2D Graphics in Front of the 3D-world and the FLIP eats more than 45 msec. Is this normal? The WinXP-B3D version or the OsX-MiniB3D dont need such a lot of time! to test this behavior, replace the code: SuperStrict 'Import sidesign.minib3d Import "minib3dsf/minib3d.bmx" Graphics3d 1024,768,0,2 Global t:TMesh=CreateCube() Global C:TCamera=CreateCamera() ambientlight 255,255,55 moveentity c,0,2,-5 Global sky:TMesh = LoadSkyBox() Global TimeStamp%, V1%,v2%,v3% Repeat Local TimeStamp%=MilliSecs() moveentity c,0.01,0,0.01 v1= (MilliSecs()-TimeStamp) Renderworld() v2= (MilliSecs()-TimeStamp) Flip 0 v3= (MilliSecs()-TimeStamp) Print v1+ " " + v2 + " " + v3 Until KeyHit(key_escape) Function LoadSkyBox:TMesh() Local m:TMesh = CreateMesh(), S:TSurface, B:TBrush 'front face: ..... ..... |
| ||
The text problem, just don't put the Text inside "BeginMax2D" and "EndMax2D" and it works - just like regular B3D. Begin/End Max2D is only needed when using plaing Max2D code. As for performance 'problems', I tried your code, with my fps count function: Global fps:Float, fpst:Float=MilliSecs(),fpsc:Float Function CountFPS:Float() If MilliSecs()-fpst>=1000 Then fps=fpsc+1 fpsc=0 fpst=MilliSecs() Else fpsc = fpsc + 1 End If Return fps End Function Just add a Text 0,0,CountFPS() before the flip... and here it was running at 130+ fps, on a laptop radeon X1300, so no performance problems here for me. |
| ||
Thank you SLotman, this was very helpful I did not know this. On my MacOsX the TEXT command seems to work also within the MAX2D-area. Now I replaced it with DRAWTEXT and it works. The performance problems can be a result of my old graphic card. In avarage I also have 100+fps, but I can observe moments where one RenderWorld() needs 185 msec. I will test it on several computers and call back.... I had to separate all movings into a timer-based function call to make it independent from the Render performance problems. That seems to be a acceptable compromise. Transparency problem I still have a problem with a BMP-picture of a shoot, which has a black (transparent) area around the ball. It looks transparent on B3D and MINIB3D-OSX, but not under WIN-MINIB3D. Here I can see a white square. But no problem: After converting it to PNG it works! CameraFog Problem The CameraFog seems to bring different results on OSX-MINIB3D and WIN-MINIB3D. But also no problem. After adjusting it, it looks good. Now the game works and I can test it on a WIN7-64-System. [EDIT ] It seem to work on WIN7-64-Home Premium too! |