Advertisement
ds84182

gxt1_test1

Jun 19th, 2014
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local fs = require "filesystem"
  2. local component = require "component"
  3.  
  4. local gx = require "gx-t1"
  5. --gx tier 1 tech demo--
  6.  
  7. gx.init() --this is called to reinitialize the gx.
  8. print("GX Initialized")
  9. gx.loadTexture(GX_TEXID1, "/lib/gx-t1/font.gxt", GX_FMT_BASE85) --uploads the texture to the GX
  10. print("Loaded texture")
  11. --GXTextures are a custom compressed texture format.
  12. --Most textures are converted to base85
  13. --that texture is a tiled font of some sort (Minecraft font perhaps?)
  14.  
  15. gx.setTextureSlot(GX_TEXSLOT1, GX_TEXID1) --every tier 1 gpu has 15 tex slots, bind the slot to the first one
  16. gx.setTextureSlotVariable(GX_TEXSLOT1, GX_TEXSLOT_VAR_TILESIZE, 8) --8x8 tiles
  17. gx.uploadMap(GX_MAP1,5,1,"Hello") --mapId, mapWidth, mapHeight, map, uploads map data to the gpu
  18. gx.setMapVariable(GX_MAP1,GX_MAP_VAR_COLOR,255,0,0,255)
  19. gx.render()
  20. print("Initial render finished")
  21. print("Doing translation")
  22. for i=0, 128, 1 do
  23.     gx.setMapVariable(GX_MAP1,GX_MAP_VAR_XY,i,i)
  24.     gx.render() --tells the gx to render the frame. (on the java side this uploads the frame data to the clients)
  25.     --os.sleep(1/20)
  26. end
  27. print("Replacing Map data")
  28. gx.startPlot(GX_MAP1)
  29. gx.plot(1,1,"W")
  30. gx.plot(2,1,"o")
  31. gx.plot(3,1,"r")
  32. gx.plot(4,1,"l")
  33. gx.plot(5,1,"d")
  34. gx.endPlot()
  35. gx.setMapVariable(GX_MAP1,GX_MAP_VAR_COLOR,0,191,255)
  36. gx.render()
  37. print("Doing translation 2")
  38. for i=128, 0, -1 do
  39.     gx.setMapVariable(GX_MAP1,GX_MAP_VAR_XY,i,i)
  40.     gx.render()
  41.     --os.sleep(1/20)
  42. end
  43. gx.clearMap(GX_MAP1)
  44. local str = "Hello, World!"
  45. gx.uploadMap(GX_MAP1,#str,1,(" "):rep(#str))
  46. for i=1, #str do
  47.     local chr = str:byte(i)
  48.     gx.startPlot(GX_MAP1)
  49.     gx.plot(i,1,chr)
  50.     gx.endPlot()
  51.     gx.render()
  52. end
  53. print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement