slightly less cursed struct shit
This commit is contained in:
parent
17ae922675
commit
e0b15dc9e4
40
u02/main.c
40
u02/main.c
|
@ -35,28 +35,28 @@ typedef struct {
|
||||||
Triangle t2;
|
Triangle t2;
|
||||||
} TriangleRect;
|
} TriangleRect;
|
||||||
|
|
||||||
void createRect(GLfloat* vertexArray, GLfloat posx, GLfloat posy, GLfloat width, GLfloat height) {
|
void createRect(TriangleRect* rect, GLfloat posx, GLfloat posy, GLfloat width, GLfloat height) {
|
||||||
vertexArray[0] = posx;
|
rect->t1.p1.x = posx;
|
||||||
vertexArray[1] = posy;
|
rect->t1.p1.y = posy;
|
||||||
|
|
||||||
vertexArray[2] = posx + width;
|
rect->t1.p2.x = posx + width;
|
||||||
vertexArray[3] = posy;
|
rect->t1.p2.y = posy;
|
||||||
|
|
||||||
vertexArray[4] = posx;
|
rect->t1.p3.x = posx;
|
||||||
vertexArray[5] = posy + height;
|
rect->t1.p3.y = posy + height;
|
||||||
|
|
||||||
vertexArray[6] = posx + width;
|
rect->t2.p1.x = posx + width;
|
||||||
vertexArray[7] = posy;
|
rect->t2.p1.y = posy;
|
||||||
|
|
||||||
vertexArray[8] = posx + width;
|
rect->t2.p2.x = posx + width;
|
||||||
vertexArray[9] = posy + height;
|
rect->t2.p2.y = posy + height;
|
||||||
|
|
||||||
vertexArray[10] = posx;
|
rect->t2.p3.x = posx;
|
||||||
vertexArray[11] = posy + height;
|
rect->t2.p3.y = posy + height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createCenterRect(GLfloat* vertexArray, GLfloat posx, GLfloat posy, GLfloat width, GLfloat height) {
|
void createCenterRect(TriangleRect* rect, GLfloat posx, GLfloat posy, GLfloat width, GLfloat height) {
|
||||||
createRect(vertexArray, posx - width / 2, posy - height / 2, width, height);
|
createRect(rect, posx - width / 2, posy - height / 2, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(void) {
|
void init(void) {
|
||||||
|
@ -134,10 +134,10 @@ void init(void) {
|
||||||
|
|
||||||
TriangleRect triangleVertices[4];
|
TriangleRect triangleVertices[4];
|
||||||
|
|
||||||
createCenterRect((GLfloat*)&triangleVertices[0], -0.2f, 0.0f, 0.1f, 1.2f);
|
createCenterRect(&triangleVertices[0], -0.2f, 0.0f, 0.1f, 1.2f);
|
||||||
createCenterRect((GLfloat*)&triangleVertices[1], 0.2f, 0.0f, 0.1f, 1.2f);
|
createCenterRect(&triangleVertices[1], 0.2f, 0.0f, 0.1f, 1.2f);
|
||||||
createCenterRect((GLfloat*)&triangleVertices[2], 0.0f, 0.0f, 0.3f, 0.1f);
|
createCenterRect(&triangleVertices[2], 0.0f, 0.0f, 0.3f, 0.1f);
|
||||||
createCenterRect((GLfloat*)&triangleVertices[3], 0.0f, -0.8f, 0.5f, 0.1f);
|
createCenterRect(&triangleVertices[3], 0.0f, -0.8f, 0.5f, 0.1f);
|
||||||
|
|
||||||
|
|
||||||
GLuint triangleVertexBufferObject;
|
GLuint triangleVertexBufferObject;
|
||||||
|
@ -156,7 +156,7 @@ void init(void) {
|
||||||
2,
|
2,
|
||||||
GL_FLOAT,
|
GL_FLOAT,
|
||||||
GL_FALSE,
|
GL_FALSE,
|
||||||
2 * sizeof(GLfloat),
|
sizeof(Point),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|
Loading…
Reference in New Issue