PLIB 1.8.5+ r2173 from http://plib.svn.sourceforge.net/svnroot/plib/trunk
This commit is contained in:
3
examples/src/Makefile.am
Normal file
3
examples/src/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
SUBDIRS = js pui sl sg ssg fnt net util psl pw
|
||||
|
||||
18
examples/src/fnt/Makefile.am
Normal file
18
examples/src/fnt/Makefile.am
Normal file
@@ -0,0 +1,18 @@
|
||||
if BUILD_FNT
|
||||
|
||||
noinst_PROGRAMS = fnt_test slideshow hello_world
|
||||
|
||||
hello_world_SOURCES = hello_world.cxx
|
||||
|
||||
fnt_test_SOURCES = fnt_test.cxx
|
||||
|
||||
slideshow_SOURCES = slideshow.cxx
|
||||
|
||||
hello_world_LDADD = -lplibpw -lplibfnt -lplibsg -lplibul $(OGL_LIBS)
|
||||
fnt_test_LDADD = -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
slideshow_LDADD = -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = fnt_test.dsp slideshow.dsp
|
||||
|
||||
BIN
examples/src/fnt/data/AvantGarde-Book.txf
Normal file
BIN
examples/src/fnt/data/AvantGarde-Book.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/AvantGarde-BookOblique.txf
Normal file
BIN
examples/src/fnt/data/AvantGarde-BookOblique.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/AvantGarde-Demi.txf
Normal file
BIN
examples/src/fnt/data/AvantGarde-Demi.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/AvantGarde-DemiOblique.txf
Normal file
BIN
examples/src/fnt/data/AvantGarde-DemiOblique.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Bookman-Demi.txf
Normal file
BIN
examples/src/fnt/data/Bookman-Demi.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Bookman-DemiItalic.txf
Normal file
BIN
examples/src/fnt/data/Bookman-DemiItalic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Bookman-Light.txf
Normal file
BIN
examples/src/fnt/data/Bookman-Light.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Bookman-LightItalic.txf
Normal file
BIN
examples/src/fnt/data/Bookman-LightItalic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Courier-Bold.txf
Normal file
BIN
examples/src/fnt/data/Courier-Bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Courier-BoldOblique.txf
Normal file
BIN
examples/src/fnt/data/Courier-BoldOblique.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Courier-Oblique.txf
Normal file
BIN
examples/src/fnt/data/Courier-Oblique.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Courier.txf
Normal file
BIN
examples/src/fnt/data/Courier.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Helvetica-Bold.txf
Normal file
BIN
examples/src/fnt/data/Helvetica-Bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Helvetica-BoldOblique.txf
Normal file
BIN
examples/src/fnt/data/Helvetica-BoldOblique.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Helvetica-Oblique.txf
Normal file
BIN
examples/src/fnt/data/Helvetica-Oblique.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Helvetica.txf
Normal file
BIN
examples/src/fnt/data/Helvetica.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/NewCenturySchlbk-Bold.txf
Normal file
BIN
examples/src/fnt/data/NewCenturySchlbk-Bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/NewCenturySchlbk-BoldItalic.txf
Normal file
BIN
examples/src/fnt/data/NewCenturySchlbk-BoldItalic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/NewCenturySchlbk-Italic.txf
Normal file
BIN
examples/src/fnt/data/NewCenturySchlbk-Italic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/NewCenturySchlbk-Roman.txf
Normal file
BIN
examples/src/fnt/data/NewCenturySchlbk-Roman.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Palatino-Bold.txf
Normal file
BIN
examples/src/fnt/data/Palatino-Bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Palatino-BoldItalic.txf
Normal file
BIN
examples/src/fnt/data/Palatino-BoldItalic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Palatino-Italic.txf
Normal file
BIN
examples/src/fnt/data/Palatino-Italic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Palatino-Roman.txf
Normal file
BIN
examples/src/fnt/data/Palatino-Roman.txf
Normal file
Binary file not shown.
48
examples/src/fnt/data/README
Normal file
48
examples/src/fnt/data/README
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
These antialiased '.txf' fonts were generated by Andrew Ross from
|
||||
Ghostscript fonts using his afm2txf script which can be found in the
|
||||
'tools' area of PLIB. All Ghostscript fonts used were GPL and Copyright
|
||||
(C) URW++ Design & Development Incorporated.
|
||||
|
||||
|
||||
Things that make them better than existing fonts are (quoted from Andrew):
|
||||
|
||||
+ They are complete. Each one has glyphs rendered for every printable
|
||||
ASCII character. No more property confusion from different strings
|
||||
rendering identically due to missing glyphs. This alone is enough
|
||||
to make them worth the price of admission. :)
|
||||
|
||||
+ They are rendered and antialiased from vector descriptions, instead
|
||||
of being pixel-for-pixel copies of X11 screen fonts. So they look a
|
||||
lot better under most conditions (at very small sizes the difference
|
||||
is negligible as mipmapping does the antialiasing for you).
|
||||
|
||||
+ They have more space around the glyphs. Mark Kilgard's 'gentexfont'
|
||||
program packed the glyphs too tightly togther; at small sizes, you could
|
||||
see "bleeding" in the textures from nearby characters.
|
||||
|
||||
+ They make better use of space in general. The characters are drawn
|
||||
as large as practical for simple layout code (i.e., I scale them up,
|
||||
but don't do any gymnastics like recursive packing or non-rectangular
|
||||
layout). So you get more font for your texture byte. Most of the
|
||||
existing '.txf' fonts use only about half of the available texture
|
||||
space.
|
||||
|
||||
+ They are professional fonts. I don't know where "typewriter.txf"
|
||||
came from, but it is awfully ugly. I replaced it with the antialiased
|
||||
Helvetica (in FlightGear), and things look *so* much nicer.
|
||||
|
||||
|
||||
Stuff that isn't ideal:
|
||||
|
||||
+ They're stored as 8 bit gray scale images instead of bitmaps, which
|
||||
means that the files are significantly larger. The texture memory
|
||||
footprint is the same, however.
|
||||
|
||||
|
||||
Note that you still find the inferior textured fonts that came with PLIB
|
||||
before in the 'old' directory.
|
||||
|
||||
|
||||
- Sebastian Ude, August 2002
|
||||
|
||||
BIN
examples/src/fnt/data/Times-Bold.txf
Normal file
BIN
examples/src/fnt/data/Times-Bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Times-BoldItalic.txf
Normal file
BIN
examples/src/fnt/data/Times-BoldItalic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Times-Italic.txf
Normal file
BIN
examples/src/fnt/data/Times-Italic.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/Times-Roman.txf
Normal file
BIN
examples/src/fnt/data/Times-Roman.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/ZapfChancery-MediumItalic.txf
Normal file
BIN
examples/src/fnt/data/ZapfChancery-MediumItalic.txf
Normal file
Binary file not shown.
34
examples/src/fnt/data/old/README
Normal file
34
examples/src/fnt/data/old/README
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
TXF Font Pack.
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Most of these fonts were created from the X-windows
|
||||
fonts that are distributed with Xfree86. The
|
||||
exceptions are Sorority, Curlfont, Default and
|
||||
Haeberli which came from Mark Kilgards' "texfont"
|
||||
distribution.
|
||||
|
||||
I used Mark's program called 'gentexfont' to convert
|
||||
X fonts into '.txf' format - which can be read into
|
||||
the PLIB FNT component.
|
||||
|
||||
Large bold-faced fonts seem to work best. There
|
||||
is little point in converting the italic versions
|
||||
of these fonts since FNT can do a reasonable job
|
||||
of italicising them on-the-fly.
|
||||
|
||||
Using large fonts gives them the best chance of
|
||||
scaling them without undue aliasing either in
|
||||
pixel or texel space. These fonts all fit pretty
|
||||
well into 256x256 maps - using smaller maps would
|
||||
require you to go for smaller font sizes - larger
|
||||
maps would not fit into 3Dfx and similar hardware.
|
||||
|
||||
Medium and fine fonts look pretty terrible when scaled,
|
||||
I have omitted all the fine fonts and some of the
|
||||
worst medium fonts from the set that come with Xfree86.
|
||||
|
||||
You can preview these using the fnt_test program,
|
||||
or use them from within other programs that use
|
||||
Mark's TXF format.
|
||||
|
||||
BIN
examples/src/fnt/data/old/charter.txf
Normal file
BIN
examples/src/fnt/data/old/charter.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/courier-bold.txf
Normal file
BIN
examples/src/fnt/data/old/courier-bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/courier_medium.txf
Normal file
BIN
examples/src/fnt/data/old/courier_medium.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/curlfont.txf
Normal file
BIN
examples/src/fnt/data/old/curlfont.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/default.txf
Normal file
BIN
examples/src/fnt/data/old/default.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/derniere.txf
Normal file
BIN
examples/src/fnt/data/old/derniere.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/haeberli.txf
Normal file
BIN
examples/src/fnt/data/old/haeberli.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/helvetica_bold.txf
Normal file
BIN
examples/src/fnt/data/old/helvetica_bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/helvetica_medium.txf
Normal file
BIN
examples/src/fnt/data/old/helvetica_medium.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/junius.txf
Normal file
BIN
examples/src/fnt/data/old/junius.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/ledfixed.txf
Normal file
BIN
examples/src/fnt/data/old/ledfixed.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/lucida.txf
Normal file
BIN
examples/src/fnt/data/old/lucida.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/lucidabright_bold.txf
Normal file
BIN
examples/src/fnt/data/old/lucidabright_bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/schoolbook_bold.txf
Normal file
BIN
examples/src/fnt/data/old/schoolbook_bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/schoolbook_medium.txf
Normal file
BIN
examples/src/fnt/data/old/schoolbook_medium.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/sorority.txf
Normal file
BIN
examples/src/fnt/data/old/sorority.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/symbol.txf
Normal file
BIN
examples/src/fnt/data/old/symbol.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/times_bold.txf
Normal file
BIN
examples/src/fnt/data/old/times_bold.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/times_medium.txf
Normal file
BIN
examples/src/fnt/data/old/times_medium.txf
Normal file
Binary file not shown.
BIN
examples/src/fnt/data/old/typewriter.txf
Normal file
BIN
examples/src/fnt/data/old/typewriter.txf
Normal file
Binary file not shown.
36
examples/src/fnt/data/test_slideshow.txt
Normal file
36
examples/src/fnt/data/test_slideshow.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
1
|
||||
2
|
||||
3 Hello to the first page.
|
||||
4 Advance by pressing "enter"
|
||||
5
|
||||
*
|
||||
6 This is the second page.
|
||||
7 Go back with backspace.
|
||||
8
|
||||
9
|
||||
*
|
||||
10 It seems you pressed enter again instead of backspace ;)
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17 This time some more lines
|
||||
18
|
||||
19
|
||||
20
|
||||
*
|
||||
The fourth page
|
||||
*
|
||||
The fifth page
|
||||
*
|
||||
The sixth page
|
||||
*
|
||||
The seventh page
|
||||
************************************************|
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
282
examples/src/fnt/fnt_test.cxx
Normal file
282
examples/src/fnt/fnt_test.cxx
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: fnt_test.cxx 2032 2005-07-05 15:43:18Z bram $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/fnt.h>
|
||||
|
||||
static fntRenderer *text ;
|
||||
|
||||
static const char *font_names [] =
|
||||
{
|
||||
"Helvetica.txf", /* This is the default */
|
||||
"Helvetica-Bold.txf",
|
||||
"Helvetica-Oblique.txf",
|
||||
"Helvetica-BoldOblique.txf",
|
||||
|
||||
"AvantGarde-Book.txf",
|
||||
"AvantGarde-BookOblique.txf",
|
||||
"AvantGarde-Demi.txf",
|
||||
"AvantGarde-DemiOblique.txf",
|
||||
|
||||
"Bookman-Light.txf",
|
||||
"Bookman-LightItalic.txf",
|
||||
"Bookman-Demi.txf",
|
||||
"Bookman-DemiItalic.txf",
|
||||
|
||||
"Courier.txf",
|
||||
"Courier-Bold.txf",
|
||||
"Courier-Oblique.txf",
|
||||
"Courier-BoldOblique.txf",
|
||||
|
||||
"NewCenturySchlbk-Roman.txf",
|
||||
"NewCenturySchlbk-Italic.txf",
|
||||
"NewCenturySchlbk-Bold.txf",
|
||||
"NewCenturySchlbk-BoldItalic.txf",
|
||||
|
||||
"Palatino-Roman.txf",
|
||||
"Palatino-Italic.txf",
|
||||
"Palatino-Bold.txf",
|
||||
"Palatino-BoldItalic.txf",
|
||||
|
||||
"Times-Roman.txf",
|
||||
"Times-Italic.txf",
|
||||
"Times-Bold.txf",
|
||||
"Times-BoldItalic.txf",
|
||||
|
||||
"ZapfChancery-MediumItalic.txf",
|
||||
|
||||
"old/sorority.txf",
|
||||
"old/charter.txf",
|
||||
/* "old/courier-bold.txf",
|
||||
"old/courier_medium.txf", */
|
||||
"old/curlfont.txf",
|
||||
"old/default.txf",
|
||||
"old/derniere.txf",
|
||||
"old/haeberli.txf",
|
||||
/* "old/helvetica_bold.txf",
|
||||
"old/helvetica_medium.txf", */
|
||||
"old/junius.txf",
|
||||
"old/ledfixed.txf",
|
||||
"old/lucida.txf",
|
||||
"old/lucidabright_bold.txf",
|
||||
/* "old/schoolbook_bold.txf",
|
||||
"old/schoolbook_medium.txf", */
|
||||
"old/symbol.txf",
|
||||
/* "old/times_bold.txf",
|
||||
"old/times_medium.txf",
|
||||
"old/typewriter.txf", */
|
||||
NULL
|
||||
} ;
|
||||
|
||||
static fntTexFont **font_list ;
|
||||
|
||||
static int cur_font = 0 ;
|
||||
static int max_font = 0 ;
|
||||
|
||||
static void motionfn ( int, int )
|
||||
{
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void keyfn ( unsigned char key, int, int )
|
||||
{
|
||||
cur_font++ ;
|
||||
|
||||
if ( cur_font >= max_font )
|
||||
cur_font = 0 ;
|
||||
}
|
||||
|
||||
static void mousefn ( int /*button*/, int /*updown*/, int /*x*/, int /*y*/ )
|
||||
{
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
static int getWindowHeight () { return glutGet ( (GLenum) GLUT_WINDOW_HEIGHT ) ; }
|
||||
static int getWindowWidth () { return glutGet ( (GLenum) GLUT_WINDOW_WIDTH ) ; }
|
||||
|
||||
static void setOpenGLState ( void )
|
||||
{
|
||||
int w = getWindowWidth () ;
|
||||
int h = getWindowHeight () ;
|
||||
|
||||
glPushAttrib ( GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
|
||||
glDisable ( GL_LIGHTING ) ;
|
||||
glDisable ( GL_FOG ) ;
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
glDisable ( GL_DEPTH_TEST ) ;
|
||||
glDisable ( GL_CULL_FACE ) ;
|
||||
glEnable ( GL_ALPHA_TEST ) ;
|
||||
glEnable ( GL_BLEND ) ;
|
||||
glAlphaFunc ( GL_GREATER, 0.1f ) ;
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
gluOrtho2D ( 0, w, 0, h ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
}
|
||||
|
||||
static void restoreOpenGLState ( void )
|
||||
{
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPopMatrix () ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPopMatrix () ;
|
||||
glPopAttrib () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void displayfn (void)
|
||||
{
|
||||
setOpenGLState () ;
|
||||
glClearColor ( 0.1f, 0.4f, 0.1f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT ) ;
|
||||
|
||||
text -> setFont ( font_list [ 0 ] ) ;
|
||||
text -> setPointSize ( 25.0f ) ;
|
||||
|
||||
text -> begin () ;
|
||||
glColor3f ( 1.0f, 1.0f, 0.0f ) ;
|
||||
text -> start2f ( 50.0f, 400.0f ) ;
|
||||
text -> puts ( "This is the PLIB Font Demo." ) ;
|
||||
text -> end () ;
|
||||
|
||||
text -> setFont ( font_list [ 0 ] ) ;
|
||||
text -> setPointSize ( 12.0f ) ;
|
||||
|
||||
text -> begin () ;
|
||||
glColor3f ( 0.0f, 0.0f, 0.0f ) ;
|
||||
text -> start2f ( 270.0f, 168.0f ) ;
|
||||
text -> puts ( "The current font is:" ) ;
|
||||
text -> start2f ( 300.0f, 148.0f ) ;
|
||||
text -> puts ( font_names [ cur_font ] ) ;
|
||||
text -> start2f ( 270.0f, 128.0f ) ;
|
||||
text -> puts ( "Press any key to change the font.\nClick the mouse to exit." ) ;
|
||||
text -> end () ;
|
||||
|
||||
text -> setFont ( font_list [ cur_font ] ) ;
|
||||
text -> setPointSize ( 25.0f ) ;
|
||||
|
||||
text -> begin () ;
|
||||
glColor3f ( 0.0f, 1.0f, 1.0f ) ;
|
||||
text -> start2f ( 50.0f, 360.0f ) ;
|
||||
text -> puts ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) ;
|
||||
glColor3f ( 1.0f, 0.0f, 1.0f ) ;
|
||||
text -> start2f ( 50.0f, 320.0f ) ;
|
||||
text -> puts ( "abcdefghijklmnopqrstuvwxyz" ) ;
|
||||
glColor3f ( 1.0f, 0.0f, 0.0f ) ;
|
||||
text -> start2f ( 50.0f, 280.0f ) ;
|
||||
text -> puts ( "0123456789!@#$%^&*()+-={}[]:\"'<>?,./`~_" ) ;
|
||||
text -> end () ;
|
||||
|
||||
text -> setPointSize ( 9.0f ) ;
|
||||
text -> begin () ;
|
||||
glColor3f ( 0, 0, 0 ) ;
|
||||
text -> start2f ( -50.0f, 265.0f ) ;
|
||||
text -> puts ( "This is a very long line, in fact, this line is so long, that it starts left of viewport. We are curious to see wether this line is still visible in plib." ) ;
|
||||
text -> end () ;
|
||||
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
glBegin ( GL_LINE_LOOP ) ;
|
||||
glColor3f ( 1.0f, 0.0f, 1.0f ) ;
|
||||
glVertex2f ( 0.0f, 0.0f ) ;
|
||||
glVertex2f ( 256.0f, 0.0f ) ;
|
||||
glVertex2f ( 256.0f, 256.0f ) ;
|
||||
glVertex2f ( 0.0f, 256.0f ) ;
|
||||
glEnd () ;
|
||||
|
||||
glEnable ( GL_TEXTURE_2D ) ;
|
||||
glBegin ( GL_TRIANGLE_STRIP ) ;
|
||||
glColor3f ( 1.0f, 1.0f, 1.0f ) ;
|
||||
glTexCoord2f( 0.0f, 0.0f ) ; glVertex2f ( 0.0f, 0.0f ) ;
|
||||
glTexCoord2f( 1.0f, 0.0f ) ; glVertex2f ( 256.0f, 0.0f ) ;
|
||||
glTexCoord2f( 0.0f, 1.0f ) ; glVertex2f ( 0.0f, 256.0f ) ;
|
||||
glTexCoord2f( 1.0f, 1.0f ) ; glVertex2f ( 256.0f, 256.0f ) ;
|
||||
glEnd () ;
|
||||
|
||||
restoreOpenGLState () ;
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
font_list = new fntTexFont* [ sizeof(font_names) / sizeof(font_names[0]) ] ;
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &argc, argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( "FNT Application" ) ;
|
||||
glutDisplayFunc ( displayfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
|
||||
text = new fntRenderer () ;
|
||||
|
||||
for ( max_font = 0 ; font_names [ max_font ] != NULL ; max_font++ )
|
||||
{
|
||||
char fname [ 256 ] ;
|
||||
|
||||
#ifdef macintosh
|
||||
sprintf ( fname, ":data:%s", font_names [ max_font ] ) ;
|
||||
#else
|
||||
sprintf ( fname, "data/%s", font_names [ max_font ] ) ;
|
||||
#endif
|
||||
|
||||
font_list [ max_font ] = new fntTexFont ( fname ) ;
|
||||
}
|
||||
|
||||
cur_font = 0 ;
|
||||
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
88
examples/src/fnt/fnt_test.dsp
Normal file
88
examples/src/fnt/fnt_test.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="fnt_test" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=fnt_test - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "fnt_test.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "fnt_test.mak" CFG="fnt_test - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "fnt_test - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "fnt_test - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "fnt_test - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fnt.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"fnt_test.exe" /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "fnt_test - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fnt_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"fnt_test.exe" /pdbtype:sept /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "fnt_test - Win32 Release"
|
||||
# Name "fnt_test - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\fnt_test.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
65
examples/src/fnt/hello_world.cxx
Normal file
65
examples/src/fnt/hello_world.cxx
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: hello_world.cxx 1996 2004-12-29 07:19:40Z sjbaker $
|
||||
*/
|
||||
|
||||
|
||||
#include <plib/pw.h>
|
||||
#include <plib/fnt.h>
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
int w, h ;
|
||||
|
||||
pwInit ( 100, 100, 230, 50, false, "FNT Hello World Demo", true, 0 ) ;
|
||||
pwSetCallbacks ( NULL, NULL, NULL, NULL, NULL ) ;
|
||||
pwGetSize ( &w, &h ) ;
|
||||
|
||||
fntRenderer *text = new fntRenderer () ;
|
||||
|
||||
text -> setFont ( new fntTexFont ( "data/Helvetica.txf" ) ) ;
|
||||
text -> setPointSize ( 30.0f ) ;
|
||||
|
||||
glEnable ( GL_ALPHA_TEST ) ;
|
||||
glEnable ( GL_BLEND ) ;
|
||||
glAlphaFunc ( GL_GREATER, 0.1f ) ;
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glLoadIdentity () ;
|
||||
glOrtho ( 0, w, 0, h, -1, 1 ) ;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
glClearColor ( 0.1f, 0.4f, 0.1f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT ) ;
|
||||
|
||||
text -> begin () ;
|
||||
glColor3f ( 1.0f, 1.0f, 0.0f ) ;
|
||||
text -> start2f ( 10.0f, 10.0f ) ;
|
||||
text -> puts ( "Hello World." ) ;
|
||||
text -> end () ;
|
||||
|
||||
pwSwapBuffers () ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
235
examples/src/fnt/slideshow.cxx
Normal file
235
examples/src/fnt/slideshow.cxx
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: slideshow.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
# ifdef __CYGWIN32__
|
||||
# include <sys/stat.h>
|
||||
# include <unistd.h>
|
||||
# else
|
||||
# include <sys/stat.h>
|
||||
# endif
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/fnt.h>
|
||||
|
||||
static fntRenderer *text ;
|
||||
static fntTexFont *font ;
|
||||
|
||||
static char *file ;
|
||||
static char **line ;
|
||||
static int *page ;
|
||||
static int num_lines = 0 ;
|
||||
static int num_pages = 0 ;
|
||||
static int curr_page = 0 ;
|
||||
|
||||
static void motionfn ( int, int )
|
||||
{
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void keyfn ( unsigned char key, int, int )
|
||||
{
|
||||
switch ( key )
|
||||
{
|
||||
case 'H' : case 'R' : curr_page = 0 ; break ;
|
||||
|
||||
case '<' : case '{' : curr_page-=5 ; break ;
|
||||
|
||||
case 0x08 : /* Backspace */
|
||||
case '[' : case ',' : curr_page-- ; break ;
|
||||
|
||||
case '>' : case '}' : curr_page+=5 ; break ;
|
||||
case ' ' :
|
||||
case '\n' :
|
||||
case '\r' :
|
||||
case ']' : case '.' : curr_page++ ; break ;
|
||||
|
||||
case 0x03 : /* Ctrl-C */
|
||||
case 'x' :
|
||||
case 'X' : exit ( 0 ) ;
|
||||
}
|
||||
|
||||
if ( curr_page < 0 ) curr_page = 0 ;
|
||||
if ( curr_page >= num_pages ) curr_page = num_pages-1 ;
|
||||
}
|
||||
|
||||
static void mousefn ( int /*button*/, int /*updown*/, int /*x*/, int /*y*/ )
|
||||
{
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
static int getWindowHeight () { return glutGet ( (GLenum) GLUT_WINDOW_HEIGHT ) ; }
|
||||
static int getWindowWidth () { return glutGet ( (GLenum) GLUT_WINDOW_WIDTH ) ; }
|
||||
|
||||
static void setOpenGLState ( void )
|
||||
{
|
||||
int w = getWindowWidth () ;
|
||||
int h = getWindowHeight () ;
|
||||
|
||||
glutWarpPointer ( 320, 240 ) ;
|
||||
|
||||
glPushAttrib ( GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
|
||||
glDisable ( GL_LIGHTING ) ;
|
||||
glDisable ( GL_FOG ) ;
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
glDisable ( GL_DEPTH_TEST ) ;
|
||||
glDisable ( GL_CULL_FACE ) ;
|
||||
glEnable ( GL_ALPHA_TEST ) ;
|
||||
glEnable ( GL_BLEND ) ;
|
||||
glAlphaFunc ( GL_GREATER, 0.1f ) ;
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
gluOrtho2D ( 0, w, 0, h ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
}
|
||||
|
||||
static void restoreOpenGLState ( void )
|
||||
{
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPopMatrix () ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPopMatrix () ;
|
||||
glPopAttrib () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void displayfn (void)
|
||||
{
|
||||
setOpenGLState () ;
|
||||
glClearColor ( 0.1f, 0.4f, 0.1f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT ) ;
|
||||
|
||||
text -> setFont ( font ) ;
|
||||
text -> setPointSize ( 25.0f ) ;
|
||||
|
||||
int row = 460 ;
|
||||
|
||||
text -> begin () ;
|
||||
glColor3f ( 1.0f, 1.0f, 1.0f ) ;
|
||||
|
||||
for ( int i = page [ curr_page ] ;
|
||||
i < page [ curr_page+1 ]-1 && i < num_lines && row > 0 ; i++ )
|
||||
{
|
||||
text -> start2f ( 10.0f, (float)row ) ;
|
||||
text -> puts ( line[i] ) ;
|
||||
row -= 30 ;
|
||||
}
|
||||
text -> end () ;
|
||||
|
||||
restoreOpenGLState () ;
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
|
||||
struct stat buf ;
|
||||
const char* fname = NULL ;
|
||||
|
||||
if ( argc > 1 )
|
||||
fname = argv[1] ;
|
||||
else
|
||||
fname = "data/test_slideshow.txt" ;
|
||||
|
||||
FILE *fd = fopen ( fname, "r" ) ;
|
||||
|
||||
if ( fd == NULL )
|
||||
exit ( 1 ) ;
|
||||
|
||||
fstat ( fileno(fd), & buf ) ;
|
||||
|
||||
off_t len = buf.st_size ;
|
||||
|
||||
file = new char [ len+1 ] ;
|
||||
line = new char* [ len+1 ] ;
|
||||
page = new int [ len+1 ] ;
|
||||
|
||||
fread ( file, 1, len, fd ) ;
|
||||
fclose ( fd ) ;
|
||||
|
||||
file [ len ] = '\0' ;
|
||||
|
||||
num_lines = 0 ;
|
||||
num_pages = 0 ;
|
||||
|
||||
line [ num_lines ] = file ;
|
||||
page [ num_pages ] = 0 ;
|
||||
|
||||
for ( int i = 0 ; i < len ; i++ )
|
||||
{
|
||||
if ( file [ i ] == '\n' )
|
||||
{
|
||||
file [ i ] = '\0' ;
|
||||
line [ ++num_lines ] = & file [ i+1 ] ;
|
||||
|
||||
if ( line [ num_lines ][ 0 ] == '*' )
|
||||
page [ ++num_pages ] = num_lines+1 ;
|
||||
}
|
||||
}
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &argc, argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( "FNT Application" ) ;
|
||||
glutDisplayFunc ( displayfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
|
||||
text = new fntRenderer () ;
|
||||
font = new fntTexFont ( "data/old/lucida.txf" ) ;
|
||||
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
88
examples/src/fnt/slideshow.dsp
Normal file
88
examples/src/fnt/slideshow.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="slideshow" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=slideshow - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "slideshow.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "slideshow.mak" CFG="slideshow - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "slideshow - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "slideshow - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "slideshow - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fnt.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcd.lib" /out:"slideshow.exe" /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "slideshow - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fnt_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"slideshow.exe" /pdbtype:sept /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "slideshow - Win32 Release"
|
||||
# Name "slideshow - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\slideshow.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
12
examples/src/js/Makefile.am
Normal file
12
examples/src/js/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_JS
|
||||
|
||||
noinst_PROGRAMS = js_demo
|
||||
|
||||
js_demo_SOURCES = js_demo.cxx
|
||||
|
||||
js_demo_LDADD = -lplibjs -lplibul
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = js_demo.dsp
|
||||
|
||||
124
examples/src/js/js_demo.cxx
Normal file
124
examples/src/js/js_demo.cxx
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: js_demo.cxx 1551 2002-09-01 12:04:53Z ude $
|
||||
*/
|
||||
|
||||
|
||||
#include <plib/js.h>
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
jsJoystick *js[2] ;
|
||||
float *ax[2] ;
|
||||
|
||||
jsInit () ;
|
||||
|
||||
js[0] = new jsJoystick ( 0 ) ;
|
||||
js[1] = new jsJoystick ( 1 ) ;
|
||||
|
||||
printf ( "Joystick test program.\n" ) ;
|
||||
printf ( "~~~~~~~~~~~~~~~~~~~~~~\n" ) ;
|
||||
|
||||
if ( js[0]->notWorking () )
|
||||
printf ( "Joystick 0 not detected\n" ) ;
|
||||
else
|
||||
printf ( "Joystick 0 is \"%s\"\n", js[0]->getName() ) ;
|
||||
|
||||
if ( js[1]->notWorking () )
|
||||
printf ( "Joystick 1 not detected\n" ) ;
|
||||
else
|
||||
printf ( "Joystick 1 is \"%s\"\n", js[1]->getName() ) ;
|
||||
|
||||
if ( js[0]->notWorking () && js[1]->notWorking () ) exit ( 1 ) ;
|
||||
|
||||
ax[0] = new float [ js[0]->getNumAxes () ] ;
|
||||
ax[1] = new float [ js[1]->getNumAxes () ] ;
|
||||
|
||||
int i, j ;
|
||||
|
||||
for ( i = 0 ; i < 2 ; i++ )
|
||||
printf ( "+---------------JS.%d-----------------", i ) ;
|
||||
|
||||
printf ( "+\n" ) ;
|
||||
|
||||
for ( i = 0 ; i < 2 ; i++ )
|
||||
{
|
||||
if ( js[i]->notWorking () )
|
||||
printf ( "| ~~~ Not Detected ~~~ " ) ;
|
||||
else
|
||||
{
|
||||
printf ( "| Btns " ) ;
|
||||
|
||||
for ( j = 0 ; j < js[i]->getNumAxes () ; j++ )
|
||||
printf ( "Ax:%d ", j ) ;
|
||||
|
||||
for ( ; j < 6 ; j++ )
|
||||
printf ( " " ) ;
|
||||
}
|
||||
}
|
||||
|
||||
printf ( "|\n" ) ;
|
||||
|
||||
for ( i = 0 ; i < 2 ; i++ )
|
||||
printf ( "+------------------------------------" ) ;
|
||||
|
||||
printf ( "+\n" ) ;
|
||||
|
||||
while (1)
|
||||
{
|
||||
for ( i = 0 ; i < 2 ; i++ )
|
||||
{
|
||||
if ( js[i]->notWorking () )
|
||||
printf ( "| . . . . . . . . . " ) ;
|
||||
else
|
||||
{
|
||||
int b ;
|
||||
|
||||
js[i]->read ( &b, ax[i] ) ;
|
||||
|
||||
printf ( "| %04x ", b ) ;
|
||||
|
||||
for ( j = 0 ; j < js[i]->getNumAxes () ; j++ )
|
||||
printf ( "%+.1f ", ax[i][j] ) ;
|
||||
|
||||
for ( ; j < 6 ; j++ )
|
||||
printf ( " . " ) ;
|
||||
}
|
||||
}
|
||||
|
||||
printf ( "|\r" ) ;
|
||||
fflush ( stdout ) ;
|
||||
|
||||
/* give other processes a chance */
|
||||
|
||||
#ifdef WIN32
|
||||
Sleep ( 1 ) ;
|
||||
#elif defined(sgi)
|
||||
sginap ( 1 ) ;
|
||||
#else
|
||||
usleep ( 1000 ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
88
examples/src/js/js_demo.dsp
Normal file
88
examples/src/js/js_demo.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="js_demo" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=js_demo - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "js_demo.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "js_demo.mak" CFG="js_demo - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "js_demo - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "js_demo - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "js_demo - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ul.lib js.lib winmm.lib /nologo /subsystem:console /machine:I386 /out:"js_demo.exe" /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "js_demo - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ul_d.lib js_d.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /out:"js_demo.exe" /pdbtype:sept /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "js_demo - Win32 Release"
|
||||
# Name "js_demo - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\js_demo.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
3
examples/src/net/Makefile.am
Normal file
3
examples/src/net/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
SUBDIRS = client_server http_get net_echo
|
||||
|
||||
14
examples/src/net/client_server/Makefile.am
Normal file
14
examples/src/net/client_server/Makefile.am
Normal file
@@ -0,0 +1,14 @@
|
||||
if BUILD_NET
|
||||
|
||||
noinst_PROGRAMS = net_udp_client net_udp_server
|
||||
|
||||
net_udp_client_SOURCES = net_udp_client.cxx
|
||||
net_udp_client_LDADD = -lplibnet -lplibul
|
||||
|
||||
net_udp_server_SOURCES = net_udp_server.cxx
|
||||
net_udp_server_LDADD = -lplibnet -lplibul
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = net_udp_client.dsp net_udp_server.dsp
|
||||
|
||||
25
examples/src/net/client_server/README
Normal file
25
examples/src/net/client_server/README
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
This example demonstrates a simple one-way communication path
|
||||
between a client and a server.
|
||||
|
||||
It uses UDP protocol - which is unreliable but fast - don't
|
||||
use it for messages that utterly must get there!
|
||||
|
||||
The client program can be told to send to the server on any port number of
|
||||
any host computer - by default it uses 'localhost'.
|
||||
|
||||
The server program can be told to listen out on any port number
|
||||
and to either listen to just one specific client - or to accept
|
||||
messages from any client.
|
||||
|
||||
Usage:
|
||||
|
||||
net_udp_client [-p port] [servername]
|
||||
net_udp_server [-p port] [clientname]
|
||||
|
||||
The default for the client is to use port 5501 on 'localhost'.
|
||||
The default to the server is to listen on port 5501 and to allow anyone
|
||||
to send to it. The name "<broadcast>" refers to the broadcast address.
|
||||
(To enter it on the command line, you'll need to escape the < and >
|
||||
symbols like this: \<broadcast\> )
|
||||
|
||||
105
examples/src/net/client_server/net_udp_client.cxx
Normal file
105
examples/src/net/client_server/net_udp_client.cxx
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: net_udp_client.cxx 1898 2004-03-21 17:13:00Z sjbaker $
|
||||
*/
|
||||
|
||||
// This is an example of a UDP client that blasts messages at a
|
||||
// server.
|
||||
//
|
||||
// UDP is a "fire and forget" protocal so the client and server can be
|
||||
// started up in any order. The client doesn't care if the server
|
||||
// receives the messages and the server doesn't care if the client is
|
||||
// sending messages, so either side can be killed and restarted at any
|
||||
// time.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <plib/net.h>
|
||||
#include <plib/ul.h>
|
||||
|
||||
void help ()
|
||||
{
|
||||
fprintf ( stderr, "net_udp_client: Usage -\n" ) ;
|
||||
fprintf ( stderr, "\n" ) ;
|
||||
fprintf ( stderr, " net_udp_client [-h] [-p port] [hostname]\n" ) ;
|
||||
fprintf ( stderr, "\n" ) ;
|
||||
fprintf ( stderr, "Where:\n" ) ;
|
||||
fprintf ( stderr, " -h -- Help (displays this message).\n" ) ;
|
||||
fprintf ( stderr, " -p port -- Set the port number (def=5501).\n" ) ;
|
||||
fprintf ( stderr, " hostname -- Set the host name (def=localhost).\n" ) ;
|
||||
fprintf ( stderr, "\n" ) ;
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
int port = 5501 ;
|
||||
char host[256] = "localhost" ;
|
||||
|
||||
for ( int i = 1 ; i < argc ; i++ )
|
||||
{
|
||||
if ( argv [ i ][ 0 ] == '-' || argv [ i ][ 0 ] == '+' )
|
||||
switch ( argv [ i ][ 1 ] )
|
||||
{
|
||||
case 'p' : port = atoi ( argv [ ++i ] ) ; break ;
|
||||
case 'h' :
|
||||
default : help () ; break ;
|
||||
}
|
||||
else
|
||||
strcpy ( host, argv [ i ] ) ;
|
||||
}
|
||||
|
||||
fprintf ( stderr, "Talking to host '%s' on port %d\n", host, port ) ;
|
||||
|
||||
// Must call this before any other net stuff
|
||||
|
||||
netInit() ;
|
||||
|
||||
netSocket *sock = new netSocket () ;
|
||||
|
||||
if ( ! sock -> open ( false ) ) // open a UDP socket
|
||||
{
|
||||
printf ( "error opening socket\n" ) ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
sock -> setBlocking ( false ) ;
|
||||
|
||||
if ( sock -> connect( host, port ) == -1 )
|
||||
{
|
||||
printf ( "error connecting to %s:%d\n", host, port ) ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
char msg[256] = "Hello world!" ;
|
||||
|
||||
int len = strlen ( msg ) ;
|
||||
|
||||
while ( true )
|
||||
{
|
||||
ulSleep ( 1 ) ;
|
||||
sock -> send( msg, len, 0 );
|
||||
printf("msg sent = %s\n", msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
88
examples/src/net/client_server/net_udp_client.dsp
Normal file
88
examples/src/net/client_server/net_udp_client.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="net_udp_client" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=net_udp_client - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "net_udp_client.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "net_udp_client.mak" CFG="net_udp_client - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "net_udp_client - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "net_udp_client - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "net_udp_client - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net.lib ul.lib wsock32.lib /nologo /subsystem:console /machine:I386 /out:"net_udp_client.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "net_udp_client - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net_d.lib ul_d.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /out:"net_udp_client.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "net_udp_client - Win32 Release"
|
||||
# Name "net_udp_client - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\net_udp_client.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
87
examples/src/net/client_server/net_udp_server.cxx
Normal file
87
examples/src/net/client_server/net_udp_server.cxx
Normal file
@@ -0,0 +1,87 @@
|
||||
// This is an example of a UDP server that accepts messages coming from a
|
||||
// client.
|
||||
//
|
||||
// UDP is a "fire and forget" protocal so the client and server can be
|
||||
// started up in any order. The client doesn't care if the server
|
||||
// receives the messages and the server doesn't care if the client is
|
||||
// sending messages, so either side can be killed and restarted at any
|
||||
// time.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <plib/net.h>
|
||||
|
||||
|
||||
void help ()
|
||||
{
|
||||
fprintf ( stderr, "net_udp_server: Usage -\n" ) ;
|
||||
fprintf ( stderr, "\n" ) ;
|
||||
fprintf ( stderr, " net_udp_server [-h] [-p port] [hostname]\n" ) ;
|
||||
fprintf ( stderr, "\n" ) ;
|
||||
fprintf ( stderr, "Where:\n" ) ;
|
||||
fprintf ( stderr, " -h -- Help (displays this message).\n" ) ;
|
||||
fprintf ( stderr, " -p port -- Set the port number (def=5501).\n" ) ;
|
||||
fprintf ( stderr, " hostname -- Set the client host name (def=any host).\n");
|
||||
fprintf ( stderr, "\n" ) ;
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int port = 5501 ;
|
||||
char host [ 256 ] = "" ;
|
||||
|
||||
for ( int i = 1 ; i < argc ; i++ )
|
||||
{
|
||||
if ( argv [ i ][ 0 ] == '-' || argv [ i ][ 0 ] == '+' )
|
||||
switch ( argv [ i ][ 1 ] )
|
||||
{
|
||||
case 'p' : port = atoi ( argv [ ++i ] ) ; break ;
|
||||
case 'h' :
|
||||
default : help () ; break ;
|
||||
}
|
||||
else
|
||||
strcpy ( host, argv [ i ] ) ;
|
||||
}
|
||||
|
||||
if ( host [ 0 ] == '\0' )
|
||||
fprintf ( stderr, "Listening to any host on port %d\n", port ) ;
|
||||
else
|
||||
fprintf ( stderr, "Listening to host '%s' on port %d\n", host, port ) ;
|
||||
|
||||
// Must call this before any other net stuff
|
||||
|
||||
netInit () ;
|
||||
|
||||
netSocket *sock = new netSocket () ;
|
||||
|
||||
if ( ! sock -> open( false ) ) // open a UDP socket
|
||||
{
|
||||
printf ( "error opening socket\n" ) ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
sock -> setBlocking ( false ) ;
|
||||
|
||||
if ( sock -> bind( host, port ) == -1 )
|
||||
{
|
||||
printf ( "error binding to port %s:%d\n", host, port ) ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
char msg [ 256 ] ;
|
||||
int maxlen = 256 ;
|
||||
int len ;
|
||||
|
||||
while ( true )
|
||||
{
|
||||
if ( (len = sock -> recv(msg, maxlen, 0)) >= 0 )
|
||||
{
|
||||
msg[len] = '\0' ;
|
||||
printf ( "msg received = %s\n", msg ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
88
examples/src/net/client_server/net_udp_server.dsp
Normal file
88
examples/src/net/client_server/net_udp_server.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="net_udp_server" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=net_udp_server - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "net_udp_server.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "net_udp_server.mak" CFG="net_udp_server - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "net_udp_server - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "net_udp_server - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "net_udp_server - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net.lib ul.lib wsock32.lib /nologo /subsystem:console /machine:I386 /out:"net_udp_server.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "net_udp_server - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net_d.lib ul_d.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /out:"net_udp_server.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "net_udp_server - Win32 Release"
|
||||
# Name "net_udp_server - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\net_udp_server.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
12
examples/src/net/http_get/Makefile.am
Normal file
12
examples/src/net/http_get/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_NET
|
||||
|
||||
noinst_PROGRAMS = http_get
|
||||
|
||||
http_get_SOURCES = http_get.cxx
|
||||
|
||||
http_get_LDADD = -lplibnet -lplibul
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = http_get.dsp
|
||||
|
||||
6
examples/src/net/http_get/README
Normal file
6
examples/src/net/http_get/README
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
This demonstrates the fetching of a HTTP web page using the network
|
||||
library.
|
||||
|
||||
It's hardwired to fetch the PLIB home-page.
|
||||
|
||||
75
examples/src/net/http_get/http_get.cxx
Normal file
75
examples/src/net/http_get/http_get.cxx
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: http_get.cxx 1906 2004-03-22 19:44:50Z sjbaker $
|
||||
*/
|
||||
|
||||
#include <plib/net.h>
|
||||
|
||||
class HTTPClient : public netBufferChannel
|
||||
{
|
||||
FILE *fpout ;
|
||||
|
||||
public:
|
||||
|
||||
HTTPClient ( const char* host, const char* path )
|
||||
{
|
||||
open () ;
|
||||
connect ( host, 80 ) ;
|
||||
|
||||
const char* s = netFormat ( "GET %s HTTP/1.1\r\n", path ) ;
|
||||
bufferSend ( s, strlen(s) ) ;
|
||||
const char* h = netFormat ( "host: %s\r\n", host ) ;
|
||||
bufferSend ( h, strlen(h) ) ;
|
||||
const char *c = netFormat ( "Connection: close\r\n\r\n" ) ;
|
||||
bufferSend ( c, strlen(c) ) ;
|
||||
}
|
||||
|
||||
~HTTPClient ()
|
||||
{
|
||||
if( fpout )
|
||||
fclose( fpout );
|
||||
}
|
||||
|
||||
virtual void handleBufferRead (netBuffer& buffer)
|
||||
{
|
||||
const char* s = buffer.getData();
|
||||
|
||||
while (*s)
|
||||
fputc(*s++,stdout);
|
||||
|
||||
buffer.remove();
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
int main ( int argc, char * argv[] )
|
||||
{
|
||||
netInit ( &argc, argv ) ;
|
||||
|
||||
new HTTPClient ( "plib.sourceforge.net", "/index.html" ) ;
|
||||
|
||||
netChannel::loop ( 0 ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
88
examples/src/net/http_get/http_get.dsp
Normal file
88
examples/src/net/http_get/http_get.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="http_get" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=http_get - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "http_get.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "http_get.mak" CFG="http_get - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "http_get - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "http_get - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "http_get - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net.lib ul.lib wsock32.lib /nologo /subsystem:console /machine:I386 /out:"http_get.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "http_get - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net_d.lib ul_d.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /out:"http_get.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "http_get - Win32 Release"
|
||||
# Name "http_get - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\http_get.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
12
examples/src/net/net_echo/Makefile.am
Normal file
12
examples/src/net/net_echo/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_NET
|
||||
|
||||
noinst_PROGRAMS = net_echo
|
||||
|
||||
net_echo_SOURCES = net_echo.cxx
|
||||
|
||||
net_echo_LDADD = -lplibnet -lplibul
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = net_echo.dsp
|
||||
|
||||
16
examples/src/net/net_echo/README
Normal file
16
examples/src/net/net_echo/README
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
This is a simple example server that reads lines of text from the client
|
||||
and echoes them back. An echo server is usually running on TCP
|
||||
port 7 of Unix machines.
|
||||
|
||||
Start it running someplace on your network, then use 'telnet' to
|
||||
connect to it on port 8000:
|
||||
|
||||
telnet localhost 8000
|
||||
|
||||
...notice that you can open multiple telnet sessions - and the
|
||||
server echoes the right data back to the right client.
|
||||
|
||||
You can choose a port number other than 8000 by putting it on the
|
||||
command line of the echo server.
|
||||
|
||||
97
examples/src/net/net_echo/net_echo.cxx
Normal file
97
examples/src/net/net_echo/net_echo.cxx
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: net_echo.cxx 1898 2004-03-21 17:13:00Z sjbaker $
|
||||
*/
|
||||
|
||||
#include <plib/net.h>
|
||||
|
||||
/*
|
||||
** simple example server that reads lines of text from the client
|
||||
** and echoes them back. An echo server is usually running on TCP
|
||||
** port 7 of Unix machines.
|
||||
*/
|
||||
|
||||
class EchoChannel : public netChat
|
||||
{
|
||||
netBuffer buffer ;
|
||||
|
||||
public:
|
||||
|
||||
EchoChannel() : buffer(512) { setTerminator("\r\n"); }
|
||||
|
||||
virtual void collectIncomingData (const char* s, int n)
|
||||
{
|
||||
buffer.append(s,n);
|
||||
}
|
||||
|
||||
virtual void foundTerminator (void)
|
||||
{
|
||||
const char* s = buffer.getData();
|
||||
printf("echo: %s\n",s);
|
||||
|
||||
push(s);
|
||||
push(getTerminator());
|
||||
|
||||
buffer.remove();
|
||||
}
|
||||
} ;
|
||||
|
||||
class EchoServer : private netChannel
|
||||
{
|
||||
virtual bool writable (void) { return false ; }
|
||||
|
||||
virtual void handleAccept (void)
|
||||
{
|
||||
netAddress addr ;
|
||||
int handle = accept ( &addr ) ;
|
||||
printf("Client %s:%d connected\n",addr.getHost(),addr.getPort());
|
||||
|
||||
EchoChannel * ec = new EchoChannel;
|
||||
ec->setHandle ( handle ) ;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
EchoServer ( int port )
|
||||
{
|
||||
open () ;
|
||||
bind ("", port) ;
|
||||
listen (5) ;
|
||||
|
||||
printf ( "Echo Server started on port %d\n", port ) ;
|
||||
}
|
||||
} ;
|
||||
|
||||
int
|
||||
main (int argc, char * argv[])
|
||||
{
|
||||
int port = 8000 ;
|
||||
|
||||
if (argc > 1)
|
||||
port = atoi (argv[1]);
|
||||
|
||||
netInit(&argc,argv);
|
||||
|
||||
new EchoServer ( port ) ;
|
||||
|
||||
netChannel::loop(0);
|
||||
return 0;
|
||||
}
|
||||
88
examples/src/net/net_echo/net_echo.dsp
Normal file
88
examples/src/net/net_echo/net_echo.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="net_echo" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=net_echo - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "net_echo.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "net_echo.mak" CFG="net_echo - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "net_echo - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "net_echo - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "net_echo - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net.lib ul.lib wsock32.lib /nologo /subsystem:console /machine:I386 /out:"net_echo.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "net_echo - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib net_d.lib ul_d.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /out:"net_echo.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "net_echo - Win32 Release"
|
||||
# Name "net_echo - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\net_echo.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
13
examples/src/psl/Makefile.am
Normal file
13
examples/src/psl/Makefile.am
Normal file
@@ -0,0 +1,13 @@
|
||||
if BUILD_PSL
|
||||
|
||||
noinst_PROGRAMS = psl_demo
|
||||
|
||||
psl_demo_SOURCES = psl_demo.cxx
|
||||
|
||||
psl_demo_LDADD = -lplibpsl -lplibul -lm
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = psl_demo.dsp
|
||||
|
||||
|
||||
4
examples/src/psl/data/header.psh
Normal file
4
examples/src/psl/data/header.psh
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
void newline () { printf ( "\n" ) ; }
|
||||
void tab () { printf ( "\t" ) ; }
|
||||
|
||||
9
examples/src/psl/data/test.psl
Normal file
9
examples/src/psl/data/test.psl
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
void main ()
|
||||
{
|
||||
int diff ;
|
||||
|
||||
if ( diff == 1 ) { diff = 2 ; } else { diff = 3 ; }
|
||||
}
|
||||
|
||||
129
examples/src/psl/psl_demo.cxx
Normal file
129
examples/src/psl/psl_demo.cxx
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: psl_demo.cxx 1912 2004-03-24 10:54:56Z nmcevoy $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <plib/psl.h>
|
||||
|
||||
pslValue my_printf ( int argc, pslValue *argv, pslProgram *p )
|
||||
{
|
||||
if ( argv[0].getType() != PSL_STRING )
|
||||
printf ( "printf: ERROR - First param must be a string!\n" ) ;
|
||||
else
|
||||
{
|
||||
printf ( "%s", argv[0].getString() ) ;
|
||||
|
||||
for ( int i = 1 ; i < argc ; i++ )
|
||||
{
|
||||
switch ( argv[i].getType () )
|
||||
{
|
||||
case PSL_INT : printf ( "%d ", argv[i].getInt () ) ; break ;
|
||||
case PSL_FLOAT : printf ( "%f ", argv[i].getFloat () ) ; break ;
|
||||
case PSL_STRING : printf ( "%s ", argv[i].getString () ) ; break ;
|
||||
case PSL_VOID : printf ( "(void) " ) ; break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pslValue ret ;
|
||||
return ret ;
|
||||
}
|
||||
|
||||
|
||||
pslValue identify ( int argc, pslValue *argv, pslProgram *p )
|
||||
{
|
||||
printf ( "I am %s.\n", (char *)( p->getUserData ()) ) ;
|
||||
|
||||
pslValue ret ;
|
||||
return ret ;
|
||||
}
|
||||
|
||||
|
||||
pslExtension extensions [] =
|
||||
{
|
||||
{ "identify", 0, identify },
|
||||
{ "printf", -1, my_printf },
|
||||
{ NULL, 0, NULL }
|
||||
} ;
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
pslInit () ;
|
||||
|
||||
/* Create program 1 and compile it. */
|
||||
|
||||
pslProgram *prog_1 = new pslProgram ( extensions, "code1" ) ;
|
||||
|
||||
ulClock ck ;
|
||||
ck.setMaxDelta ( 100000.0 ) ;
|
||||
ck.update () ;
|
||||
|
||||
prog_1 -> compile ( "data/test.psl" ) ;
|
||||
|
||||
ck.update () ;
|
||||
fprintf(stderr, "%fs compiletime elapsed\n", ck.getDeltaTime () ) ;
|
||||
|
||||
prog_1 -> dump () ;
|
||||
|
||||
/* Clone program 2 from program 1 */
|
||||
|
||||
pslProgram *prog_2 = new pslProgram ( prog_1, "code2" ) ;
|
||||
|
||||
/* Make program 3 from inline strings. */
|
||||
|
||||
pslProgram *prog_3 = new pslProgram ( extensions, "inline" ) ;
|
||||
|
||||
prog_3 -> compile ( "int main () { printf ( \"Hello World.\\n\" ) ; }\n",
|
||||
"HelloProgram" ) ;
|
||||
|
||||
/* Make them unique by assigning user data to them */
|
||||
|
||||
prog_1 -> setUserData ( (void *) "Program 1" ) ;
|
||||
prog_2 -> setUserData ( (void *) "Program 2" ) ;
|
||||
prog_3 -> setUserData ( (void *) "Program 3" ) ;
|
||||
|
||||
ck.update () ;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( prog_1 -> step () == PSL_PROGRAM_END &&
|
||||
prog_2 -> step () == PSL_PROGRAM_END &&
|
||||
prog_3 -> step () == PSL_PROGRAM_END )
|
||||
break ;
|
||||
}
|
||||
ck.update () ;
|
||||
fprintf(stderr, "%fs runtime elapsed\n", ck.getDeltaTime () ) ;
|
||||
|
||||
exit ( 0 ) ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
90
examples/src/psl/psl_demo.dsp
Normal file
90
examples/src/psl/psl_demo.dsp
Normal file
@@ -0,0 +1,90 @@
|
||||
# Microsoft Developer Studio Project File - Name="psl_demo" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=psl_demo - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "psl_demo.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "psl_demo.mak" CFG="psl_demo - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "psl_demo - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "psl_demo - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "psl_demo - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib psl.lib ul.lib /nologo /subsystem:console /machine:I386 /out:"psl_demo.exe" /libpath:"..\..\..\..\plib"
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "psl_demo - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib psl_d.lib ul_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"psl_demo.exe" /pdbtype:sept /libpath:"..\..\..\..\plib"
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "psl_demo - Win32 Release"
|
||||
# Name "psl_demo - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\psl_demo.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
31
examples/src/pui/Makefile.am
Normal file
31
examples/src/pui/Makefile.am
Normal file
@@ -0,0 +1,31 @@
|
||||
if BUILD_PUI
|
||||
|
||||
noinst_PROGRAMS = simple complex widget_list PointPicker widget_test
|
||||
|
||||
simple_SOURCES = simple.cxx
|
||||
|
||||
complex_SOURCES = complex.cxx
|
||||
|
||||
widget_test_SOURCES = widget_test.cxx
|
||||
|
||||
widget_list_SOURCES = widget_list.cxx
|
||||
|
||||
PointPicker_SOURCES = PointPicker.cxx
|
||||
|
||||
simple_LDADD = -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
complex_LDADD = -lplibpuaux -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
widget_test_LDADD = -lplibpuaux -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) \
|
||||
$(OGL_LIBS)
|
||||
|
||||
widget_list_LDADD = -lplibpuaux -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) \
|
||||
$(OGL_LIBS)
|
||||
|
||||
PointPicker_LDADD = -lplibpuaux -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) \
|
||||
$(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = complex.dsp simple.dsp PointPicker.dsp widget_list.dsp widget_test.dsp
|
||||
|
||||
446
examples/src/pui/PointPicker.cxx
Normal file
446
examples/src/pui/PointPicker.cxx
Normal file
@@ -0,0 +1,446 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: PointPicker.cxx 2143 2009-01-21 17:18:45Z fayjf $
|
||||
*/
|
||||
|
||||
// Point Picker Program by John Fay, October 2000.
|
||||
// This is a demonstration program for PUI. It displays a set of points in
|
||||
// a window and allows the user to pick them with the right mouse button.
|
||||
// It demonstrates the following PUI capabilities:
|
||||
// - puInput widget
|
||||
// - puOneShot widget
|
||||
// - active widget functionality, with up, active, and down callbacks
|
||||
// - valuators
|
||||
//
|
||||
// To use it, the user does the following:
|
||||
// First Method: Click in the input widget and type the number of the
|
||||
// point
|
||||
// Second Method: Click in the input widget and right-click on a point to
|
||||
// select it.
|
||||
//
|
||||
// For both methods, clicking the left (one-shot) button moves the point
|
||||
// to the right. When it gets far enough to the right, it wraps around to
|
||||
// the left and moves slightly upwards.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/pu.h>
|
||||
#include <plib/puAux.h>
|
||||
|
||||
//#define VOODOO 1
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* These are the PUI widget pointers *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
static int main_window ;
|
||||
static puText *instruction ;
|
||||
static puInput *point_no ;
|
||||
static puOneShot *move_point ;
|
||||
static puButton *exit_button ;
|
||||
static puaLargeInput *input ;
|
||||
|
||||
static int picked_point ;
|
||||
static int mouse_x, mouse_y ; // Mouse coordinates
|
||||
|
||||
//static fntTexFont *tim ;
|
||||
|
||||
/**********************************\
|
||||
* *
|
||||
* Here are the point coordinates *
|
||||
* *
|
||||
\**********************************/
|
||||
|
||||
typedef struct {
|
||||
float x, y, z ;
|
||||
} node ;
|
||||
|
||||
#define NUMBER_POINTS 30
|
||||
|
||||
static node point[NUMBER_POINTS] ;
|
||||
|
||||
static int firsttime;
|
||||
|
||||
static void drawSinglePickableObject ( int i, float x, float y, float z )
|
||||
{
|
||||
// I realize that putting the point size, normal, and begin/end inside the for-loop
|
||||
// is less efficient, but for the purposes of the demo I want everything required
|
||||
// to draw a single pickable object in this routine.
|
||||
|
||||
glPointSize ( 10.0f ) ;
|
||||
glBegin ( GL_POINTS ) ;
|
||||
glNormal3f ( 1.0f, 0.0f, 0.0f ) ; // Needed so the points show color
|
||||
|
||||
if ( i == picked_point )
|
||||
glColor4f ( 1.0f, 0.0f, 0.0f, 1.0f ) ;
|
||||
else
|
||||
glColor4f ( 0.0f, 1.0f, 0.0f, 1.0f ) ;
|
||||
|
||||
glVertex3f ( x, y, z ) ;
|
||||
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
static void drawPoints (void)
|
||||
{
|
||||
|
||||
if ( firsttime )
|
||||
{
|
||||
/*
|
||||
Deliberately do this only once - it's a better test of
|
||||
PUI's attempts to leave the OpenGL state undisturbed
|
||||
*/
|
||||
glEnable ( GL_BLEND ) ;
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glAlphaFunc(GL_GREATER,0.1f);
|
||||
|
||||
firsttime = FALSE ;
|
||||
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
gluPerspective ( 40.0, 1.0, 1.0, 10.0 ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
gluLookAt ( 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ) ;
|
||||
|
||||
// Assign point coordinates (random values between zero and one)
|
||||
|
||||
for ( int i = 0; i < NUMBER_POINTS; i++ )
|
||||
{
|
||||
point[i].x = ( (float) i / (float)NUMBER_POINTS * 2 ) - 1 ;
|
||||
point[i].y = ( (float)( ( i * i * i ) % NUMBER_POINTS) / (float)NUMBER_POINTS * 2 ) - 1 ;
|
||||
point[i].z = ( (float)( ( i * i ) % NUMBER_POINTS) / (float)NUMBER_POINTS * 2 ) - 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
GLfloat matrix[16] ;
|
||||
glGetFloatv ( GL_MODELVIEW_MATRIX, matrix ) ;
|
||||
glGetFloatv ( GL_PROJECTION_MATRIX, matrix ) ;
|
||||
|
||||
for ( int i = 0 ; i < NUMBER_POINTS ; i++ )
|
||||
{
|
||||
drawSinglePickableObject ( i, point[i].x, point[i].y, point[i].z ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************\
|
||||
* *
|
||||
* These three functions capture mouse *
|
||||
* and keystrokes (special and mundane) *
|
||||
* from GLUT and pass them on to PUI. *
|
||||
* *
|
||||
\**************************************/
|
||||
|
||||
static void specialfn ( int key, int, int )
|
||||
{
|
||||
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void keyfn ( unsigned char key, int, int )
|
||||
{
|
||||
puKeyboard ( key, PU_DOWN ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void motionfn ( int x, int y )
|
||||
{
|
||||
puMouse ( x, y ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static puObject *active_widget = (puObject *)NULL ;
|
||||
static void mousefn ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( updown == PU_UP ) active_widget = puActiveWidget () ;
|
||||
if ( !puMouse ( button, updown, x, y ) )
|
||||
{
|
||||
// PUI didn't take the mouseclick, try the main window
|
||||
|
||||
mouse_x = x ;
|
||||
mouse_y = puGetWindowHeight () - y ;
|
||||
|
||||
// Check for an active widget. If there is one, call its active callback
|
||||
|
||||
if ( active_widget )
|
||||
{
|
||||
active_widget -> invokeActiveCallback () ;
|
||||
// Make sure PUI keeps the active widget active
|
||||
puSetActiveWidget ( active_widget, 0, 0 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
/**************************************\
|
||||
* *
|
||||
* This function redisplays the PUI and *
|
||||
* the points, flips the double buffer *
|
||||
* and then asks GLUT to post a *
|
||||
* redisplay command - so we re-render *
|
||||
* at maximum rate. *
|
||||
* *
|
||||
\**************************************/
|
||||
|
||||
static void displayfn (void)
|
||||
{
|
||||
/* Clear the screen */
|
||||
|
||||
glClearColor ( 0.4f, 0.1f, 0.1f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
/* Draw the points */
|
||||
|
||||
drawPoints () ;
|
||||
|
||||
/* Make PUI redraw */
|
||||
|
||||
puDisplay () ;
|
||||
|
||||
/* Off we go again... */
|
||||
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* Here are the PUI widget callback *
|
||||
* functions. *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
// Point Number Input Widget Up Callback
|
||||
|
||||
static void point_no_up_cb ( puObject *ob )
|
||||
{
|
||||
printf ( "Calling the up-callback with partial data: %d\n", picked_point ) ;
|
||||
if ( input->inputDisabled () )
|
||||
input->enableInput () ;
|
||||
else
|
||||
input->disableInput () ;
|
||||
}
|
||||
|
||||
// Point Number Input Widget Active Callback
|
||||
|
||||
static void point_no_active_cb ( puObject *ob )
|
||||
{
|
||||
GLint viewport[4] ; // Viewport
|
||||
glGetIntegerv ( GL_VIEWPORT, viewport ) ;
|
||||
|
||||
GLuint buffer[512];
|
||||
glSelectBuffer ( 512L, buffer ); // Set up the buffer to put hits into
|
||||
glRenderMode ( GL_SELECT ) ; // Go into Select mode
|
||||
|
||||
glInitNames (); // Empty the name stack
|
||||
|
||||
glMatrixMode ( GL_PROJECTION ) ; // Set the Projection matrix for picking
|
||||
glPushMatrix () ; // Save the current matrix
|
||||
glLoadIdentity();
|
||||
|
||||
// Many thanks to Dave McClurg for getting the transformation matrices to work correctly
|
||||
/* create 10x10 pixel picking region near cursor location */
|
||||
gluPickMatrix ( (double)mouse_x, (double)mouse_y,
|
||||
10.0f, 10.0f, viewport ) ;
|
||||
|
||||
gluPerspective ( 40.0, 1.0, 1.0, 10.0 ) ;
|
||||
|
||||
for ( int i = 0 ; i < NUMBER_POINTS ; i++ )
|
||||
{
|
||||
glPushName ( i ) ;
|
||||
drawSinglePickableObject ( i, point[i].x, point[i].y, point[i].z ) ;
|
||||
glPopName () ;
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glFlush();
|
||||
|
||||
long hits = glRenderMode ( GL_RENDER ) ; // Back to Rendering mode, get number of hits
|
||||
|
||||
if ( hits )
|
||||
point_no->setValue ( (int)buffer[3] ) ;
|
||||
|
||||
printf ( "Active point %d %d %ld\n", mouse_x, mouse_y, hits ) ;
|
||||
|
||||
glMatrixMode ( GL_MODELVIEW ); // got set to GL_PROJECTION earlier
|
||||
}
|
||||
|
||||
// Point Number Input Widget Down Callback
|
||||
|
||||
static void point_no_down_cb ( puObject *ob )
|
||||
{
|
||||
printf ( "Calling the down callback with full data: %d\n", picked_point ) ;
|
||||
if ( picked_point < 0 )
|
||||
{
|
||||
printf ( "Value too small, setting it to zero\n" ) ;
|
||||
picked_point = 0 ;
|
||||
}
|
||||
|
||||
if ( picked_point > NUMBER_POINTS - 1 )
|
||||
{
|
||||
printf ( "Value too big, setting it to %d\n", NUMBER_POINTS - 1 ) ;
|
||||
picked_point = NUMBER_POINTS - 1 ;
|
||||
}
|
||||
|
||||
point_no->setValue ( picked_point ) ;
|
||||
}
|
||||
|
||||
// Move Point Button Callback
|
||||
|
||||
static void move_point_cb ( puObject *ob )
|
||||
{
|
||||
point[picked_point].x += 0.1f ;
|
||||
if ( point[picked_point].x > 1.0 )
|
||||
{
|
||||
point[picked_point].x = -1.0 ;
|
||||
point[picked_point].y += 0.1f ;
|
||||
}
|
||||
}
|
||||
|
||||
static void exit_cb ( puObject * )
|
||||
{
|
||||
fprintf ( stderr, "Exiting PUI demo program.\n" ) ;
|
||||
exit ( 1 ) ;
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
firsttime = TRUE;
|
||||
picked_point = 0 ;
|
||||
|
||||
// Set up the window
|
||||
|
||||
glutInitWindowPosition( 100, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &argc, argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
main_window = glutCreateWindow ( "Point Picker PUI Application" ) ;
|
||||
glutDisplayFunc ( displayfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
glutSpecialFunc ( specialfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
glutIdleFunc ( displayfn ) ;
|
||||
|
||||
puInit () ;
|
||||
|
||||
#ifdef VOODOO
|
||||
puShowCursor () ;
|
||||
#endif
|
||||
|
||||
// Set up the font
|
||||
|
||||
//tim = new fntTexFont ;
|
||||
//tim -> load ( "../fnt/data/old/times_medium.txf" ) ;
|
||||
//puFont times_medium ( tim, 15, 0.3f ) ;
|
||||
//puSetDefaultFonts ( times_medium, times_medium ) ;
|
||||
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
puSetDefaultColourScheme ( 0.1f, 0.8f, 0.1f, 1.0f) ;
|
||||
|
||||
// Set up the widgets in the window
|
||||
|
||||
instruction = new puText ( 10, 450 ) ;
|
||||
instruction -> setColour ( PUCOL_LABEL, 1.0, 1.0, 1.0 ) ;
|
||||
instruction -> setLabel ( "Enter a point number in the input box, or\n"
|
||||
"left-click in the input box and right-click on a point." ) ;
|
||||
|
||||
point_no = new puInput ( 150, 60, 240, 80 ) ;
|
||||
point_no->setValuator ( &picked_point ) ;
|
||||
point_no->setLabel ( "Point Number" ) ;
|
||||
point_no->setLabelPlace ( PUPLACE_LEFT_CENTER ) ;
|
||||
point_no->setCallback ( point_no_up_cb ) ;
|
||||
point_no->setActiveCallback ( point_no_active_cb ) ;
|
||||
point_no->setDownCallback ( point_no_down_cb ) ;
|
||||
|
||||
move_point = new puOneShot ( 10, 10, 250, 50 ) ;
|
||||
move_point->setLegend ( "Move Selected Point" ) ;
|
||||
move_point->setCallback ( move_point_cb ) ;
|
||||
move_point->makeReturnDefault ( TRUE ) ;
|
||||
|
||||
exit_button = new puButton ( 260, 10, 360, 50 ) ;
|
||||
exit_button->setLegend ( "Exit" ) ;
|
||||
exit_button->setCallback ( exit_cb ) ;
|
||||
exit_button->setStyle ( PUSTYLE_BOXED ) ;
|
||||
exit_button->setLegendPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
|
||||
input = new puaLargeInput ( 440, 0, 200, 300, 1, 20, TRUE ) ;
|
||||
//input->setChildStyle ( PUCLASS_ARROW, PUSTYLE_BOXED ) ;
|
||||
//input->setChildBorderThickness ( PUCLASS_ARROW, 15 ) ;
|
||||
input->setValue( "This is a large input box\n"
|
||||
"This is line two of a large input box\n"
|
||||
"Line 3\n"
|
||||
"Line 4\n"
|
||||
"This is an extremely long line in the large input box, so long it passes the box width\n"
|
||||
"Line 6\n"
|
||||
"Line 7\n"
|
||||
"Line 8\n"
|
||||
"Line 9\n"
|
||||
"Line 10\n"
|
||||
"Line 11\n"
|
||||
"Line 12\n"
|
||||
"Line 13\n"
|
||||
"Line 14\n"
|
||||
"Line 15\n"
|
||||
"Line 16\n"
|
||||
"Line 17\n"
|
||||
"Line 18\n"
|
||||
"Line 19\n"
|
||||
"Line 20\n"
|
||||
"Line 21\n"
|
||||
"Line 22\n"
|
||||
"Line 23\n"
|
||||
"Line 24\n"
|
||||
"Line 25\n"
|
||||
"Line 26\n"
|
||||
"Line 27\n"
|
||||
"Line 28\n"
|
||||
"Line 29\n"
|
||||
"Line 30\n" ) ;
|
||||
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
88
examples/src/pui/PointPicker.dsp
Normal file
88
examples/src/pui/PointPicker.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="PointPicker" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=PointPicker - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PointPicker.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PointPicker.mak" CFG="PointPicker - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PointPicker - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "PointPicker - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PointPicker - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui.lib puAux.lib fnt.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"PointPicker.exe" /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PointPicker - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui_d.lib puAux_d.lib fnt_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"PointPicker.exe" /pdbtype:sept /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PointPicker - Win32 Release"
|
||||
# Name "PointPicker - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PointPicker.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
636
examples/src/pui/complex.cxx
Normal file
636
examples/src/pui/complex.cxx
Normal file
@@ -0,0 +1,636 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: complex.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/pu.h>
|
||||
#include <plib/puAux.h>
|
||||
|
||||
//#define VOODOO 1
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* These are the PUI widget pointers *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
static int main_window ;
|
||||
static puMenuBar *main_menu_bar ;
|
||||
static puButton *hide_menu_button ;
|
||||
static puDialogBox *dialog_box ;
|
||||
static puText *dialog_box_message ;
|
||||
static puOneShot *dialog_box_ok_button ;
|
||||
static puText *timer_text ;
|
||||
static puGroup *mygroup ;
|
||||
static puInput *input1 ;
|
||||
static puInput *input2 ;
|
||||
|
||||
static int slider_window ;
|
||||
static puSlider *rspeedSlider ;
|
||||
static puSlider *directSlider ;
|
||||
|
||||
static int save_window ;
|
||||
static puaFileSelector *file_selector ;
|
||||
|
||||
static int coordinate_window ;
|
||||
static puaBiSlider *x_coordinate ;
|
||||
static puaTriSlider *y_coordinate ;
|
||||
|
||||
//static fntTexFont *hel ;
|
||||
//static fntTexFont *tim ;
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* This is a generic tumbling cube *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
static const GLfloat light_diffuse [] = {0.0, 1.0, 0.0, 1.0} ; /* Red diffuse light. */
|
||||
static const GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0} ; /* Infinite light location. */
|
||||
|
||||
static const GLfloat cube_n[6][3] = /* Normals */
|
||||
{
|
||||
{-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},
|
||||
{ 0.0,-1.0, 0.0}, {0.0, 0.0,-1.0}, {0.0, 0.0, 1.0}
|
||||
} ;
|
||||
|
||||
static const GLint cube_i[6][4] = /* Vertex indices */
|
||||
{
|
||||
{0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4},
|
||||
{4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3}
|
||||
} ;
|
||||
|
||||
static const GLfloat cube_v[8][3] = /* Vertices */
|
||||
{
|
||||
{-1.0,-1.0, 1.0}, {-1.0,-1.0,-1.0}, {-1.0, 1.0,-1.0}, {-1.0, 1.0, 1.0},
|
||||
{ 1.0,-1.0, 1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, { 1.0, 1.0, 1.0}
|
||||
} ;
|
||||
|
||||
|
||||
static int firsttime;
|
||||
|
||||
static void drawCube (void)
|
||||
{
|
||||
|
||||
if ( firsttime )
|
||||
{
|
||||
/*
|
||||
Deliberately do this only once - it's a better test of
|
||||
PUI's attempts to leave the OpenGL state undisturbed
|
||||
*/
|
||||
glEnable ( GL_BLEND ) ;
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glAlphaFunc(GL_GREATER,0.1f);
|
||||
|
||||
firsttime = FALSE ;
|
||||
glLightfv ( GL_LIGHT0, GL_DIFFUSE , light_diffuse ) ;
|
||||
glLightfv ( GL_LIGHT0, GL_POSITION, light_position ) ;
|
||||
glEnable ( GL_LIGHT0 ) ;
|
||||
glEnable ( GL_LIGHTING ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
gluPerspective ( 40.0, 1.0, 1.0, 10.0 ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
gluLookAt ( 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ) ;
|
||||
glTranslatef ( 0.0, 0.0, -1.0 ) ;
|
||||
glRotatef ( 60.0, 1.0, 0.0, 0.0 ) ;
|
||||
}
|
||||
|
||||
glCullFace ( GL_FRONT ) ;
|
||||
glEnable ( GL_CULL_FACE ) ;
|
||||
// glRotatef ( 1.0f, 0.0, 0.0, 1.0 ) ; /* Tumble that cube! */
|
||||
|
||||
glBegin ( GL_QUADS ) ;
|
||||
|
||||
for ( int i = 0 ; i < 6 ; i++ )
|
||||
{
|
||||
glNormal3fv ( &cube_n[i][0] ) ;
|
||||
for ( int j = 0; j < 4; j++ )
|
||||
{
|
||||
float xmult =(float)(x_coordinate->getCurrentMax () - x_coordinate->getCurrentMin ()) /
|
||||
(float)(x_coordinate->getMaxValue () - x_coordinate->getMinValue ()) ;
|
||||
float ymult =(float)(y_coordinate->getCurrentMax () - y_coordinate->getCurrentMin ()) /
|
||||
(float)(y_coordinate->getMaxValue () - y_coordinate->getMinValue ()) ;
|
||||
|
||||
float x = cube_v[cube_i[i][j]][0] * xmult ;
|
||||
float y = cube_v[cube_i[i][j]][1] * ymult ;
|
||||
float z = cube_v[cube_i[i][j]][2] ;
|
||||
glVertex3f ( x, y, z ) ;
|
||||
}
|
||||
}
|
||||
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
/********************************\
|
||||
* *
|
||||
* End of cube renderer in OpenGL *
|
||||
* *
|
||||
\********************************/
|
||||
|
||||
|
||||
/**************************************\
|
||||
* *
|
||||
* These three functions capture mouse *
|
||||
* and keystrokes (special and mundane) *
|
||||
* from GLUT and pass them on to PUI. *
|
||||
* *
|
||||
\**************************************/
|
||||
|
||||
static void specialfn ( int key, int, int )
|
||||
{
|
||||
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void keyfn ( unsigned char key, int, int )
|
||||
{
|
||||
puKeyboard ( key, PU_DOWN ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void motionfn ( int x, int y )
|
||||
{
|
||||
puMouse ( x, y ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void mousefn ( int button, int updown, int x, int y )
|
||||
{
|
||||
puMouse ( button, updown, x, y ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
/**************************************\
|
||||
* *
|
||||
* This function redisplays the PUI and *
|
||||
* the tumbling cube, flips the double *
|
||||
* buffer and then asks GLUT to post a *
|
||||
* redisplay command - so we re-render *
|
||||
* at maximum rate. *
|
||||
* *
|
||||
\**************************************/
|
||||
|
||||
static void displayfn (void)
|
||||
{
|
||||
/* Clear the screen */
|
||||
|
||||
glClearColor ( 0.1f, 0.3f, 0.5f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
/* Draw the tumbling cube */
|
||||
|
||||
float val ; rspeedSlider->getValue ( &val ) ;
|
||||
float dir ; directSlider->getValue ( &dir ) ;
|
||||
|
||||
glRotatef( 4*val, 3.0f * ( 2.0f * dir - 1.0f ) , 2.0f * ( 1.0f - 2.0f * dir ) , 1.0f );
|
||||
|
||||
drawCube () ;
|
||||
|
||||
/* Update the 'timer' */
|
||||
|
||||
time_t t = time ( NULL ) ;
|
||||
timer_text -> setLabel ( ctime ( & t ) ) ;
|
||||
|
||||
/* Make PUI redraw */
|
||||
|
||||
puDisplay () ;
|
||||
|
||||
/* Off we go again... */
|
||||
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
static void sliderdisplayfn (void)
|
||||
{
|
||||
/*
|
||||
Function to display only the slider window
|
||||
We must set the glut window first or we get an annoying flicker in the main window.
|
||||
*/
|
||||
|
||||
glutSetWindow ( slider_window ) ;
|
||||
|
||||
/* Clear the screen */
|
||||
|
||||
glClearColor ( 0.1f, 0.3f, 0.5f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
/* Make PUI redraw the slider window */
|
||||
|
||||
puDisplay ( slider_window ) ;
|
||||
|
||||
/* Off we go again... */
|
||||
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
|
||||
static void savedisplayfn (void)
|
||||
{
|
||||
/*
|
||||
Function to display only the save window
|
||||
We must set the glut window first or we get an annoying flicker in the main window.
|
||||
*/
|
||||
|
||||
glutSetWindow ( save_window ) ;
|
||||
|
||||
/* Clear the screen */
|
||||
|
||||
glClearColor ( 0.1f, 0.1f, 5.0f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
/* Make PUI redraw the save window */
|
||||
|
||||
puDisplay ( save_window ) ;
|
||||
|
||||
/* Off we go again... */
|
||||
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
|
||||
static void coorddisplayfn (void)
|
||||
{
|
||||
/*
|
||||
Function to display only the slider window
|
||||
We must set the glut window first or we get an annoying flicker in the main window.
|
||||
*/
|
||||
|
||||
glutSetWindow ( coordinate_window ) ;
|
||||
|
||||
/* Clear the screen */
|
||||
|
||||
glClearColor ( 0.1f, 0.3f, 0.5f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
/* Make PUI redraw the slider window */
|
||||
|
||||
puDisplay ( coordinate_window ) ;
|
||||
|
||||
/* Off we go again... */
|
||||
|
||||
glutSwapBuffers () ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
|
||||
/***********************************\
|
||||
* *
|
||||
* Here are the PUI widget callback *
|
||||
* functions. *
|
||||
* *
|
||||
\***********************************/
|
||||
|
||||
static void hide_menu_cb ( puObject *cb )
|
||||
{
|
||||
if ( cb -> getValue () )
|
||||
{
|
||||
main_menu_bar -> reveal () ;
|
||||
hide_menu_button->setLegend ( "Hide Menu" ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
main_menu_bar -> hide () ;
|
||||
hide_menu_button->setLegend ( "Show Menu" ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void go_away_cb ( puObject * )
|
||||
{
|
||||
// Delete the dialog box when its 'OK' button is pressed.
|
||||
|
||||
puDeleteObject( dialog_box ) ;
|
||||
dialog_box = NULL ;
|
||||
}
|
||||
|
||||
static void mk_dialog ( char *fmt, ... )
|
||||
{
|
||||
static char txt [ PUSTRING_MAX ] ;
|
||||
|
||||
va_list argptr ;
|
||||
va_start(argptr, fmt) ;
|
||||
vsprintf( txt, fmt, argptr ) ;
|
||||
va_end(argptr) ;
|
||||
|
||||
dialog_box = new puDialogBox ( 150, 50 ) ;
|
||||
{
|
||||
new puFrame ( 0, 0, 400, 100 ) ;
|
||||
dialog_box_message = new puText ( 10, 70 ) ;
|
||||
dialog_box_message -> setLabel ( txt ) ;
|
||||
dialog_box_ok_button = new puOneShot ( 180, 10, 240, 50 ) ;
|
||||
dialog_box_ok_button -> setLegend ( "OK" ) ;
|
||||
dialog_box_ok_button -> makeReturnDefault ( TRUE ) ;
|
||||
dialog_box_ok_button -> setCallback ( go_away_cb ) ;
|
||||
}
|
||||
dialog_box -> close () ;
|
||||
dialog_box -> reveal () ;
|
||||
}
|
||||
|
||||
static void pick_cb ( puObject * )
|
||||
{
|
||||
char* filename ;
|
||||
file_selector -> getValue ( &filename ) ;
|
||||
|
||||
//NOTE: interface creation/deletion must be nested
|
||||
//the old interface must be deleted *before* a new one is created
|
||||
//otherwise the interface stack will be messed up
|
||||
puDeleteObject ( file_selector ) ;
|
||||
file_selector = 0 ;
|
||||
glutHideWindow () ;
|
||||
glutSetWindow ( main_window ) ;
|
||||
|
||||
if ( filename[0] != 0 )
|
||||
mk_dialog ( "Saving File:\n%s", filename ) ;
|
||||
else
|
||||
mk_dialog ( "Save canceled" ) ;
|
||||
}
|
||||
|
||||
static void savereshapefn ( int w, int h )
|
||||
{
|
||||
if ( file_selector )
|
||||
file_selector->setSize ( w, h ) ;
|
||||
}
|
||||
|
||||
static void coordreshapefn ( int w, int h )
|
||||
{
|
||||
x_coordinate->setSize ( 20, h-40 ) ;
|
||||
y_coordinate->setSize ( 20, h-40 ) ;
|
||||
y_coordinate->setPosition ( w/2 - 5, 30 ) ;
|
||||
}
|
||||
|
||||
static void save_cb ( puObject * )
|
||||
{
|
||||
static int save_count = 0 ; // Number of buttons in file picker
|
||||
int w = 320, h = 270 ;
|
||||
glutSetWindow ( save_window ) ;
|
||||
glutShowWindow () ;
|
||||
glutReshapeWindow ( w, h ) ;
|
||||
glutPositionWindow ( ( 640 - w ) / 2, ( 480 - h ) / 2 ) ;
|
||||
if ( ++save_count > 2 ) save_count = 0 ;
|
||||
|
||||
file_selector = new puaFileSelector ( 0, 0, w, h, save_count, ".", "Pick Place To Save" ) ;
|
||||
file_selector -> setCallback ( pick_cb ) ;
|
||||
file_selector->setChildStyle ( PUCLASS_ONESHOT, PUSTYLE_BOXED ) ;
|
||||
file_selector->setChildBorderThickness ( PUCLASS_ONESHOT, 5 ) ;
|
||||
file_selector->setChildColour ( PUCLASS_SLIDER, 0, 0.5, 0.5, 0.5 ) ;
|
||||
}
|
||||
|
||||
static void ni_cb ( puObject * )
|
||||
{
|
||||
mk_dialog ( "Warning:\nSorry, that function isn't implemented" ) ;
|
||||
}
|
||||
|
||||
static void about_cb ( puObject * )
|
||||
{
|
||||
mk_dialog ( "About:\nThis is the PUI 'complex' program" ) ;
|
||||
}
|
||||
|
||||
static void help_cb ( puObject * )
|
||||
{
|
||||
mk_dialog ( "Help:\nSorry, no help is available for this demo" ) ;
|
||||
}
|
||||
|
||||
static void edit_cb ( puObject * )
|
||||
{
|
||||
}
|
||||
|
||||
static void exit_cb ( puObject * )
|
||||
{
|
||||
fprintf ( stderr, "Exiting PUI demo program.\n" ) ;
|
||||
exit ( 1 ) ;
|
||||
}
|
||||
|
||||
/* Menu bar entries: */
|
||||
|
||||
static char *file_submenu [] = { "Exit", "Close", "------------", "Print - this is a long entry", "------------", "Save", "New", NULL } ;
|
||||
static puCallback file_submenu_cb [] = { exit_cb, exit_cb, NULL, ni_cb, NULL, save_cb, ni_cb, NULL } ;
|
||||
|
||||
static char *edit_submenu [] = { "Do nothing", NULL } ;
|
||||
static puCallback edit_submenu_cb [] = { edit_cb, NULL } ;
|
||||
|
||||
static char *help_submenu [] = { "About...", "Help", NULL } ;
|
||||
static puCallback help_submenu_cb [] = { about_cb, help_cb, NULL } ;
|
||||
|
||||
|
||||
static void sliderCB( puObject *)
|
||||
{
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void coordCB( puObject *)
|
||||
{
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
firsttime = TRUE;
|
||||
|
||||
glutInitWindowPosition( 100, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &argc, argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
main_window = glutCreateWindow ( "Complex PUI Application" ) ;
|
||||
glutDisplayFunc ( displayfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
glutSpecialFunc ( specialfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
|
||||
#ifdef VOODOO
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
#endif
|
||||
|
||||
glutIdleFunc ( displayfn ) ;
|
||||
|
||||
puInit () ;
|
||||
|
||||
#ifdef VOODOO
|
||||
puShowCursor () ;
|
||||
#endif
|
||||
|
||||
//hel = new fntTexFont ;
|
||||
//tim = new fntTexFont ;
|
||||
//hel -> load ( "../fnt/data/old/helvetica_medium.txf" ) ;
|
||||
//tim -> load ( "../fnt/data/old/times_medium.txf" ) ;
|
||||
//puFont helvetica ( hel, 15 ) ;
|
||||
//puFont times_medium ( tim, 13 ) ;
|
||||
//puSetDefaultFonts ( helvetica, times_medium ) ;
|
||||
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
puSetDefaultColourScheme ( 0.3f, 0.4f, 0.6f, 1.0f) ;
|
||||
|
||||
timer_text = new puText ( 300, 10 ) ;
|
||||
timer_text -> setColour ( PUCOL_LABEL, 1.0, 1.0, 1.0 ) ;
|
||||
|
||||
/* Make a button to hide the menu bar */
|
||||
|
||||
hide_menu_button = new puButton ( 10, 10, 150, 50 ) ;
|
||||
hide_menu_button->setValue ( TRUE ) ;
|
||||
hide_menu_button->setLegend ( "Hide the Menu" ) ;
|
||||
hide_menu_button->setCallback ( hide_menu_cb ) ;
|
||||
// hide_menu_button->setLegendPlace ( PUPLACE_CENTER ) ;
|
||||
hide_menu_button->makeReturnDefault ( TRUE ) ;
|
||||
|
||||
/* Make the menu bar */
|
||||
|
||||
main_menu_bar = new puMenuBar () ;
|
||||
{
|
||||
main_menu_bar -> add_submenu ( "File", file_submenu, file_submenu_cb ) ;
|
||||
main_menu_bar -> add_submenu ( "Edit", edit_submenu, edit_submenu_cb ) ;
|
||||
main_menu_bar -> add_submenu ( "Help", help_submenu, help_submenu_cb ) ;
|
||||
}
|
||||
main_menu_bar -> close () ;
|
||||
|
||||
mygroup = new puGroup ( 40, 40 ) ;
|
||||
input1 = new puInput ( 10, 70, 90, 90 ) ;
|
||||
input2 = new puInput ( 10, 40, 90, 60 ) ;
|
||||
mygroup->close () ;
|
||||
|
||||
slider_window = glutCreateWindow ( "Slider Window" ) ;
|
||||
glutPositionWindow ( 20, 100 ) ;
|
||||
glutReshapeWindow ( 150, 200 ) ;
|
||||
glutDisplayFunc ( sliderdisplayfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
glutSpecialFunc ( specialfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
glutIdleFunc ( sliderdisplayfn ) ;
|
||||
|
||||
//load the texture for the 2nd window
|
||||
//hel -> load ( "../fnt/data/old/helvetica_medium.txf" ) ;
|
||||
//tim -> load ( "../fnt/data/old/times_medium.txf" ) ;
|
||||
|
||||
puGroup *slider_group = new puGroup ( 0, 0 ) ; // Necessary so that "sliderdisplayfn" will draw all widgets
|
||||
|
||||
rspeedSlider = new puSlider (10,30,150,TRUE);
|
||||
rspeedSlider->setDelta(0.1f);
|
||||
rspeedSlider->setCBMode( PUSLIDER_DELTA );
|
||||
rspeedSlider->setCallback(sliderCB);
|
||||
rspeedSlider->setLabel ( "Speed" ) ;
|
||||
rspeedSlider->setLabelPlace ( PUPLACE_BOTTOM_LEFT ) ;
|
||||
rspeedSlider->setValue ( 0.8f ) ;
|
||||
|
||||
directSlider = new puSlider (80,30,150,TRUE);
|
||||
directSlider->setDelta(0.1f);
|
||||
directSlider->setCBMode( PUSLIDER_DELTA );
|
||||
directSlider->setCallback(sliderCB);
|
||||
directSlider->setLabel ( "Direction" ) ;
|
||||
directSlider->setLabelPlace ( PUPLACE_BOTTOM_LEFT ) ;
|
||||
|
||||
slider_group -> close () ;
|
||||
|
||||
save_window = glutCreateWindow ( "Saving" ) ;
|
||||
glutDisplayFunc ( savedisplayfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
glutSpecialFunc ( specialfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
glutIdleFunc ( savedisplayfn ) ;
|
||||
glutReshapeFunc ( savereshapefn ) ;
|
||||
glutHideWindow () ;
|
||||
|
||||
//load the texture for the save window
|
||||
//hel -> load ( "../fnt/data/old/helvetica_medium.txf" ) ;
|
||||
//tim -> load ( "../fnt/data/old/times_medium.txf" ) ;
|
||||
|
||||
// Coordinate Selection Window
|
||||
|
||||
coordinate_window = glutCreateWindow ( "Coordinate Window" ) ;
|
||||
glutPositionWindow ( 420, 100 ) ;
|
||||
glutReshapeWindow ( 250, 400 ) ;
|
||||
glutDisplayFunc ( coorddisplayfn ) ;
|
||||
glutKeyboardFunc ( keyfn ) ;
|
||||
glutSpecialFunc ( specialfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
glutIdleFunc ( coorddisplayfn ) ;
|
||||
glutReshapeFunc ( coordreshapefn ) ;
|
||||
|
||||
//load the texture for the 2nd window
|
||||
//hel -> load ( "../fnt/data/old/helvetica_medium.txf" ) ;
|
||||
//tim -> load ( "../fnt/data/old/times_medium.txf" ) ;
|
||||
|
||||
puGroup *coordinate_group = new puGroup ( 0, 0 ) ; // Necessary so that "groupdisplayfn" will draw all widgets
|
||||
|
||||
x_coordinate = new puaBiSlider ( 50,10,350,TRUE ) ;
|
||||
x_coordinate->setMinValue ( -20 ) ;
|
||||
x_coordinate->setMaxValue ( 20 ) ;
|
||||
x_coordinate->setCurrentMin ( -20 ) ;
|
||||
x_coordinate->setCurrentMax ( 20 ) ;
|
||||
// x_coordinate->setDelta(0.1);
|
||||
// x_coordinate->setCBMode( PUSLIDER_DELTA );
|
||||
x_coordinate->setCallback(coordCB);
|
||||
x_coordinate->setLabel ( "X-coords" ) ;
|
||||
x_coordinate->setLabelPlace ( PUPLACE_TOP_CENTERED ) ;
|
||||
|
||||
y_coordinate = new puaTriSlider (200,30,350,TRUE);
|
||||
y_coordinate->setMinValue ( -20 ) ;
|
||||
y_coordinate->setMaxValue ( 20 ) ;
|
||||
y_coordinate->setCurrentMin ( -20 ) ;
|
||||
y_coordinate->setCurrentMax ( 20 ) ;
|
||||
y_coordinate->setFreezeEnds ( FALSE ) ;
|
||||
y_coordinate->setValue ( 0 ) ;
|
||||
// y_coordinate->setDelta(0.1);
|
||||
// y_coordinate->setCBMode( PUSLIDER_DELTA );
|
||||
y_coordinate->setCallback(coordCB);
|
||||
y_coordinate->setLabel ( "Y-coords" ) ;
|
||||
y_coordinate->setLabelPlace ( PUPLACE_BOTTOM_CENTERED ) ;
|
||||
|
||||
coordinate_group -> close () ;
|
||||
|
||||
// hel -> load ( "../fnt/data/old/helvetica_medium.txf" ) ;
|
||||
// tim -> load ( "../fnt/data/old/times_medium.txf" ) ;
|
||||
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
88
examples/src/pui/complex.dsp
Normal file
88
examples/src/pui/complex.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="complex" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=complex - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "complex.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "complex.mak" CFG="complex - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "complex - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "complex - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "complex - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui.lib puAux.lib fnt.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"complex.exe" /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "complex - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui_d.lib puAux_d.lib fnt_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"complex.exe" /pdbtype:sept /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "complex - Win32 Release"
|
||||
# Name "complex - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\complex.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
25
examples/src/pui/fltk_demo/Makefile
Normal file
25
examples/src/pui/fltk_demo/Makefile
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*-Makefile-*- $Id: Makefile 1877 2004-02-25 11:01:31Z stromberg $
|
||||
|
||||
|
||||
CXXFLAGS = $(shell fltk-config --use-gl --cxxflags) -Wall -O2 -DPU_USE_FLTK
|
||||
LDFLAGS = $(shell fltk-config --use-gl --ldflags) -lplibpu -lplibfnt -lplibul
|
||||
|
||||
OBJS = main.o gui.o puf.o
|
||||
|
||||
|
||||
fltk_demo: $(OBJS)
|
||||
g++ $(OBJS) $(LDFLAGS) -o $@
|
||||
|
||||
clean:
|
||||
rm -f gui.{h,cxx} *.o *~
|
||||
|
||||
|
||||
%.o: %.cxx
|
||||
g++ $(CXXFLAGS) -c $<
|
||||
|
||||
%.h %.cxx: %.fl
|
||||
fluid -c $<
|
||||
|
||||
|
||||
main.o gui.o: gui.h puf.h
|
||||
puf.o: puf.h
|
||||
48
examples/src/pui/fltk_demo/gui.fl
Normal file
48
examples/src/pui/fltk_demo/gui.fl
Normal file
@@ -0,0 +1,48 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0104
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
Function {make_window()} {open
|
||||
} {
|
||||
Fl_Window main_window {
|
||||
label {fluid window} open
|
||||
xywh {544 347 265 285} type Double hide
|
||||
} {
|
||||
Fl_Box gl_area {selected
|
||||
xywh {15 50 235 180} labelsize 12 align 1
|
||||
code0 {\#include "puf.h"}
|
||||
class Puf_Window
|
||||
}
|
||||
Fl_Menu_Bar {} {open
|
||||
xywh {0 0 265 20} labelsize 12 textsize 12
|
||||
} {
|
||||
submenu {} {
|
||||
label File open
|
||||
xywh {0 0 100 20} labelsize 12
|
||||
} {
|
||||
menuitem {} {
|
||||
label Quit
|
||||
callback {exit(0);}
|
||||
xywh {0 0 100 20} labelsize 12
|
||||
code0 {\#include <stdlib.h>}
|
||||
}
|
||||
}
|
||||
submenu {} {
|
||||
label Edit open
|
||||
xywh {0 0 100 20} labelsize 12
|
||||
} {}
|
||||
submenu {} {
|
||||
label View open
|
||||
xywh {15 15 100 20} labelsize 12
|
||||
} {}
|
||||
}
|
||||
Fl_Box {} {
|
||||
label {OpenGL Area}
|
||||
xywh {15 30 235 20} labelfont 1 labelsize 12
|
||||
}
|
||||
Fl_Button toggle_other {
|
||||
label {Show / Hide}
|
||||
xywh {70 250 120 25} labelsize 12
|
||||
}
|
||||
}
|
||||
}
|
||||
143
examples/src/pui/fltk_demo/main.cxx
Normal file
143
examples/src/pui/fltk_demo/main.cxx
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: main.cxx 1877 2004-02-25 11:01:31Z stromberg $
|
||||
*/
|
||||
|
||||
|
||||
#include "puf.h"
|
||||
#include "gui.h"
|
||||
#include <plib/pu.h>
|
||||
|
||||
|
||||
static Puf_Window *window1;
|
||||
static Puf_Window *window2;
|
||||
|
||||
static puButton *button1;
|
||||
static puButton *button2;
|
||||
|
||||
static puInput *input1;
|
||||
static puInput *input2;
|
||||
|
||||
|
||||
static void hello_cb(puObject *o)
|
||||
{
|
||||
puInput *i = (o == button1 ? input1 : input2);
|
||||
char *s = 0;
|
||||
i->getValue(&s);
|
||||
fprintf(stderr, "[Window %d] Hello: %s\n", o == button1 ? 1 : 2, s);
|
||||
}
|
||||
|
||||
|
||||
static void toggle_cb(puObject *o)
|
||||
{
|
||||
if (main_window->visible())
|
||||
main_window->hide();
|
||||
else
|
||||
main_window->show();
|
||||
}
|
||||
|
||||
|
||||
static void quit_cb(puObject *o)
|
||||
{
|
||||
main_window->hide();
|
||||
window1->hide();
|
||||
}
|
||||
|
||||
|
||||
static void init_pui()
|
||||
{
|
||||
window1->make_current();
|
||||
|
||||
puInit();
|
||||
|
||||
new puGroup(0, 0);
|
||||
puButton *b = new puOneShot(50, 50, 200, 80);
|
||||
b->setLegend("Show / Hide");
|
||||
b->setCallback(toggle_cb);
|
||||
button1 = new puOneShot(50, 120, 200, 150);
|
||||
button1->setLegend("Say Hello");
|
||||
button1->setCallback(hello_cb);
|
||||
input1 = new puInput(50, 170, 200, 200);
|
||||
puMenuBar *menu = new puMenuBar();
|
||||
char *menu_text[] = { "Quit", "----", "----", NULL };
|
||||
puCallback menu_cb[] = { quit_cb, NULL, NULL };
|
||||
char *dummy_text[] = { "----", NULL };
|
||||
puCallback dummy_cb[] = { NULL };
|
||||
menu->add_submenu("File", menu_text, menu_cb);
|
||||
menu->add_submenu("Edit", dummy_text, dummy_cb);
|
||||
menu->add_submenu("View", dummy_text, dummy_cb);
|
||||
menu->close();
|
||||
puPopGroup();
|
||||
|
||||
window2->make_current();
|
||||
|
||||
new puInterface(0, 0);
|
||||
new puGroup(0, 0);
|
||||
button2 = new puOneShot(50, 50, 200, 80);
|
||||
button2->setLegend("Say Hello");
|
||||
button2->setCallback(hello_cb);
|
||||
input2 = new puInput(50, 100, 200, 130);
|
||||
puPopGroup();
|
||||
}
|
||||
|
||||
|
||||
static void toggle_fl(Fl_Widget *widget, void *data)
|
||||
{
|
||||
if (window1->visible())
|
||||
window1->hide();
|
||||
else
|
||||
window1->show();
|
||||
}
|
||||
|
||||
|
||||
// This is for debugging, to see that redraw occurs when it should.
|
||||
static void refresh(void *data)
|
||||
{
|
||||
window1->redraw();
|
||||
window2->redraw();
|
||||
Fl::repeat_timeout(2.0, refresh);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
window1 = new Puf_Window(250, 270, "OpenGL Window");
|
||||
window1->show();
|
||||
|
||||
make_window()->show();
|
||||
window2 = gl_area;
|
||||
|
||||
init_pui();
|
||||
|
||||
toggle_other->callback(toggle_fl);
|
||||
Fl::add_timeout(3.0, refresh);
|
||||
|
||||
return Fl::run();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
mode: C++
|
||||
c-basic-offset: 4
|
||||
c-file-offsets: ((substatement-open 0) (case-label 0))
|
||||
End:
|
||||
*/
|
||||
186
examples/src/pui/fltk_demo/puf.cxx
Normal file
186
examples/src/pui/fltk_demo/puf.cxx
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: puf.cxx 1877 2004-02-25 11:01:31Z stromberg $
|
||||
*/
|
||||
|
||||
|
||||
#include "puf.h"
|
||||
#include <FL/Fl.H>
|
||||
#include <plib/pu.h>
|
||||
|
||||
|
||||
int puf_translate_key(int key)
|
||||
{
|
||||
const short xtab[][2] = {
|
||||
{ FL_BackSpace, '\b' },
|
||||
{ FL_Tab, '\t' },
|
||||
{ FL_Enter, '\r' },
|
||||
{ FL_Escape, 0x1b },
|
||||
{ FL_Home, PU_KEY_HOME },
|
||||
{ FL_Left, PU_KEY_LEFT },
|
||||
{ FL_Up, PU_KEY_UP },
|
||||
{ FL_Right, PU_KEY_RIGHT },
|
||||
{ FL_Down, PU_KEY_DOWN },
|
||||
{ FL_Page_Up, PU_KEY_PAGE_UP },
|
||||
{ FL_Page_Down, PU_KEY_PAGE_DOWN },
|
||||
{ FL_End, PU_KEY_END },
|
||||
{ FL_Insert, PU_KEY_INSERT },
|
||||
{ FL_KP + 0, '0' },
|
||||
{ FL_KP + 1, '1' },
|
||||
{ FL_KP + 2, '2' },
|
||||
{ FL_KP + 3, '3' },
|
||||
{ FL_KP + 4, '4' },
|
||||
{ FL_KP + 5, '5' },
|
||||
{ FL_KP + 6, '6' },
|
||||
{ FL_KP + 7, '7' },
|
||||
{ FL_KP + 8, '8' },
|
||||
{ FL_KP + 9, '9' },
|
||||
{ FL_KP_Enter, '\r' },
|
||||
{ FL_F + 1, PU_KEY_F1 },
|
||||
{ FL_F + 2, PU_KEY_F2 },
|
||||
{ FL_F + 3, PU_KEY_F3 },
|
||||
{ FL_F + 4, PU_KEY_F4 },
|
||||
{ FL_F + 5, PU_KEY_F5 },
|
||||
{ FL_F + 6, PU_KEY_F6 },
|
||||
{ FL_F + 7, PU_KEY_F7 },
|
||||
{ FL_F + 8, PU_KEY_F8 },
|
||||
{ FL_F + 9, PU_KEY_F9 },
|
||||
{ FL_F + 10, PU_KEY_F10 },
|
||||
{ FL_F + 11, PU_KEY_F11 },
|
||||
{ FL_F + 12, PU_KEY_F12 },
|
||||
{ FL_Delete, 0x7f },
|
||||
};
|
||||
|
||||
static short xmap[256] = { 0 };
|
||||
|
||||
if (xmap[ FL_BackSpace & 0xff ] == 0) {
|
||||
for (unsigned i = 0; i < sizeof(xtab) / sizeof(xtab[0]); i++)
|
||||
xmap[ xtab[i][0] & 0xff ] = xtab[i][1];
|
||||
}
|
||||
|
||||
return key <= 0xff ? key : key >= 0xff00 ? xmap[ key & 0xff ] : 0;
|
||||
}
|
||||
|
||||
|
||||
int puf_handle_event(Fl_Gl_Window *window, int event)
|
||||
{
|
||||
int n, ret = 1;
|
||||
|
||||
switch (event) {
|
||||
|
||||
case FL_PUSH:
|
||||
case FL_RELEASE:
|
||||
window->make_current();
|
||||
ret = puMouse(Fl::event_button() - 1, event == FL_PUSH ? PU_DOWN : PU_UP,
|
||||
Fl::event_x(), Fl::event_y());
|
||||
window->redraw();
|
||||
break;
|
||||
|
||||
case FL_DRAG:
|
||||
window->make_current();
|
||||
ret = puMouse(Fl::event_x(), Fl::event_y());
|
||||
window->redraw();
|
||||
break;
|
||||
|
||||
case FL_ENTER:
|
||||
window->take_focus();
|
||||
break;
|
||||
|
||||
case FL_FOCUS:
|
||||
case FL_UNFOCUS:
|
||||
window->redraw();
|
||||
break;
|
||||
|
||||
case FL_KEYDOWN:
|
||||
case FL_KEYUP:
|
||||
n = Fl::event_length();
|
||||
ret = 0;
|
||||
if (Fl::event_key() <= 0xff && n > 0) {
|
||||
const char *s = Fl::event_text();
|
||||
window->make_current();
|
||||
for (int i = 0; i < n; i++)
|
||||
ret |= puKeyboard(s[i], event == FL_KEYDOWN ? PU_DOWN : PU_UP);
|
||||
} else {
|
||||
int key = puf_translate_key(Fl::event_key());
|
||||
if (key != 0) {
|
||||
window->make_current();
|
||||
ret = puKeyboard(key, event == FL_KEYDOWN ? PU_DOWN : PU_UP);
|
||||
}
|
||||
}
|
||||
if (ret != 0)
|
||||
window->redraw();
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int Puf_Window::handle(int event)
|
||||
{
|
||||
return puf_handle_event(this, event) || Fl_Gl_Window::handle(event);
|
||||
}
|
||||
|
||||
|
||||
void Puf_Window::draw()
|
||||
{
|
||||
if (!valid())
|
||||
glViewport(0, 0, w(), h());
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
#if 1 // draw a border showing current focus
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, w(), 0, h(), -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
float c = (Fl::focus() == this ? 0.9f : 0.5f);
|
||||
glColor3f(c, c, c);
|
||||
|
||||
float x0 = 0.5f, x1 = w() - 0.5f;
|
||||
float y0 = 0.5f, y1 = h() - 0.5f;
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(x0, y0);
|
||||
glVertex2f(x1, y0);
|
||||
glVertex2f(x1, y1);
|
||||
glVertex2f(x0, y1);
|
||||
glEnd();
|
||||
|
||||
#endif
|
||||
|
||||
puDisplay();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
mode: C++
|
||||
c-basic-offset: 4
|
||||
c-file-offsets: ((substatement-open 0) (case-label 0))
|
||||
End:
|
||||
*/
|
||||
61
examples/src/pui/fltk_demo/puf.h
Normal file
61
examples/src/pui/fltk_demo/puf.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: puf.h 1877 2004-02-25 11:01:31Z stromberg $
|
||||
*/
|
||||
|
||||
|
||||
#ifndef puf_h
|
||||
#define puf_h
|
||||
|
||||
#include <FL/Fl_Gl_Window.H>
|
||||
|
||||
|
||||
// Functions for passing FLTK events to PUI
|
||||
|
||||
int puf_translate_key(int key_code);
|
||||
int puf_handle_event(Fl_Gl_Window *, int event);
|
||||
|
||||
|
||||
// An FLTK window class for simple PUI integration
|
||||
|
||||
class Puf_Window : public Fl_Gl_Window
|
||||
{
|
||||
protected:
|
||||
virtual int handle(int);
|
||||
virtual void draw();
|
||||
public:
|
||||
Puf_Window(int X, int Y, int W, int H, const char *L = 0)
|
||||
: Fl_Gl_Window(X, Y, W, H, L) {}
|
||||
Puf_Window(int W, int H, const char *L = 0)
|
||||
: Fl_Gl_Window(W, H, L) {}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
mode: C++
|
||||
c-basic-offset: 4
|
||||
c-file-offsets: ((substatement-open 0) (case-label 0))
|
||||
End:
|
||||
*/
|
||||
75
examples/src/pui/sdl_example/Demo.cxx
Normal file
75
examples/src/pui/sdl_example/Demo.cxx
Normal file
@@ -0,0 +1,75 @@
|
||||
#include <stdio.h>
|
||||
#include <GL/gl.h>
|
||||
#include <plib/pu.h>
|
||||
|
||||
#include "Demo.h"
|
||||
|
||||
|
||||
static puInput* input = NULL;
|
||||
|
||||
|
||||
|
||||
static void on_quit(puObject*)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void on_say_hello(puObject*)
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
}
|
||||
|
||||
static void on_print_text(puObject*)
|
||||
{
|
||||
printf("Input text: %s\n", input->getStringValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void initPUI()
|
||||
{
|
||||
puInit();
|
||||
|
||||
puSetDefaultStyle(PUSTYLE_SMALL_BEVELLED);
|
||||
puSetDefaultColourScheme(0.75f, 0.75f, 0.75f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
void createInterface()
|
||||
{
|
||||
// menu bar
|
||||
puMenuBar* menu = new puMenuBar();
|
||||
char* menu_text[] = {
|
||||
"Quit",
|
||||
"----",
|
||||
"Say Hello",
|
||||
"Print text",
|
||||
NULL
|
||||
};
|
||||
puCallback menu_cb[] = {
|
||||
on_quit,
|
||||
NULL,
|
||||
on_say_hello,
|
||||
on_print_text,
|
||||
NULL
|
||||
};
|
||||
menu->add_submenu("Demo", menu_text, menu_cb);
|
||||
menu->close();
|
||||
|
||||
// input and buttons
|
||||
puButton* button;
|
||||
button = new puOneShot(100, 200, 220, 225);
|
||||
button->setLegend("Quit");
|
||||
button->setCallback(on_quit);
|
||||
|
||||
button = new puOneShot(100, 250, 220, 275);
|
||||
button->setLegend("Say Hello");
|
||||
button->setCallback(on_say_hello);
|
||||
|
||||
button = new puOneShot(100, 300, 220, 325);
|
||||
button->setLegend("Print text");
|
||||
button->setCallback(on_print_text);
|
||||
|
||||
input = new puInput(250, 300, 450, 325);
|
||||
}
|
||||
|
||||
10
examples/src/pui/sdl_example/Demo.h
Normal file
10
examples/src/pui/sdl_example/Demo.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef DEMO_H
|
||||
#define DEMO_H
|
||||
|
||||
|
||||
void initPUI();
|
||||
|
||||
void createInterface();
|
||||
|
||||
|
||||
#endif
|
||||
180
examples/src/pui/sdl_example/EventLoopSDL.cxx
Normal file
180
examples/src/pui/sdl_example/EventLoopSDL.cxx
Normal file
@@ -0,0 +1,180 @@
|
||||
#include <GL/gl.h>
|
||||
#include <SDL/SDL_keysym.h>
|
||||
#include <plib/pu.h>
|
||||
|
||||
#include "EventLoopSDL.h"
|
||||
|
||||
|
||||
static bool stop_requested;
|
||||
|
||||
|
||||
|
||||
void EventLoopSDL::run()
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
stop_requested = false;
|
||||
while (!stop_requested) {
|
||||
|
||||
// process events
|
||||
SDL_WaitEvent(NULL);
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT:
|
||||
stop_requested = true;
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
onMouseMove(event.motion.state, event.motion.x, event.motion.y);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
onMouseDown(event.button.button, event.button.x, event.button.y);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
onMouseUp(event.button.button, event.button.x, event.button.y);
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
onKeyDown(event.key.keysym);
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
onKeyUp(event.key.keysym);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// redraw
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
draw();
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EventLoopSDL::stop()
|
||||
{
|
||||
stop_requested = true;
|
||||
}
|
||||
|
||||
|
||||
void EventLoopSDL::draw()
|
||||
{
|
||||
puDisplay();
|
||||
}
|
||||
|
||||
|
||||
int EventLoopSDL::translateKey(const SDL_keysym& keysym)
|
||||
{
|
||||
// Printable characters
|
||||
if (keysym.unicode > 0)
|
||||
return keysym.unicode;
|
||||
|
||||
// Numpad key, translate no non-numpad equivalent
|
||||
if (keysym.sym >= SDLK_KP0 && keysym.sym <= SDLK_KP_EQUALS) {
|
||||
switch (keysym.sym) {
|
||||
case SDLK_KP0:
|
||||
return PU_KEY_INSERT;
|
||||
case SDLK_KP1:
|
||||
return PU_KEY_END;
|
||||
case SDLK_KP2:
|
||||
return PU_KEY_DOWN;
|
||||
case SDLK_KP3:
|
||||
return PU_KEY_PAGE_DOWN;
|
||||
case SDLK_KP4:
|
||||
return PU_KEY_LEFT;
|
||||
case SDLK_KP6:
|
||||
return PU_KEY_RIGHT;
|
||||
case SDLK_KP7:
|
||||
return PU_KEY_HOME;
|
||||
case SDLK_KP8:
|
||||
return PU_KEY_UP;
|
||||
case SDLK_KP9:
|
||||
return PU_KEY_PAGE_UP;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Everything else
|
||||
switch (keysym.sym) {
|
||||
case SDLK_UP:
|
||||
return PU_KEY_UP;
|
||||
case SDLK_DOWN:
|
||||
return PU_KEY_DOWN;
|
||||
case SDLK_LEFT:
|
||||
return PU_KEY_LEFT;
|
||||
case SDLK_RIGHT:
|
||||
return PU_KEY_RIGHT;
|
||||
|
||||
case SDLK_PAGEUP:
|
||||
return PU_KEY_PAGE_UP;
|
||||
case SDLK_PAGEDOWN:
|
||||
return PU_KEY_PAGE_DOWN;
|
||||
case SDLK_HOME:
|
||||
return PU_KEY_HOME;
|
||||
case SDLK_END:
|
||||
return PU_KEY_END;
|
||||
case SDLK_INSERT:
|
||||
return PU_KEY_INSERT;
|
||||
case SDLK_DELETE:
|
||||
return -1;
|
||||
|
||||
case SDLK_F1:
|
||||
return PU_KEY_F1;
|
||||
case SDLK_F2:
|
||||
return PU_KEY_F2;
|
||||
case SDLK_F3:
|
||||
return PU_KEY_F3;
|
||||
case SDLK_F4:
|
||||
return PU_KEY_F4;
|
||||
case SDLK_F5:
|
||||
return PU_KEY_F5;
|
||||
case SDLK_F6:
|
||||
return PU_KEY_F6;
|
||||
case SDLK_F7:
|
||||
return PU_KEY_F7;
|
||||
case SDLK_F8:
|
||||
return PU_KEY_F8;
|
||||
case SDLK_F9:
|
||||
return PU_KEY_F9;
|
||||
case SDLK_F10:
|
||||
return PU_KEY_F10;
|
||||
case SDLK_F11:
|
||||
return PU_KEY_F11;
|
||||
case SDLK_F12:
|
||||
return PU_KEY_F12;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int EventLoopSDL::translateMouse(int btn)
|
||||
{
|
||||
// SDL counts buttons from 1, PUI from 0
|
||||
return btn-1;
|
||||
}
|
||||
|
||||
|
||||
int EventLoopSDL::onMouseMove(char state, int x, int y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int EventLoopSDL::onMouseDown(int btn, int x, int y)
|
||||
{
|
||||
return puMouse(translateMouse(btn), PU_DOWN, x, y);
|
||||
}
|
||||
|
||||
int EventLoopSDL::onMouseUp(int btn, int x, int y)
|
||||
{
|
||||
return puMouse(translateMouse(btn), PU_UP, x, y);
|
||||
}
|
||||
|
||||
int EventLoopSDL::onKeyDown(const SDL_keysym& keysym)
|
||||
{
|
||||
return puKeyboard(translateKey(keysym), PU_DOWN);
|
||||
}
|
||||
|
||||
int EventLoopSDL::onKeyUp(const SDL_keysym& keysym)
|
||||
{
|
||||
return puKeyboard(translateKey(keysym), PU_UP);
|
||||
}
|
||||
32
examples/src/pui/sdl_example/EventLoopSDL.h
Normal file
32
examples/src/pui/sdl_example/EventLoopSDL.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef EVENTLOOPSDL_H
|
||||
#define EVENTLOOPSDL_H
|
||||
|
||||
|
||||
class EventLoopSDL
|
||||
{
|
||||
public:
|
||||
// starts the main loop
|
||||
static void run();
|
||||
|
||||
// requests main loop termination
|
||||
static void stop();
|
||||
|
||||
// draw one frame
|
||||
static void draw();
|
||||
|
||||
// translates an SDL keysym to the PUI equivalent
|
||||
static int translateKey(const SDL_keysym& keysym);
|
||||
|
||||
// translates an SDL mouse button to the PUI equivalent
|
||||
static int translateMouse(int btn);
|
||||
|
||||
// event handlers
|
||||
static int onMouseMove(char state, int x, int y);
|
||||
static int onMouseDown(int btn, int x, int y);
|
||||
static int onMouseUp(int btn, int x, int y);
|
||||
static int onKeyDown(const SDL_keysym& keysym);
|
||||
static int onKeyUp(const SDL_keysym& keysym);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
38
examples/src/pui/sdl_example/Makefile
Normal file
38
examples/src/pui/sdl_example/Makefile
Normal file
@@ -0,0 +1,38 @@
|
||||
SDL_LDFLAGS := $(shell sdl-config --libs)
|
||||
OGL_LDFLAGS := -lGL -lGLU
|
||||
PUI_LDFLAGS := -lplibpu -lplibfnt -lplibsg -lplibul
|
||||
LDFLAGS := $(OGL_LDFLAGS) $(SDL_LDFLAGS) $(PUI_LDFLAGS) -lm
|
||||
|
||||
SDL_CFLAGS := $(shell sdl-config --cflags)
|
||||
PUI_CFLAGS := -DPU_USE_SDL
|
||||
CXXFLAGS := -Wall -g $(SDL_CFLAGS) $(PUI_CFLAGS)
|
||||
|
||||
CXX := g++
|
||||
|
||||
|
||||
OBJECT := mainSDL.o EventLoopSDL.o Demo.o
|
||||
|
||||
|
||||
%.o : %.cxx
|
||||
$(CXX) $(CXXFLAGS) -c $<
|
||||
|
||||
|
||||
sdl_example: $(OBJECT)
|
||||
$(CXX) -o $@ $+ $(LDFLAGS)
|
||||
|
||||
|
||||
.PHONY: clean depend
|
||||
|
||||
clean:
|
||||
rm -f *.o sdl_example
|
||||
|
||||
depend:
|
||||
makedepend -Y *.cxx >/dev/null 2>&1
|
||||
|
||||
|
||||
# Do 'make depend' to regenerate dependencies.
|
||||
# DO NOT DELETE
|
||||
|
||||
Demo.o: Demo.h
|
||||
EventLoopSDL.o: EventLoopSDL.h
|
||||
mainSDL.o: Demo.h EventLoopSDL.h
|
||||
58
examples/src/pui/sdl_example/mainSDL.cxx
Normal file
58
examples/src/pui/sdl_example/mainSDL.cxx
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <stdlib.h>
|
||||
#include <plib/pu.h>
|
||||
#include "SDL.h"
|
||||
|
||||
#include "Demo.h"
|
||||
#include "EventLoopSDL.h"
|
||||
|
||||
|
||||
// default window size
|
||||
static const int WIDTH = 640;
|
||||
static const int HEIGHT = 480;
|
||||
|
||||
|
||||
static void initSDL(int w, int h, const char *title)
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
|
||||
if (SDL_SetVideoMode(w, h, 0, SDL_OPENGL | SDL_ANYFORMAT/* | SDL_FULLSCREEN*/) == NULL) {
|
||||
fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (title)
|
||||
SDL_WM_SetCaption(title, NULL);
|
||||
|
||||
SDL_EnableKeyRepeat(150, 75);
|
||||
SDL_EnableUNICODE(true);
|
||||
}
|
||||
|
||||
|
||||
void initOGL(int w, int h)
|
||||
{
|
||||
glViewport(0, 0, w, h);
|
||||
glClearColor(0.1f, 0.4f, 0.1f, 1.0f);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glAlphaFunc(GL_GREATER, 0.1f);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
initSDL(WIDTH, HEIGHT, "PUI with SDL sample");
|
||||
initOGL(WIDTH, HEIGHT);
|
||||
initPUI();
|
||||
|
||||
createInterface();
|
||||
|
||||
EventLoopSDL::run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
131
examples/src/pui/simple.cxx
Normal file
131
examples/src/pui/simple.cxx
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: simple.cxx 1551 2002-09-01 12:04:53Z ude $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/pu.h>
|
||||
|
||||
//#define VOODOO 1
|
||||
|
||||
void motionfn ( int x, int y )
|
||||
{
|
||||
puMouse ( x, y ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
void mousefn ( int button, int updown, int x, int y )
|
||||
{
|
||||
puMouse ( button, updown, x, y ) ;
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
void displayfn ( void )
|
||||
{
|
||||
glClearColor ( 0.1f, 0.4f, 0.1f, 1.0f ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT ) ;
|
||||
|
||||
puDisplay () ;
|
||||
|
||||
glutSwapBuffers () ;
|
||||
|
||||
/* The next line is not neccessary - you could remove it safely without
|
||||
affecting the functionality of this simple example program.
|
||||
|
||||
It exists because in every application which does some more stuff
|
||||
than creating user interface widgets, you normally do want to
|
||||
redraw your scenery as often as possible for smooth animation. */
|
||||
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
void button_cb ( puObject * )
|
||||
{
|
||||
fprintf ( stderr, "Hello World.\n" ) ;
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
#ifdef VOODOO
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
#endif
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &argc, argv ) ;
|
||||
|
||||
/* Note that in order for PUI and this example program to work, you
|
||||
definitely don't need a depth buffer.
|
||||
|
||||
However, most applications using PUI do some more things than rendering
|
||||
PUI widgets. In every "real" program, you usually do need a depth
|
||||
buffer - we are requesting one in the next line so that PLIB programmers
|
||||
can write their applications upon this example code without running
|
||||
into problems. */
|
||||
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
|
||||
glutCreateWindow ( "PUI Application" ) ;
|
||||
glutDisplayFunc ( displayfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
|
||||
#ifdef VOODOO
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
#endif
|
||||
|
||||
puInit () ;
|
||||
|
||||
#ifdef VOODOO
|
||||
puShowCursor () ;
|
||||
#endif
|
||||
|
||||
puOneShot *b = new puOneShot ( 50, 50, 200, 80 ) ;
|
||||
|
||||
b -> setLegend ( "Say Hello" ) ;
|
||||
b -> setCallback ( button_cb ) ;
|
||||
|
||||
printf ( "%d\n", PLIB_VERSION ) ;
|
||||
|
||||
glutMainLoop () ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
88
examples/src/pui/simple.dsp
Normal file
88
examples/src/pui/simple.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="simple" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=simple - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "simple.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "simple.mak" CFG="simple - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "simple - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "simple - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "simple - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui.lib fnt.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"simple.exe" /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "simple - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui_d.lib fnt_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"simple.exe" /pdbtype:sept /libpath:"..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "simple - Win32 Release"
|
||||
# Name "simple - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simple.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user