Advertisement
Guest User

Untitled

a guest
Jul 5th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1.  
  2. <=================== VertexObject.h ====================>
  3. #pragma once
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. #include <GL\glew.h>
  9. #include <GLFW\glfw3.h>
  10.  
  11. class VertexObject
  12. {
  13.  
  14. public:
  15.     VertexObject ( );
  16.  
  17.     void SetArray ( GLfloat Points [] );
  18.  
  19.     void SetBuffer ( GLuint* VBO );
  20.  
  21.     GLfloat Points [ ] = {
  22.          1.0f , 0.0f , 1.0f,
  23.          0.0f , 1.0f , 1.0f,
  24.         -1.0f , 0.0f , 1.0f
  25.     };
  26.  
  27. private:
  28.  
  29.    
  30.  
  31. };
  32.  
  33. <========================= VertexObjecct.cpp ==============================>
  34.  
  35. #include "VertexObject.h"
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39.  
  40. #include <GL\glew.h>
  41. #include <GLFW\glfw3.h>
  42.  
  43. void VertexObject::SetArray ( GLfloat Points [ ] )
  44. {
  45.  
  46.     //Generate Vertex Array Object
  47.     GLuint vaoID1;
  48.     //Generates an array for the VAO
  49.     glGenVertexArrays ( 1 , &vaoID1 );
  50.     //Assigns the array to the Vertex Array Object
  51.     glBindVertexArray ( vaoID1 );
  52.  
  53.     //Fills in the array
  54.    
  55.     for ( int i = 0; i < sizeof ( Points ); i++ )
  56.     {
  57.  
  58.         this->Points [ i ] = Points [ i ];
  59.  
  60.     }
  61.    
  62. }
  63.  
  64. void VertexObject::SetBuffer ( GLuint* VBO )
  65. {
  66.  
  67.     //Generate Vertex Buffer Object
  68.     glGenBuffers ( 1 , VBO );
  69.     glBindBuffer ( GL_ARRAY_BUFFER , *VBO );
  70.     glBufferData ( GL_ARRAY_BUFFER ,sizeof(Points) , Points , GL_STATIC_DRAW );
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement