123 lines
2.9 KiB
C++
123 lines
2.9 KiB
C++
#include "allocate/factory.h"
|
|
#include "code/return.h"
|
|
#include "draw/opengl_service.h"
|
|
|
|
opengl_service_t::opengl_service_t(
|
|
opengl_service_t::configuration_t* configuration_p
|
|
) {
|
|
configuration_m = configuration_p;
|
|
}
|
|
|
|
void_t<opengl_service_t::error_t> opengl_service_t::draw(
|
|
int cycle_p
|
|
) {
|
|
glClearColor(1.0, 1.0, 1.0, 1.0);
|
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
|
glLoadIdentity();
|
|
|
|
double rotate_x = static_cast<double>(cycle_p * 1);
|
|
double rotate_y = static_cast<double>(cycle_p * 1);
|
|
glRotatef( rotate_x, 1.0, 0.0, 0.0 );
|
|
glRotatef( rotate_y, 0.0, 1.0, 0.0 );
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
glColor3f( 1.0, 1.0, 1.0 );
|
|
glVertex3f( 0.5, -0.5, 0.5 );
|
|
glVertex3f( 0.5, 0.5, 0.5 );
|
|
glVertex3f( -0.5, 0.5, 0.5 );
|
|
glVertex3f( -0.5, -0.5, 0.5 );
|
|
glEnd();
|
|
|
|
// Purple side - RIGHT
|
|
glBegin(GL_POLYGON);
|
|
glColor3f( 1.0, 0.0, 1.0 );
|
|
glVertex3f( 0.5, -0.5, -0.5 );
|
|
glVertex3f( 0.5, 0.5, -0.5 );
|
|
glVertex3f( 0.5, 0.5, 0.5 );
|
|
glVertex3f( 0.5, -0.5, 0.5 );
|
|
glEnd();
|
|
|
|
// Green side - LEFT
|
|
glBegin(GL_POLYGON);
|
|
glColor3f( 0.0, 1.0, 0.0 );
|
|
glVertex3f( -0.5, -0.5, 0.5 );
|
|
glVertex3f( -0.5, 0.5, 0.5 );
|
|
glVertex3f( -0.5, 0.5, -0.5 );
|
|
glVertex3f( -0.5, -0.5, -0.5 );
|
|
glEnd();
|
|
|
|
// Blue side - TOP
|
|
glBegin(GL_POLYGON);
|
|
glColor3f( 0.0, 0.0, 1.0 );
|
|
glVertex3f( 0.5, 0.5, 0.5 );
|
|
glVertex3f( 0.5, 0.5, -0.5 );
|
|
glVertex3f( -0.5, 0.5, -0.5 );
|
|
glVertex3f( -0.5, 0.5, 0.5 );
|
|
glEnd();
|
|
|
|
// Red side - BOTTOM
|
|
glBegin(GL_POLYGON);
|
|
glColor3f( 1.0, 0.0, 0.0 );
|
|
glVertex3f( 0.5, -0.5, -0.5 );
|
|
glVertex3f( 0.5, -0.5, 0.5 );
|
|
glVertex3f( -0.5, -0.5, 0.5 );
|
|
glVertex3f( -0.5, -0.5, -0.5 );
|
|
|
|
glEnd();
|
|
glFlush();
|
|
|
|
void_t<opengl_service_t::error_t> void_l;
|
|
void_l.error_m = opengl_service_t::error_t::none;
|
|
return void_l;
|
|
}
|
|
|
|
void_t<opengl_service_t::error_t> opengl_service_t::enable_depth_test(
|
|
) {
|
|
glEnable(
|
|
GL_DEPTH_TEST
|
|
);
|
|
void_t<opengl_service_t::error_t> void_l;
|
|
void_l.error_m = opengl_service_t::error_t::none;
|
|
return void_l;
|
|
}
|
|
|
|
|
|
void_t<opengl_service_t::error_t> opengl_service_t::resize_viewport(
|
|
int x,
|
|
int y,
|
|
int width,
|
|
int height
|
|
) {
|
|
void_t<opengl_service_t::error_t> void_l;
|
|
void_l.error_m = opengl_service_t::error_t::none;
|
|
glViewport(
|
|
0,
|
|
0,
|
|
width,
|
|
height
|
|
);
|
|
return void_l;
|
|
}
|
|
|
|
return_t<opengl_service_t::error_t, opengl_service_t*> opengl_service_factory_t::create(
|
|
opengl_service_t::configuration_t* configuration_p
|
|
) {
|
|
opengl_service_t* opengl_service_l = new opengl_service_t(
|
|
configuration_p
|
|
);
|
|
return_t<opengl_service_t::error_t, opengl_service_t*> return_l;
|
|
return_l.error_m = opengl_service_t::error_t::none;
|
|
return_l.value_m = opengl_service_l;
|
|
return return_l;
|
|
}
|
|
|
|
void_t<opengl_service_t::error_t> opengl_service_factory_t::dispose(
|
|
opengl_service_t* opengl_service_p
|
|
) {
|
|
delete opengl_service_p;
|
|
void_t<opengl_service_t::error_t> void_l;
|
|
void_l.error_m = opengl_service_t::error_t::none;
|
|
return void_l;
|
|
}
|