~ubuntu-branches/ubuntu/hoary/plib-doc/hoary

« back to all changes in this revision

Viewing changes to src/pui/simple.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Frauenfelder
  • Date: 2004-07-13 20:56:29 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040713205629-gw7kmoiiwaqi6rol
Tags: 1.8.1-4
Changed build depends: added xlibs-dev, removed g++. Additionally, added
-lpthread to LDFLAGS for configure call. Closes: #259131

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
     PLIB - A Suite of Portable Game Libraries
 
3
     Copyright (C) 2001  Steve Baker
 
4
 
 
5
     This program is free software; you can redistribute it and/or modify
 
6
     it under the terms of the GNU General Public License as published by
 
7
     the Free Software Foundation; either version 2 of the License, or
 
8
     (at your option) any later version.
 
9
 
 
10
     This program is distributed in the hope that it will be useful,
 
11
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
     GNU General Public License for more details.
 
14
 
 
15
     You should have received a copy of the GNU General Public License
 
16
     along with this program; if not, write to the Free Software
 
17
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
18
 
 
19
     For further information visit http://plib.sourceforge.net
 
20
 
 
21
     $Id: simple.cxx,v 1.11 2002/09/01 12:04:51 ude Exp $
 
22
*/
 
23
 
1
24
 
2
25
#include <stdio.h>
3
26
#include <stdlib.h>
4
27
#include <string.h>
5
28
#ifdef WIN32
6
 
#include <windows.h>
 
29
#  include <windows.h>
7
30
#else
8
 
#include <unistd.h>
 
31
#  include <unistd.h>
9
32
#endif
10
33
#include <math.h>
11
 
#include <GL/glut.h>
 
34
 
 
35
#ifdef FREEGLUT_IS_PRESENT
 
36
#  include <GL/freeglut.h>
 
37
#else
 
38
#  ifdef __APPLE__
 
39
#    include <GLUT/glut.h>
 
40
#  else
 
41
#    include <GL/glut.h>
 
42
#  endif
 
43
#endif
 
44
 
12
45
#include <plib/pu.h>
13
46
 
 
47
//#define VOODOO 1
 
48
 
14
49
void motionfn ( int x, int y )
15
50
{
16
51
  puMouse ( x, y ) ;
23
58
  glutPostRedisplay () ;
24
59
}
25
60
 
26
 
void displayfn (void)
 
61
void displayfn ( void )
27
62
{
28
 
  glClearColor ( 0.1, 0.4, 0.1, 1.0 ) ;
 
63
  glClearColor ( 0.1f, 0.4f, 0.1f, 1.0f ) ;
29
64
  glClear      ( GL_COLOR_BUFFER_BIT ) ;
30
65
 
31
66
  puDisplay () ;
32
67
 
33
68
  glutSwapBuffers   () ;
 
69
 
 
70
  /* The next line is not neccessary - you could remove it safely without
 
71
     affecting the functionality of this simple example program.
 
72
 
 
73
     It exists because in every application which does some more stuff
 
74
     than creating user interface widgets, you normally do want to
 
75
     redraw your scenery as often as possible for smooth animation. */
 
76
 
34
77
  glutPostRedisplay () ;
35
78
}
36
79
 
47
90
#endif
48
91
  glutInitWindowSize     ( 640, 480 ) ;
49
92
  glutInit               ( &argc, argv ) ;
 
93
 
 
94
  /* Note that in order for PUI and this example program to work, you
 
95
     definitely don't need a depth buffer.
 
96
 
 
97
     However, most applications using PUI do some more things than rendering
 
98
     PUI widgets. In every "real" program, you usually do need a depth
 
99
     buffer - we are requesting one in the next line so that PLIB programmers
 
100
     can write their applications upon this example code without running
 
101
     into problems. */
 
102
 
50
103
  glutInitDisplayMode    ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
 
104
 
51
105
  glutCreateWindow       ( "PUI Application"  ) ;
52
106
  glutDisplayFunc        ( displayfn ) ;
53
107
  glutMouseFunc          ( mousefn   ) ;
54
108
  glutMotionFunc         ( motionfn  ) ;
 
109
 
 
110
#ifdef VOODOO
55
111
  glutPassiveMotionFunc  ( motionfn  ) ;
 
112
#endif
56
113
 
57
114
  puInit () ;
58
115
 
65
122
  b -> setLegend   ( "Say Hello" ) ;
66
123
  b -> setCallback ( button_cb ) ;
67
124
 
 
125
printf ( "%d\n", PLIB_VERSION ) ;
 
126
 
68
127
  glutMainLoop () ;
69
128
 
70
129
  return 0 ;
71
130
}
72
131
 
73
 
 
74