diff --git a/u02/main.c b/u02/main.c index bb42ca8..d89fef7 100644 --- a/u02/main.c +++ b/u02/main.c @@ -19,6 +19,22 @@ GLfloat speedY = -0.0005f; #define NUM_TRIANGLES 8 +typedef struct { + GLfloat x; + GLfloat y; +} Point; + +typedef struct { + Point p1; + Point p2; + Point p3; +} Triangle; + +typedef struct { + Triangle t1; + Triangle t2; +} TriangleRect; + void createRect(GLfloat* vertexArray, GLfloat posx, GLfloat posy, GLfloat width, GLfloat height) { vertexArray[0] = posx; vertexArray[1] = posy; @@ -116,24 +132,12 @@ void init(void) { } + TriangleRect triangleVertices[4]; - // create triangle buffer - // GLfloat triangleVertices[] = - // {// X Y - // -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, - // -0.5f, -0.5f, 0.0f, 1.0f, 0.0f, - // -0.75f, -0.5f, 0.0f, 0.0f, 1.0f, - - // -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, - // -0.75f, 0.5f, 0.0f, 1.0f, 0.0f, - // -0.75f, -0.5f, 0.0f, 0.0f, 1.0f - // }; - GLfloat triangleVertices[48]; - - createCenterRect(&triangleVertices[0], -0.2f, 0.0f, 0.1f, 1.2f); - createCenterRect(&triangleVertices[12], 0.2f, 0.0f, 0.1f, 1.2f); - createCenterRect(&triangleVertices[24], 0.0f, 0.0f, 0.3f, 0.1f); - createCenterRect(&triangleVertices[36], 0.0f, -0.8f, 0.5f, 0.1f); + createCenterRect((GLfloat*)&triangleVertices[0], -0.2f, 0.0f, 0.1f, 1.2f); + createCenterRect((GLfloat*)&triangleVertices[1], 0.2f, 0.0f, 0.1f, 1.2f); + createCenterRect((GLfloat*)&triangleVertices[2], 0.0f, 0.0f, 0.3f, 0.1f); + createCenterRect((GLfloat*)&triangleVertices[3], 0.0f, -0.8f, 0.5f, 0.1f); GLuint triangleVertexBufferObject;