mirror of
https://github.com/gwm17/glfw.git
synced 2025-02-07 06:38:50 -05:00
Formatting.
This commit is contained in:
parent
a4a2eaaa0f
commit
cba8d35c65
|
@ -92,6 +92,7 @@ static void drawTorus( void )
|
||||||
glVertex3f((float) x, (float) y, (float) z);
|
glVertex3f((float) x, (float) y, (float) z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,13 +211,9 @@ static void drawAllViews( void )
|
||||||
|
|
||||||
// Calculate aspect of window
|
// Calculate aspect of window
|
||||||
if (height > 0)
|
if (height > 0)
|
||||||
{
|
|
||||||
aspect = (double) width / (double) height;
|
aspect = (double) width / (double) height;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
aspect = 1.0;
|
aspect = 1.0;
|
||||||
}
|
|
||||||
|
|
||||||
// Clear screen
|
// Clear screen
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
@ -229,7 +226,6 @@ static void drawAllViews( void )
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
|
|
||||||
|
|
||||||
// ** ORTHOGONAL VIEWS **
|
// ** ORTHOGONAL VIEWS **
|
||||||
|
|
||||||
// For orthogonal views, use wireframe rendering
|
// For orthogonal views, use wireframe rendering
|
||||||
|
@ -282,7 +278,6 @@ static void drawAllViews( void )
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
|
||||||
// ** PERSPECTIVE VIEW **
|
// ** PERSPECTIVE VIEW **
|
||||||
|
|
||||||
// For perspective view, use solid rendering
|
// For perspective view, use solid rendering
|
||||||
|
@ -330,18 +325,21 @@ static void drawAllViews( void )
|
||||||
// Disable scissor test
|
// Disable scissor test
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
|
||||||
// Draw a border around the active view
|
// Draw a border around the active view
|
||||||
if (active_view > 0 && active_view != 2)
|
if (active_view > 0 && active_view != 2)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0);
|
glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glColor3f( 1.0f, 1.0f, 0.6f );
|
|
||||||
glTranslatef((GLfloat) ((active_view - 1) & 1), (GLfloat) (1 - (active_view - 1) / 2), 0.0f);
|
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);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex2i(0, 0);
|
glVertex2i(0, 0);
|
||||||
glVertex2i(1, 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)
|
static void mouseButtonFun(GLFWwindow window, int button, int action)
|
||||||
{
|
{
|
||||||
// Button clicked?
|
|
||||||
if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS)
|
if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
// Detect which of the four views was clicked
|
// Detect which of the four views was clicked
|
||||||
active_view = 1;
|
active_view = 1;
|
||||||
if (xpos >= width / 2)
|
if (xpos >= width / 2)
|
||||||
{
|
|
||||||
active_view += 1;
|
active_view += 1;
|
||||||
}
|
|
||||||
if (ypos >= height / 2)
|
if (ypos >= height / 2)
|
||||||
{
|
|
||||||
active_view += 2;
|
active_view += 2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Button released?
|
|
||||||
else if (button == GLFW_MOUSE_BUTTON_LEFT)
|
else if (button == GLFW_MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
// Deselect any previously selected view
|
// Deselect any previously selected view
|
||||||
|
@ -443,7 +434,7 @@ static void mouseButtonFun( GLFWwindow window, int button, int action )
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// main()
|
// main
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@ -464,7 +455,6 @@ int main( void )
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window\n");
|
fprintf(stderr, "Failed to open GLFW window\n");
|
||||||
glfwTerminate();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user