Skip to content

Instantly share code, notes, and snippets.

@ruby0x1
Created April 27, 2015 17:50
Show Gist options
  • Save ruby0x1/c2933ed7b9b18ed24ba5 to your computer and use it in GitHub Desktop.
Save ruby0x1/c2933ed7b9b18ed24ba5 to your computer and use it in GitHub Desktop.
luxe-alpha-2.0 initial work

Parcel:

  • new Parcel implementation
  • update options and creation options for all new resource types and settings
  • initial work toward parcel diff loading
  • add parcel event endpoints, for progress, complete, failed events
  • added ParcelChange type for information on progress or failure events
  • added length properties for counting resources
  • added state, for unloaded loading loaded
  • added listed which returns an array of resource id's in the parcel
  • added loaded which returns an array of resource id's that are loaded by this parcel
  • added oncomplete, onfailed and onprogress handlers in options
  • added bytes, texts, jsons, textures, fonts, shaders, sounds for constructor options
  • added is_loaded(id)
  • added skipping of already loaded assets
  • removed manual add_* api's
    • modify list
  • ParcelProgress
    • added no_visuals to bypass the default geometries for custom implementations
    • complete handler called before fade completes, not after
      • prevents "seeing" load complete responses happening
    • update for new Parcel event api instead of hijacking the onload/onprogress callbacks

Resources:

  • changed ResourceType.data to ResourceType.bytes and all associated calls/types
  • added new resource load/fetch api
  • all load actions return a Promise
  • all fetch actions return a strong type
  • added has, get for general queries
  • added invalidate(id)/destroy(id)
  • added a complete set of events for all resources
    • unknown / listed / loading / loaded / failed / destroyed / invalidated
  • added handling of reference counters from load calls

Resource:

  • added reload api handled by all resource types
  • added TextResource JSONResource BytesResource
    • these all contain a snow Asset type
    • which means:
      • previously res.text, res.json and res.bytes becomes
      • res.asset.text, res.asset.json and res.asset.bytes
  • added reference counting for handling destroy and sharing
    • tracked by Resources for you on load calls
    • will be used in subsequent additions re: parcel diff features
  • added resource state property, for listed, loading, loaded, failed etc
  • added invalidation and clearing
    • invalidate triggers an event, usually from some other event (like file change, context loss)
    • clear destroys asset/gpu/memory/other resources and slims down the instance to just state
    • clear is auto handled on reload, invalidate, and others

Texture:

  • implement new resource api
    • reload()/clear()
  • clearer toString details
  • Add Texture.default_filter and Texture.default_clamp #246
    • this is not retroactive
    • only textures created after this will be affected
  • Add Texture.max_size():Int
    • returns hardware max width/height
  • filter and clamp represented by their proper parts
    • reduces chance of state desync errors
    • to update, set both at once:
      • filter = becomes filter_min = filter_mag =
      • clamp = becomes clamp_s = clamp_t =
  • removed asset from texture resource
    • texture resource contains gpu resource only,
    • it shouldn't have been hanging ram references
  • removed onload handlers as resources are now imperative
    • use a parcel, the preload parcel, or use
    • Luxe.resources.load_texture(id, options).then(function(texture) { }
  • removed from_pixel, from_bytes creation conveniences
    • only from pixels because it's not managing a resource
    • use new Texture({ id:.., width:..., height:..., pixels:Uint8Array });
    • use Luxe.snow.assets.image(id) to get an AssetImage which gives you the bytes api's if needed
    • use texture.submit(pixels) if updating texture pixels
  • added submit/fetch clarity
    • fetch downloads the texture pixels into a given array
    • submit uploads the pixels from the given array
    • submits includes TextureSubmitTarget for uploading cubemap faces
  • bind state cached in ResourceState so that multiple binds have no real effect
  • initial pass on abstractions/flexibility
    • add border parameter used in submit
    • add format parameter to configure the gpu format (i.e GL.RGBA)
    • add type parameter to configure the gpu type, enabling 2D textures or Cube Maps (and future 3D texture types)
    • add data_type parameter to configure the gpu data type (i.e GL.UNSIGNED_BYTE)
    • add compressed flag for handling compressed formats.
      • only useful right now if you know what you're doing!
      • when submitting, compressedTexImage2D would be used instead of texImage2D

Screen:

  • changed w and h to Int type
  • added width and height to Float if needed
  • removed redundant cache values and error prone sync code
  • added bounds getter, returns a luxe.Rectangle for convenience
  • clarified that mid, size, bounds will return new instances
    • this is because cached values get modified by user code
    • immutability is in the new vector code for later alpha

Shaders:

  • implement new resource api
    • reload() / clear()
  • only set uniforms that are found (not all 8 for no reason)
  • added luxe_no_shader_prefix define short term
    • you don't need to define this unless you need to
  • clone requires an id for the clone (see below)
  • removed all inconsistent verbose flags and fixed error logging to be more logical
  • unified naming of vert_id and frag_id
  • gave a proper resource id, must be unique like all resource id's
    • that means the | combined stop gap is gone
  • when creating or specifying for loading, vert_id, frag_id and id are required
    • move to be explicit for usage code clarity
    • in the cases where you left one out:
      • use 'default' for vert_id
      • use 'default' for untextured and 'textured' otherwise

BitmapFont:

  • implement new resource api
    • reload() / clear()
  • remove from_string and other static api's
    • use new BitmapFont({ id:, pages:[], font_data:string });
  • moved parser and types into luxe/importers/

RenderState:

  • add bindTexture( type, tex ) abstraction
  • add bindTexture2D/bindTextureCube implementation
  • add ResourceState.bound_texture_2D/bound_texture_cube
    • for cases where the currently bound TextureID may be useful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment