현재 상태가 아래와 같습니다 ㅠㅠ 위에서 봤을 때는 아래처럼 태양에서 빛 받는거처럼 정상적으로 처리되는거 같은데..
void makeSphere(){
float radius = 1.0f;
vertex radiusVertices[triCount];
float rTheta = (180 / (float)triCount) * PI / 180;
for (int i = 0; i < triCount; i++){
float px = (cosf(rTheta * i) * 0) - (sinf(rTheta * i) * radius);
float py = (sinf(rTheta * i) * 0) + (cosf(rTheta * i) * radius);
radiusVertices[i].pos = vec3(-px, py, 0);
radiusVertices[i].color = vec4(1, 1, 0, 1);
}
vertex vertices[triCount][triCount];
GLuint Indices[((triCount - 1) * 2)*triCount];
float theta = (360 / (float)triCount) * PI / 180;
float x = radiusVertices[0].pos[0];
float y = radiusVertices[0].pos[1];
float z = 0;
int index_counter = 0;
for (int i = 0; i < triCount; i++){
x = radiusVertices[i].pos[0];
y = radiusVertices[i].pos[1];
for (int j = 0; j < triCount; j++){
float x2 = (cosf(theta * j) * x) - (sinf(theta * j) * 0);
float z2 = (sinf(theta * j) * x) + (cosf(theta * j) * 0);
vertices[i][j].pos = vec3(x2, y, z2);
vertices[i][j].color = vec4(1, 1, 0, 1);
vertices[i][j].norm = vec3(x2, y, z2).normalize();
vertices[i][j].index = index_counter++;
}
}
int k = 0;
for (int i = 0; i < triCount - 1; i++){
for (int j = 0; j < triCount; j++){
Indices[k++] = vertices[i][j].index;
Indices[k++] = vertices[i + 1][j].index;
}
}
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// geneation of index buffer
glGenBuffers(1, &indexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);
}