render.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "atto/math.h"
  3. typedef enum {
  4. RTexFormat_RGB565,
  5. #ifdef ATTO_PLATFORM_RPI
  6. RTexFormat_Compressed_ETC1,
  7. #endif
  8. } RTexFormat;
  9. typedef enum {
  10. RTexType_2D = (1 << 0),
  11. RTexType_CubePX = (1 << 1),
  12. RTexType_CubeNX = (1 << 2),
  13. RTexType_CubePY = (1 << 3),
  14. RTexType_CubeNY = (1 << 4),
  15. RTexType_CubePZ = (1 << 5),
  16. RTexType_CubeNZ = (1 << 6),
  17. } RTexType;
  18. typedef enum {
  19. RTexWrap_Repeat,
  20. RTexWrap_Clamp
  21. } RTexWrap;
  22. typedef struct {
  23. int width, height;
  24. RTexFormat format;
  25. int gl_name;
  26. int type_flags;
  27. } RTexture;
  28. typedef struct {
  29. RTexType type;
  30. int width, height;
  31. RTexFormat format;
  32. const void *pixels;
  33. int mip_level; // -1 means generate; -2 means don't need
  34. RTexWrap wrap;
  35. } RTextureUploadParams;
  36. #define renderTextureInit(texture_ptr) do { (texture_ptr)->gl_name = -1; } while (0)
  37. void renderTextureUpload(RTexture *texture, RTextureUploadParams params);
  38. typedef struct {
  39. int gl_name;
  40. int type;
  41. } RBuffer;
  42. typedef enum {
  43. RBufferType_Vertex,
  44. RBufferType_Index
  45. } RBufferType;
  46. int renderInit();
  47. void renderResize(int w, int h);
  48. void renderBufferCreate(RBuffer *buffer, RBufferType type, int size, const void *data);
  49. struct BSPModel;
  50. struct Camera;
  51. void renderBegin();
  52. typedef struct {
  53. const struct Camera *camera;
  54. struct AVec3f translation;
  55. int selected;
  56. } RDrawParams;
  57. void renderModelDraw(const RDrawParams *params, const struct BSPModel *model);
  58. void renderEnd(const struct Camera *camera);