Page 2 of 4

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Wed Jul 31, 2019 4:57 pm
by Mijikai
gurj wrote:In your first post, no 'nautilusCreate' was found.
and, i test your first Example: Image...
The first post only showed (now removed) the interface functions.
Please download the library & include from one of the links provided in the first post.

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Thu Aug 01, 2019 4:05 am
by kvitaliy
Mijikai wrote:Version 1.00 :)

Finally :D
No link to the final version?

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Thu Aug 01, 2019 8:32 am
by applePi
@Mijikai, your engine works okay, i tested Version 0.35 beta with winXP/32 PB570
i want to calculate positions of thousands of points ONCE and then after the calculations rendering it , how to do that ?
here i plot thousands of points randomly , but it keeps calculating continuously between *engine\RenderBegin and *engine\RenderEnd(). and i want to calculate the positions outside this Loop and then rendering the result. the meaning i don't know how you implements it in glLists or vbo or something else.

Code: Select all

EnableExplicit

XIncludeFile "nautilus.pbi"
Global x,y,i,r,g,b,col
Structure VECTOR_STRUCT
  x.f
  y.f
EndStructure

Procedure.i Demo(Width.i,Height.i,Title.s,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected win.i
  Protected win_handle.i
  Protected win_flag.i
  Protected win_msg.i
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_delta.f
  Protected engine_fps.i
  Protected engine_error.i
  Protected *collision.NAUTILUS_COLLISION
  
  win_flag|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
  win_flag|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  win = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,win_flag)
    
  If win
    win_handle = WindowID(win)
    *engine = nautilusCreate(win_handle,ViewWidth,ViewHeight,FPS)
    If *engine
      *engine\RenderAspect()
      Repeat
        Repeat
          win_msg = WindowEvent()
          If win_msg = #PB_Event_CloseWindow
            Break 2
          EndIf 
        Until win_msg = #Null

        *engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
        For i=1 To 5000
          x=Random(500): y=Random(500)
          r=Random(255):g=Random(255):b=Random(255)
          col = RGBA(r,g,b,255)
        *engine\DrawPointSize(5)
        *engine\DrawPoint(x,y, col)
        Next
      
        *engine\RenderEnd()
        If engine_error
          Break
        EndIf 
      ForEver
      *engine\Release()
    EndIf 
    CloseWindow(win)
  EndIf
EndProcedure

Demo(800,600,"Points",600,400,30)

End

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Thu Aug 01, 2019 2:09 pm
by Mijikai
applePi wrote:@Mijikai, your engine works okay, i tested Version 0.35 beta with winXP/32 PB570
i want to calculate positions of thousands of points ONCE and then after the calculations rendering it , how to do that ?
here i plot thousands of points randomly , but it keeps calculating continuously between *engine\RenderBegin and *engine\RenderEnd(). and i want to calculate the positions outside this Loop and then rendering the result. the meaning i don't know how you implements it in glLists or vbo or something else.
Even if every positions was calculated beforehand - there is no engine function to render it at once.

Luckily all OpenGL commands are still usable :)

So here is an example that uses a gl list:

Code: Select all

EnableExplicit

XIncludeFile "nautilus.pbi"

Structure VECTOR_STRUCT
  x.f
  y.f
EndStructure

