main.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include <stdio.h>
  2. #include "../RasterIver/headers/rasteriver.h"
  3. #include <time.h>
  4. #include <stdlib.h>
  5. int width = 100;
  6. int height = 100;
  7. int main(){
  8. srand(time(NULL));
  9. RI_SetFlag(RI_FLAG_DEBUG, 1);
  10. RI_SetFlag(RI_FLAG_DEBUG_LEVEL, RI_DEBUG_HIGH);
  11. RI_SetFlag(RI_FLAG_DEBUG_TICK, 0);
  12. RI_SetFlag(RI_FLAG_DEBUG_FPS, 0);
  13. RI_SetFlag(RI_FLAG_SHOW_FPS, 1);
  14. RI_SetFlag(RI_FLAG_SHOW_FRAME, 0);
  15. RI_SetFlag(RI_FLAG_SHOW_BUFFER, RI_BUFFER_COMPLETE);
  16. RI_SetFlag(RI_FLAG_CLEAN_POLYGONS, 1);
  17. RI_SetFlag(RI_FLAG_POPULATE_POLYGONS, 0);
  18. RI_SetFlag(RI_FLAG_BE_MASTER_RENDERER, 1);
  19. RI_SetFlag(RI_FLAG_HANDLE_SDL_EVENTS, 1);
  20. RI_SetFlag(RI_FLAG_SHOW_INFO, 0);
  21. RI_SetFlag(RI_FLAG_USE_CPU, 0);
  22. RI_SetValue(RI_VALUE_WIREFRAME_SCALE, 0.01);
  23. char prefix[50] = "[RASTERIVER IS AMAZING] ";
  24. RI_SetDebugPrefix(prefix);
  25. //RI_SetFpsCap(120);
  26. if (RI_Init(width, height, "Rasteriver Test") == RI_ERROR){
  27. return 1;
  28. }
  29. RI_newObject object_buffer[49] = {
  30. {0, 0, 50, 0, 0, 0, -9999999, 10, 10, 10, RI_MATERIAL_WIREFRAME | RI_MATERIAL_DOUBLE_SIDED | RI_MATERIAL_HAS_TEXTURE, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  31. {10, 0, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  32. {20, 0, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  33. {30, 0, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  34. {-10, 0, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  35. {-20, 0, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  36. {-30, 0, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  37. {0, 10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  38. {10, 10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  39. {20, 10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  40. {30, 10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  41. {-10, 10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  42. {-20, 10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  43. {-30, 10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  44. {0, -10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  45. {10, -10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  46. {20, -10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  47. {30, -10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  48. {-10, -10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  49. {-20, -10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  50. {-30, -10, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  51. {0, 20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  52. {10, 20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  53. {20, 20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  54. {30, 20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  55. {-10, 20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  56. {-20, 20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  57. {-30, 20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  58. {0, -20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  59. {10, -20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  60. {20, -20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  61. {30, -20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  62. {-10, -20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  63. {-20, -20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  64. {-30, -20, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  65. {0, 30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  66. {10, 30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  67. {20, 30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  68. {30, 30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  69. {-10, 30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  70. {-20, 30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  71. {-30, 30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  72. {0, -30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  73. {10, -30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  74. {20, -30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  75. {30, -30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  76. {-10, -30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  77. {-20, -30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  78. {-30, -30, 100, 0, 0, 0, -9999999, 10, 10, 10, RI_PMP_TEXTURED, "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
  79. };
  80. int objects_to_request = 1;
  81. RI_objects objects = RI_RequestObjects(object_buffer, objects_to_request);
  82. while (RI_IsRunning() == RI_RUNNING){
  83. for (int i = 0; i < objects_to_request; i++){
  84. objects[i].transform.rotation.x += 0.01;
  85. objects[i].transform.rotation.y += 0.02;
  86. objects[i].transform.rotation.z += 0.03;
  87. objects[i].transform.rotation.x = fmod(objects[i].transform.rotation.x, RI_2PI);
  88. objects[i].transform.rotation.y = fmod(objects[i].transform.rotation.y, RI_2PI);
  89. objects[i].transform.rotation.z = fmod(objects[i].transform.rotation.z, RI_2PI);
  90. }
  91. RI_Tick();
  92. }
  93. RI_Stop();
  94. }