GLSLProgram.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. require "Polycode/Resource"
  2. class "GLSLProgram" (Resource)
  3. TYPE_VERT = 0
  4. TYPE_FRAG = 1
  5. function GLSLProgram:__index__(name)
  6. if name == "type" then
  7. return Polycore.GLSLProgram_get_type(self.__ptr)
  8. end
  9. end
  10. function GLSLProgram:__set_callback(name,value)
  11. if name == "type" then
  12. Polycore.GLSLProgram_set_type(self.__ptr, value)
  13. return true
  14. end
  15. return false
  16. end
  17. function GLSLProgram:GLSLProgram(...)
  18. if type(arg[1]) == "table" and count(arg) == 1 then
  19. if ""..arg[1]:class() == "Resource" then
  20. self.__ptr = arg[1].__ptr
  21. return
  22. end
  23. end
  24. for k,v in pairs(arg) do
  25. if type(v) == "table" then
  26. if v.__ptr ~= nil then
  27. arg[k] = v.__ptr
  28. end
  29. end
  30. end
  31. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  32. self.__ptr = Polycore.GLSLProgram(unpack(arg))
  33. Polycore.__ptr_lookup[self.__ptr] = self
  34. end
  35. end
  36. function GLSLProgram:addParam(name, isAuto, autoID, paramType, defaultData)
  37. local retVal = Polycore.GLSLProgram_addParam(self.__ptr, name, isAuto, autoID, paramType, defaultData.__ptr)
  38. end
  39. function GLSLProgram:__delete()
  40. Polycore.__ptr_lookup[self.__ptr] = nil
  41. Polycore.delete_GLSLProgram(self.__ptr)
  42. end