Procedure.i Points();create a list
  Protected index.i 
  Protected lst.i
  Protected color,i
  Protected pos.VECTOR_STRUCT
  lst = glGenLists_(1)
  glNewList_(lst,#GL_COMPILE)
  glBegin_(#GL_POINTS)
  For index = 0 To 4999
    color = RGBA(Random(255),Random(255),Random(255),255)
    pos\x = Random(500)
    pos\y = Random(500)
    glColor3ubv_(@color) 
    glVertex2fv_(@pos)
  Next
  glEnd_()
  glEndList_()
  ProcedureReturn lst
EndProcedure

Procedure.i Demo(Width.i,Height.i,Title.s,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected win.i
  Protected win_handle.i
  Protected win_flag.i
  Protected win_msg.i
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_delta.f
  Protected engine_fps.i
  Protected engine_error.i
  Protected *collision.NAUTILUS_COLLISION
  Protected dlst.i
  win_flag|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
  win_flag|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  win = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,win_flag)
  If win
    win_handle = WindowID(win)
    *engine = nautilusCreate(win_handle,ViewWidth,ViewHeight,FPS)
    If *engine
      *engine\RenderAspect()
      *engine\DrawPointSize(5)
      dlst = Points();<- create a point lst
      Repeat
        Repeat
          win_msg = WindowEvent()
          If win_msg = #PB_Event_CloseWindow
            Break 2
          EndIf 
        Until win_msg = #Null

        *engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
        
        glDisable_(#GL_TEXTURE_2D)
        glCallList_(dlst);<- render everything
        glEnable_(#GL_TEXTURE_2D);<- needed the engine expects this to be enabled by default!
        
        *engine\RenderEnd()
        If engine_error
          Break
        EndIf 
      ForEver
      *engine\Release()
    EndIf 
    CloseWindow(win)
  EndIf
EndProcedure

Demo(800,600,"Points",600,400,30)

End

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Thu Aug 01, 2019 2:18 pm
by Mijikai
kvitaliy wrote:
Mijikai wrote:Version 1.00 :)

Finally :D
No link to the final version?
Dont worry :)
Im still working on example codes ill post the link when everything is ready.

I was rightfully criticized when i briefly posted the link without any
examples or documentation so im fixing that now.

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Thu Aug 01, 2019 5:21 pm
by applePi
nice example Mijikai, thank you.
this is useful for displaying the time consuming images such as fractals like Mandelbrot set and so on.
in the example here: viewtopic.php?f=14&t=73077&start=0#p538774
line 64 a typo mistake *collision\LineLineEx, should be *collision\LineEx
Thanks for letting OpenGL commands still usable, we can this way use your engine to display the hard parts of opengl which we don't know how to achieve such as mouse, text display, fonts, and many other things.

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Thu Aug 01, 2019 6:11 pm
by Mijikai
Thanks for the reply :)

Just had some time to play around a bit and it looks like all engine functions can also be used in a list:

Code: Select all

Procedure.i Points(*engine.NAUTILUS_ENGINE);create a list
  Protected index.i 
  Protected lst.i
  Protected color,i
  Protected pos.VECTOR_STRUCT
  lst = glGenLists_(1)
  glNewList_(lst,#GL_COMPILE)
  glBegin_(#GL_POINTS)
  For index = 0 To 4999
    *engine\DrawPoint(Random(500),Random(500),RGBA(Random(255),Random(255),Random(255),255))
  Next
  glEnd_()
  glEndList_()
  ProcedureReturn lst
EndProcedure
So i decided to provide functions for it in the next release :D

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Fri Aug 02, 2019 11:02 am
by Mijikai
Did some work i also decided to add some functions for creating a window :)

Preview:

The code also renders a gl list but uses the new engine functions 8)

Code: Select all

EnableExplicit

XIncludeFile "nautilus.pbi"

Procedure.i Demo(Title.s,Width.i,Height.i,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_fps.i
  Protected point_list.i
  Protected index.i
  *engine = nautilusWindow(Title,Width,Height,#Null,ViewWidth,ViewHeight,FPS)
  If *engine
    *engine\DrawPointSize(5)
    point_list = *engine\DrawListBegin()
    If point_list
      For index = 0 To 4999
        *engine\DrawPoint(Random(320),Random(200),RGBA(Random(255),Random(255),Random(255),255))
      Next
      *engine\DrawListEnd()
    EndIf 
    Repeat
      *engine\RenderBegin(#Null,@engine_fps)
      *engine\DrawList(point_list)
      *engine\RenderEnd()
      nautilusWindowTitle(*engine," FPS: " + Str(engine_fps),#True)
    Until nautilusWindowExit()
    *engine\DrawListDelete(point_list)
    nautilusWindowClose(*engine)
  EndIf 
EndProcedure

Demo(#Null$,800,600,320,200,60)
A list can also be rendered onto a layer :wink:

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Thu Aug 15, 2019 9:31 pm
by Mijikai
Release Version 1.03
- New Function: The Window Mode can now be changed
- Bug Fixes

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Tue Apr 14, 2020 3:50 am
by slagusev
Download link does not work (

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Tue May 19, 2020 2:27 pm
by Mijikai
Update: Version 1.044
- new interface for isometric games!

Interface:

Code: Select all

Interface NAUTILUS_WORLD_ISO
  CameraCreate.i(X.f,Y.f,Width.f,Height.f)
  CameraPosition.i(Camera.i,*InCartesian,*InOffset = #Null)
  CameraMove.i(Camera.i,*InCartesian,*InOffset = #Null)
  CameraZoomSet.f(Camera.i,Min.f,Max.f,*InScale = #Null)
  CameraZoomGet.f(Camera.i)
  CameraUnit.i(Camera.i,*OutUnit)
  CameraCartesian.i(Camera.i,*OutCartesian)
  CameraIsometric.i(Camera.i,*OutIsometric)
  CameraClamp.i(Camera.i,*OutClamp)
  CameraUpdate.i(Camera.i,*OutTranslation = #Null)
  CameraFree.i(Camera.i)
  TilesCreate.i()
  Tiles.i()
  TilesX.i()
  TilesY.i()
  TileSet.i(X.i,Y.i,Link.i)
  TileGet.i(X.i,Y.i)
  TileUnit.i(X.i,Y.i,*OutUnit)
  TileCartesian.i(X.i,Y.i,*OutCartesian)
  TileIsometric.i(X.i,Y.i,*OutIsometric)
  TileTranslate.i(Camera.i,X.i,Y.i,*OutPosition,*OutCartesian = #Null,*OutLink = #Null)
  TilesFree.i()
  Mouse.i(Camera.i,*InMouse,*OutCartesian,*OutUnit = #Null)
  TestUnit.i(*InUnit)
  TestCartesian.i(*InCartesian)
  WorldToScreen.i(Camera.i,*InCartesian,*OutPosition)
  ScreenToWorld.i(Camera.i,*InPosition,*OutCartesian,*OutUnit = #Null)
  Translate.i(Camera.i,*InIsometric,*OutPosition)
  Unit.i(*InCartesian,*OutUnit)
  Cartesian.i(*InUnit,*OutCartesian)
  Isometric.i(*InCatesian,*OutIsometric)
  Release.i()
EndInterface
Image

Code:

Code: Select all

EnableExplicit

XIncludeFile "nautilus.pbi"

;isometric demo

Procedure.i Main()
  Protected *engine.NAUTILUS_ENGINE
  Protected *iso.NAUTILUS_WORLD_ISO
  Protected cam.i
  Protected cam_zoom.f
  Protected cam_position.NE_VECTOR
  Protected cam_move.NE_VECTOR
  Protected cam_clamp.NE_CLAMP
  Protected px.i
  Protected py.i
  Protected position.NE_VECTOR
  Protected link.i
  Protected mouse.NE_VECTOR
  Protected mouse_cartesian.NE_VECTOR
  Protected mouse_unit.NE_INDEX
  Protected tiles.i
  Protected engine_delta.f
  *engine = nautilusWindow("TEST",800,600,#NE_WINDOW_NORMAL,800,600)
  If *engine
    *iso = *engine\CreateWorldIso(100,100,40,20);100 x 100 tiles / each tile is 40 x 20 pixels!
    If *iso
      cam = *iso\CameraCreate(100,100,600,400);camera 'viewport' offset: 100 x 100 & size: 600 x 400
      *iso\TilesCreate();create iso tilemap
      cam_position\x = 128
      cam_position\y = 128
      *iso\CameraPosition(cam,@cam_position);position the cam @cartesian pos 128 x 128
      cam_zoom = 0.8
      *iso\CameraZoomSet(cam,0.5,4,@cam_zoom);set camera zoom (this will change the render matrix so store it before!)
      For px = 0 To 99;assing a value to all tiles (could be anything like a pointer to a structure)
        For py = 0 To 99
          *iso\TileSet(px,py,Random(2))
        Next
      Next
      Repeat
        If *engine\InputKey(#VK_A);check 'wasd' keys
          cam_move\x - 2 * engine_delta
          cam_move\y + 2 * engine_delta
        EndIf
        If *engine\InputKey(#VK_D)
          cam_move\x + 2 * engine_delta
          cam_move\y - 2 * engine_delta
        EndIf
        If *engine\InputKey(#VK_S)
          cam_move\x + 2 * engine_delta
          cam_move\y + 2 * engine_delta
        EndIf
        If *engine\InputKey(#VK_W)
          cam_move\x - 2 * engine_delta
          cam_move\y - 2 * engine_delta
        EndIf
        *engine\InputMouse(@mouse);get the mouse position
        *engine\RenderBegin(#Null,@engine_delta);start rendering
        *engine\DrawText(10,10,"TILES RENDERED: " + Str(tiles));how many tiles are currently rendered
        cam_zoom + *engine\InputMouseWheel() / 1000;get the mousewheel input
        *iso\CameraZoomSet(cam,0.5,4,@cam_zoom);set the zoom according to the mousewheel
        If *iso\Mouse(cam,@mouse,@mouse_cartesian,@mouse_unit);translate the mouse to the actual cartesian postition
          *iso\TileSet(mouse_unit\x,mouse_unit\y,3);if the mouse is over the tile make it red -> value 3
          *engine\DrawText(10,20,"MOUSE POSITION: " + StrF(mouse_cartesian\x,0) + " x " + StrF(mouse_cartesian\y,0));if mouse is inside the iso camere display its position
        EndIf
        *engine\RenderClip(100,100,600,400);render this will clip all tiles at the camera boundary
        *engine\RenderPush();this will backup the render matrix
        *iso\CameraMove(cam,@cam_move);move the camera to the new position
        *iso\CameraUpdate(cam);update the camera
        *iso\CameraClamp(cam,@cam_clamp);clamp - determine what tiles can be drawn - what tile are visible
        tiles = 0
        For px = cam_clamp\min\x To cam_clamp\max\x
          For py = cam_clamp\min\y To cam_clamp\max\y
            If *iso\TileTranslate(cam,px,py,@position,#Null,@link);translate the the tile accroding to the camera
              Select link;if the tile is visible draw it - color it according to the 'linked' value
                Case 0:*engine\DrawDiamond(position\x,position\y,40,20,#False,#True,$FF444444)
                Case 1:*engine\DrawDiamond(position\x,position\y,40,20,#False,#True,$FF222222)
                Case 2:*engine\DrawDiamond(position\x,position\y,40,20,#False,#True,$FF111111)
                Case 3:*engine\DrawDiamond(position\x,position\y,40,20,#False,#False,$FF0000DD)
              EndSelect
              tiles + 1
            EndIf
          Next
        Next
        *engine\RenderPop();restore the render matrix
        *engine\RenderUnclip();unclip the render area
        *engine\DrawBox(100,100,600,400); draw a box just to show the camera 'view'
        *engine\RenderEnd();stop rendering
      Until *engine\WindowExit()
      *iso\Release()
    EndIf
    *engine\Release()
  EndIf
  ProcedureReturn #Null
EndProcedure

Main()

End
Download Engine & Iso Example (x64):
https://www.dropbox.com/s/r71inwbfb8nm9 ... 4.zip?dl=0

More Examples & Demos:
https://www.dropbox.com/s/agw30e7j189y0 ... o.zip?dl=0

Have fun playing around :D

Im still working on it :)
Dokumentation is still not done.

Let me know if u have any questions / criticism.

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Tue May 19, 2020 8:30 pm
by ar-s
Sorry Mijikai but can't launch any code.. Polink error.. (PB 5.72 x86/x64)
Do we have to copy ne.lib anywhere ?
Please, before spreading usefull tools like that, start by an install.txt if needeed.

Thanks for your work.

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Tue May 19, 2020 8:43 pm
by Mijikai
Thanks for testing, i hope this helps:
ne.lib and ne.dll need to be in the same directory as the soure file and nautilus.pbi.
Use the x64 Compiler (PB 5.72 should work fine) :)

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Tue May 19, 2020 10:43 pm
by ar-s
It's my own fault, sorry, my compiler PB72 was on x86... Sorry
Thanks for sharing. I look forward to more examples.

Re: [ENGINE] 2D Engine Nautilus (Win)

Posted: Fri May 22, 2020 5:53 pm
by Mythros
Where to download this?!