~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/scriptedwizard/resources/glfw/files/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <GL/glfw.h>
 
2
 
 
3
int main()
 
4
{
 
5
    int     width, height;
 
6
    int     frame = 0;
 
7
    bool    running = true;
 
8
 
 
9
    glfwInit();
 
10
 
 
11
    if( !glfwOpenWindow( 512, 512, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) )
 
12
    {
 
13
        glfwTerminate();
 
14
        return 0;
 
15
    }
 
16
 
 
17
    glfwSetWindowTitle("GLFW Application");
 
18
 
 
19
    while(running)
 
20
    {
 
21
        frame++;
 
22
 
 
23
        glfwGetWindowSize( &width, &height );
 
24
        height = height > 0 ? height : 1;
 
25
 
 
26
        glViewport( 0, 0, width, height );
 
27
 
 
28
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
 
29
        glClear( GL_COLOR_BUFFER_BIT );
 
30
 
 
31
        glMatrixMode( GL_PROJECTION );
 
32
        glLoadIdentity();
 
33
        gluPerspective( 65.0f, (GLfloat)width/(GLfloat)height, 1.0f, 100.0f );
 
34
 
 
35
        // Draw some rotating garbage
 
36
        glMatrixMode( GL_MODELVIEW );
 
37
        glLoadIdentity();
 
38
        gluLookAt(0.0f, -10.0f, 0.0f,
 
39
                0.0f, 0.0f, 0.0f,
 
40
                0.0f, 0.0f, 1.0f );
 
41
 
 
42
        //glTranslatef( 1.0f, 1.0f, 0.0f );
 
43
        glRotatef(frame, 0.25f, 1.0f, 0.75f);
 
44
        glBegin( GL_TRIANGLES );
 
45
          glColor3f(0.1f, 0.0f, 0.0f );
 
46
          glVertex3f(0.0f, 3.0f, -4.0f);
 
47
          glColor3f(0.0f, 1.0f, 0.0f );
 
48
          glVertex3f(3.0f, -2.0f, -4.0f);
 
49
          glColor3f(0.0f, 0.0f, 1.0f );
 
50
          glVertex3f(-3.0f, -2.0f, -4.0f);
 
51
        glEnd();
 
52
        glBegin( GL_TRIANGLES );
 
53
          glColor3f(0.0f, 0.1f, 0.0f );
 
54
          glVertex3f(0.0f, 3.0f, -3.0f);
 
55
          glColor3f(0.0f, 0.0f, 1.0f );
 
56
          glVertex3f(3.0f, -2.0f, -2.0f);
 
57
          glColor3f(1.0f, 0.0f, 0.0f );
 
58
          glVertex3f(-3.0f, -2.0f, 2.0f);
 
59
        glEnd();
 
60
        glfwSwapBuffers();
 
61
 
 
62
        // exit if ESC was pressed or window was closed
 
63
        running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam( GLFW_OPENED);
 
64
    }
 
65
 
 
66
    glfwTerminate();
 
67
 
 
68
    return 0;
 
69
}