Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. #include <sb6.h>
  2. #include <math.h>
  3.  
  4. class simplepoint_app : public sb6::application
  5. {
  6. void init()
  7. {
  8. static const char title[] = "Open GL Point";
  9. sb6::application::init();
  10. memcpy(info.title, title, sizeof(title));
  11.  
  12. }
  13. int i = 0;
  14. int count = 600;
  15.  
  16. virtual void render(double currentTime)
  17. {
  18. static GLfloat red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
  19. static GLfloat green[] = { 0.0f, 1.0f, 0.0f, 1.0f };
  20. static GLfloat blue[] = { 0.0f, 0.0f, 1.0f, 1.0f };
  21.  
  22.  
  23. glUseProgram(program);
  24. glPointSize(40.0f);
  25. glDrawArrays(GL_POINTS, 0, 1);
  26. //glClearBufferfv(GL_COLOR, 0, green);
  27.  
  28. }
  29.  
  30. virtual void startup()
  31. {
  32. //vertex source code
  33. static const char* vs_source[] = {
  34. "#version 420 core \n"
  35. " \n"
  36. "void main(void) \n"
  37. "{ \n"
  38. " \n"
  39. " gl_Position = vec4(0.0, 0.0, 0.0, 1.0); \n"
  40. " \n"
  41. " \n"
  42. " \n"
  43. "} \n" };
  44.  
  45.  
  46.  
  47. static const char* fs_source[] = {
  48. "#version 420 core \n"
  49. " \n"
  50. "out vec4 color; \n"
  51. "void main (void) \n"
  52. "{ \n"
  53. " \n"
  54. " color = vec4(0.0, 0.8, 1.0, 1.0); \n"
  55. " \n"
  56. " \n"
  57. "} \n" };
  58.  
  59. if (program != 0)
  60. {
  61. glDeleteProgram(program);
  62. }
  63.  
  64. // Default vs und fs setup
  65.  
  66. program = glCreateProgram();
  67. GLuint vs = glCreateShader(GL_VERTEX_SHADER);
  68. glShaderSource(vs, 1, vs_source, NULL);
  69. glCompileShader(vs);
  70.  
  71.  
  72. program = glCreateProgram();
  73. GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
  74. glShaderSource(fs, 1, fs_source, NULL);
  75. glCompileShader(fs);
  76.  
  77. glAttachShader(program, vs);
  78. glAttachShader(program, fs);
  79.  
  80. glLinkProgram(program);
  81.  
  82. glGenVertexArrays(1, &vao);
  83. glBindVertexArray(vao);
  84.  
  85. }
  86.  
  87. virtual void shutdown()
  88. {
  89. glDeleteVertexArrays(1, &vao);
  90. glDeleteProgram(program);
  91. }
  92.  
  93. private:
  94. GLuint program;
  95. GLuint vao;
  96.  
  97. };
  98. DECLARE_MAIN(simplepoint_app)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement