|
|
|
@ -92,6 +92,7 @@ static void drawTorus( void ) |
|
|
|
|
glVertex3f((float) x, (float) y, (float) z); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
glEnd(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -210,13 +211,9 @@ static void drawAllViews( void ) |
|
|
|
|
|
|
|
|
|
// Calculate aspect of window
|
|
|
|
|
if (height > 0) |
|
|
|
|
{ |
|
|
|
|
aspect = (double) width / (double) height; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
aspect = 1.0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Clear screen
|
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
|
|
|
@ -229,7 +226,6 @@ static void drawAllViews( void ) |
|
|
|
|
glEnable(GL_DEPTH_TEST); |
|
|
|
|
glDepthFunc(GL_LEQUAL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ** ORTHOGONAL VIEWS **
|
|
|
|
|
|
|
|
|
|
// For orthogonal views, use wireframe rendering
|
|
|
|
@ -282,7 +278,6 @@ static void drawAllViews( void ) |
|
|
|
|
glDisable(GL_LINE_SMOOTH); |
|
|
|
|
glDisable(GL_BLEND); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ** PERSPECTIVE VIEW **
|
|
|
|
|
|
|
|
|
|
// For perspective view, use solid rendering
|
|
|
|
@ -330,18 +325,21 @@ static void drawAllViews( void ) |
|
|
|
|
// Disable scissor test
|
|
|
|
|
glDisable(GL_SCISSOR_TEST); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Draw a border around the active view
|
|
|
|
|
if (active_view > 0 && active_view != 2) |
|
|
|
|
{ |
|
|
|
|
glViewport(0, 0, width, height); |
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION); |
|
|
|
|
glLoadIdentity(); |
|
|
|
|
glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0); |
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW); |
|
|
|
|
glLoadIdentity(); |
|
|
|
|
glColor3f( 1.0f, 1.0f, 0.6f ); |
|
|
|
|
glTranslatef((GLfloat) ((active_view - 1) & 1), (GLfloat) (1 - (active_view - 1) / 2), 0.0f); |
|
|
|
|
|
|
|
|
|
glColor3f(1.0f, 1.0f, 0.6f); |
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP); |
|
|
|
|
glVertex2i(0, 0); |
|
|
|
|
glVertex2i(1, 0); |
|
|
|
@ -416,22 +414,15 @@ static void mousePosFun( GLFWwindow window, int x, int y ) |
|
|
|
|
|
|
|
|
|
static void mouseButtonFun(GLFWwindow window, int button, int action) |
|
|
|
|
{ |
|
|
|
|
// Button clicked?
|
|
|
|
|
if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS) |
|
|
|
|
{ |
|
|
|
|
// Detect which of the four views was clicked
|
|
|
|
|
active_view = 1; |
|
|
|
|
if (xpos >= width / 2) |
|
|
|
|
{ |
|
|
|
|
active_view += 1; |
|
|
|
|
} |
|
|
|
|
if (ypos >= height / 2) |
|
|
|
|
{ |
|
|
|
|
active_view += 2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Button released?
|
|
|
|
|
else if (button == GLFW_MOUSE_BUTTON_LEFT) |
|
|
|
|
{ |
|
|
|
|
// Deselect any previously selected view
|
|
|
|
@ -443,7 +434,7 @@ static void mouseButtonFun( GLFWwindow window, int button, int action ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// main()
|
|
|
|
|
// main
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
int main(void) |
|
|
|
@ -464,7 +455,6 @@ int main( void ) |
|
|
|
|
if (!window) |
|
|
|
|
{ |
|
|
|
|
fprintf(stderr, "Failed to open GLFW window\n"); |
|
|
|
|
glfwTerminate(); |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|