minib3d setting Texture..

Hardcoal

New member
Joined
Jul 4, 2020
Messages
28
Hi
Im trying to set texture to a simple cube, after using createcube command

im using LoadTexture command and try to do EntityTexture on the cube..
but it keep getting stuck and do nothing..

I even did .. TPixmap.PreLoadPixmap([]) before and still it didnt work..

i put the texture on a .data folder.. so thats not it..

cheers
 

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,453
As there are basically no users here that use MiniB3d, could you attach a small project so I can try myself?
 

Hardcoal

New member
Joined
Jul 4, 2020
Messages
28
im just a begginer in minib3d though i know b3d very well..
ive checked a demo of minib3d and there version managed to work
but mine doesnt..
ill try a bit more and if not ill post here the code..

this is my first days of using cerberus though i have some expirience with monkey from years ago..

do people use vortex as the main 3d engine? or are there other alternatives ?
 

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,453
I don't know.

Edit: let me rephrase that. I don't know of any other users here who develop a 3d game.
Personally i would use AGK Classic with CX. That is till we have our own supported solution. Which is on the map. But first i want to integrate a new render backend
 
Last edited:

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,453
Ok, tested this myself, here on GLFW and HTML5:

Cerberus:
Strict
#HTML5_APP_FILENAME="index.html" 'Set the default name for the html outfile.
#HTML5_APP_TITLE="Cerberus Game - Example textured cube"         'Set the title inside the browser tab.
#GLFW_WINDOW_TITLE="Cerberus Game - Example textured cube"

Import minib3d

Function Main:Int()
    New Game
    Return 0
End

Class Game Extends App
    
    Field cam:TCamera
    
    Field light:TLight
    Field cube:TMesh
    Field txt:TText
    
    ' used by fps code
    Field old_ms:Int
    Field renders:Int
    Field fps:Int
    
    Field a:Float=0, dir:Int=0, oldTouchX:Int, oldTouchY:Int, touchBegin:Int, lr#, ud#
    'Field anim_time:Int
    
    Field redbrush:TBrush

    Field init_gl:Bool = False
    
    '--------------------------------------------------------
    Method OnCreate:Int()
        SetRender()   
        SetSwapInterval (0)
        SetUpdateRate (0)
        Return 0
    End

    '--------------------------------------------------------
    Method Init:Int()
        
        If init_gl Then Return 0
        
        If Not TPixmap.PreLoadPixmap(["cx.png","mojo_font.png"])   
            Return 0
        Endif
        
        init_gl = True

        cam = CreateCamera()
        cam.CameraClsColor(0,0,80)
        cam.PositionEntity 0,4,-7
        
        light=CreateLight(1)
        light.PositionEntity 0,3,-3
        
        cube=CreateCube()
        'cube.ScaleEntity(0.5,0.5,0.5)
        cube.name = "cube"
        PositionEntity cube,0,2,2
                
        redbrush = New TBrush
        redbrush.BrushColor(255,255,255)
        redbrush.LoadTexture("cx.png")             '<--------
        cube.PaintEntity( redbrush)
        
        txt = TText.CreateText2D()
        'txt.NoSmooth()

        old_ms=Millisecs()
        
        'Wireframe(True)
        
        Print "main: init done"
        Return 0
    End
    
    '--------------------------------------------------------
    Method OnUpdate:Int()
    
        If KeyHit(KEY_CLOSE) Or KeyHit(KEY_ESCAPE) Then Error ""
        
        If Not init_gl Then Init(); Return 0
        
        ' control camera
        Local cr:Float = KeyDown(KEY_LEFT)-KeyDown(KEY_RIGHT)
        Local cu:Float = KeyDown(KEY_DOWN)-KeyDown(KEY_UP)
        
        Local camin:Float = KeyDown(KEY_W)-KeyDown(KEY_S)
        Local camup:Float = KeyDown(KEY_D)-KeyDown(KEY_A)
        
        Local turnzx:Float = KeyDown(KEY_Z)-KeyDown(KEY_X)
        
        If TouchDown(0) And Not TouchDown(1)
            If Not touchBegin
                oldTouchX = TouchX()
                oldTouchY = TouchY()
                touchBegin = 1
            Endif
            lr = (TouchX() - oldTouchX) * 0.5
            ud = (-TouchY() + oldTouchY) *0.5
            oldTouchX = TouchX()
            oldTouchY = TouchY()
        Elseif TouchDown(1)
            If Not touchBegin
                oldTouchX = TouchX()
                oldTouchY = TouchY()
                touchBegin = 1
            Endif
            camup = (-TouchX() + oldTouchX) * 0.1
            camin = (-TouchY() + oldTouchY) *0.1
            oldTouchX = TouchX()
            oldTouchY = TouchY()
        Else
            touchBegin = 0
        Endif
        
        TurnEntity cube,turnzx*2,0,0
        MoveEntity cube,(lr)*0.2,0,ud*0.1'camup,0,camin
        
        cam.MoveEntity camup,0,camin
        cam.TurnEntity cu,cr,0

        txt.SetText(fps+" fps")
        txt.HideEntity()
        txt.Draw(0,0)
        
        ' calculate fps
        If Millisecs()-old_ms >= 1000
            old_ms=Millisecs()
            fps=renders
            renders=0
        Endif
        
        UpdateWorld()
        Return 0
    End
    
    '--------------------------------------------------------
    Method OnRender:Int()

        RenderWorld()
        renders=renders+1
        Return 0
    End

End
 

Hardcoal

New member
Joined
Jul 4, 2020
Messages
28
OK thanks Mike.. i finally figured out what was wrong..
it was several things..
but one of them was that i came from a pc only apps making background..

I didnt allow the images to load using PreLoadPixmap.
I mean i used to command but without the Return 0..

Its a totally different mindset i need to adopt.. or partially

but it works now..
 
Top Bottom