Добавим код в конце функции engine_init_display в файле main.cpp
static int engine_init_display(struct engine* engine) {
...
// enable draw lines and colors
glEnableClientState(GL_VERTEX_ARRAY);// glEnableClientState(GL_VERTEX_ARRAY) allow to use glVertexPointer
glEnableClientState(GL_COLOR_ARRAY); // glEnableClientState(GL_COLOR_ARRAY) allow to use glColorPointer
return 0;
}
Полностью перепишем содержимое функции engine_draw_frame в файле main.cpp
static void engine_draw_frame(struct engine* engine) {
if (engine->display == NULL) {
// No display.
return;
}
// set color (white)
glClearColor(255, 255 ,255, 0);
// fill device with color
glClear(GL_COLOR_BUFFER_BIT);
// set line points and line colors
static GLfloat colors[] = {
1.0f, 0.0f, 0.0f, 1.0f, // red color
0.0f, 1.0f, 0.0f, 1.0f, // green color
0.0f, 0.0f, 1.0f, 1.0f // blue color
};
static GLfloat points[] = {
0, 0, 0,
0.9, 0.9, 0,
0.9, 0, 0
};
// draw line points and line color
glLineWidth(10);
glVertexPointer(3 /*columns count in variable points*/, GL_FLOAT, 0, points);
glColorPointer(4 /*columns count in variable colors*/ , GL_FLOAT, 0, colors);
glDrawArrays(GL_LINE_STRIP, 0 /*first index to draw*/, 3 /*count of points to draw*/);
// switch gl buffers
eglSwapBuffers(engine->display, engine->surface);
}