Documentation

Everything you need to create a game with FRAG

Documentation is still very much a work in progress. Please understand there may be rapid changes to this section of the website.

Documentation Progress: 5%

Example

Minimal FRAG application implementing game loop



#Nim Standard Library Imports
import
  events
#Dependency Imports
import
  bgfxdotnim,
  sdl2 as sdl
#Frag Imports
import
  frag,
  frag/config,
  frag/graphics/window,
  frag/logger,
  frag/modules/graphics

type App = ref object

proc resize*(e: EventArgs) = let event = SDLEventMessage(e).event let sdlEventData = event.sdlEventData let graphics = event.graphics graphics.setViewRect(0, 0, 0, uint16 sdlEventData.window.data1, uint16 sdlEventData.window.data2)

proc initApp(app: App, ctx: Frag) = logDebug “Initializing app…” ctx.events.on(SDLEventType.WindowResize, resize)

proc updateApp(app:App, ctx: Frag, deltaTime: float) = discard

proc renderApp(app: App, ctx: Frag, deltaTime: float) = ctx.graphics.clearView(0, ClearMode.Color.ord or ClearMode.Depth.ord, 0x303030ff, 1.0, 0)

proc shutdownApp(app: App, ctx: Frag) = logDebug “Shutting down app…”

startFrag(App(), Config( rootWindowTitle: “Minimal FRAG Application”, rootWindowPosX: window.posUndefined, rootWindowPosY: window.posUndefined, rootWindowWidth: 960, rootWindowHeight: 540, resetFlags: ResetFlag.VSync, logFileName: “frag-app.log”, assetRoot: “../assets”, debugMode: BGFX_DEBUG_NONE ))