From cf2fe0e32ddd67f3be9a63cb2ec322176b28d8c8 Mon Sep 17 00:00:00 2001 From: "Martin Felis (berta)" Date: Sat, 13 Nov 2010 18:37:16 +0100 Subject: [PATCH] updated oglft to version 0.9 --- engine/libraries/oglft/AUTHORS | 6 +- engine/libraries/oglft/CMakeLists.txt | 14 +- engine/libraries/oglft/NEWS | 6 + engine/libraries/oglft/OGLFT.h | 4 +- engine/libraries/oglft/liboglft/OGLFT.cpp | 613 ++++++++++-------- .../oglft/tests/Demo3UnicodeExample.h | 2 +- engine/libraries/oglft/tests/demo.cpp | 31 +- engine/libraries/oglft/tests/demo2.cpp | 24 +- engine/libraries/oglft/tests/demo3.cpp | 59 +- engine/libraries/oglft/tests/speedtest.cpp | 82 ++- engine/libraries/oglft/tests/speedtest.h | 2 +- engine/libraries/oglft/tests/tutorial1.cpp | 5 +- engine/libraries/oglft/tests/tutorial2.cpp | 11 +- engine/libraries/oglft/tests/tutorial3.cpp | 38 +- engine/libraries/oglft/tests/vignette.h | 14 +- 15 files changed, 497 insertions(+), 414 deletions(-) diff --git a/engine/libraries/oglft/AUTHORS b/engine/libraries/oglft/AUTHORS index 2a22791..7e16e35 100644 --- a/engine/libraries/oglft/AUTHORS +++ b/engine/libraries/oglft/AUTHORS @@ -1,5 +1,3 @@ -Authors of OGLFT +Author of OGLFT -Allen Barnett -Oliver Bock -Nigel Stewart +Allen Barnett diff --git a/engine/libraries/oglft/CMakeLists.txt b/engine/libraries/oglft/CMakeLists.txt index 70dc430..fa0b50d 100644 --- a/engine/libraries/oglft/CMakeLists.txt +++ b/engine/libraries/oglft/CMakeLists.txt @@ -7,14 +7,14 @@ Set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake ) FIND_PACKAGE( OpenGL REQUIRED ) FIND_PACKAGE( FreeType2 REQUIRED ) -if( ENABLE_QT ) - find_package( Qt REQUIRED ) - if( DESIRED_QT_VERSION EQUAL 3 ) - find_package( KDE3 REQUIRED ) - endif( DESIRED_QT_VERSION EQUAL 3 ) -endif( ENABLE_QT ) +IF( ENABLE_QT ) + FIND_PACKAGE( QT REQUIRED ) + IF( DESIRED_QT_VERSION EQUAL 3 ) + FIND_PACKAGE( KDE3 REQUIRED ) + ENDIF( DESIRED_QT_VERSION EQUAL 3 ) +ENDIF( ENABLE_QT ) -if( ENABLE_GLE ) +If( ENABLE_GLE ) find_package( GLE ) endif( ENABLE_GLE ) diff --git a/engine/libraries/oglft/NEWS b/engine/libraries/oglft/NEWS index bc5efa7..24ead74 100644 --- a/engine/libraries/oglft/NEWS +++ b/engine/libraries/oglft/NEWS @@ -1,3 +1,9 @@ +New in OGLFT version 0.9 + + * Moved my CVS repository so this is mostly a resync. + + * A couple of minor changes to configure.ac for RH Linux 9, too. + New in OGLFT version 0.8 * Added the ability to draw numbers with a format à la printf. diff --git a/engine/libraries/oglft/OGLFT.h b/engine/libraries/oglft/OGLFT.h index a8bf6ed..5755794 100644 --- a/engine/libraries/oglft/OGLFT.h +++ b/engine/libraries/oglft/OGLFT.h @@ -233,13 +233,13 @@ namespace OGLFT { if ( new_value < x_min_ ) x_min_ = new_value; new_value = b.y_min_ + advance_.dy_; - if ( new_value < y_min_ ) y_min_ = new_value; + if ( advance_.dy_ != 0. && new_value < y_min_ ) y_min_ = new_value; new_value = b.x_max_ + advance_.dx_; if ( new_value > x_max_ ) x_max_ = new_value; new_value = b.y_max_ + advance_.dy_; - if ( new_value > y_max_ ) y_max_ = new_value; + if ( advance_.dy_ != 0. && new_value > y_max_ ) y_max_ = new_value; advance_.dx_ += b.advance_.dx_; advance_.dy_ += b.advance_.dy_; diff --git a/engine/libraries/oglft/liboglft/OGLFT.cpp b/engine/libraries/oglft/liboglft/OGLFT.cpp index db61802..19a4514 100644 --- a/engine/libraries/oglft/liboglft/OGLFT.cpp +++ b/engine/libraries/oglft/liboglft/OGLFT.cpp @@ -1,8 +1,7 @@ /* * OGLFT: A library for drawing text with OpenGL using the FreeType library * Copyright (C) 2002 lignum Computing, Inc. - * Copyright (C) 2008 Allen Barnett - * $Id:$ + * $Id: OGLFT.cpp,v 1.11 2003/10/01 14:21:18 allen Exp $ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,13 +21,16 @@ #include #include - -#include "OGLFT.h" - +#ifdef HAVE_CONFIG_H +#include +#endif +#include #ifndef OGLFT_NO_QT #include #endif +#include + namespace OGLFT { // This is the static instance of the FreeType library wrapper ... @@ -69,7 +71,7 @@ namespace OGLFT { return library_; } - // Load a new face from file + // Load a new face Face::Face ( const char* filename, float point_size, FT_UInt resolution ) : point_size_( point_size ), resolution_( resolution ) @@ -95,32 +97,6 @@ namespace OGLFT { init(); } - // Load a new face from memory - - Face::Face ( const FT_Byte* data_base, const FT_Long data_size, float point_size, FT_UInt resolution ) - : point_size_( point_size ), resolution_( resolution ) - { - valid_ = true; // Assume the best :-) - - FT_Face ft_face; - - FT_Error error = FT_New_Memory_Face( Library::instance(), data_base, data_size, 0, &ft_face ); - - if ( error != 0 ) { - valid_ = false; - return; - } - - // As of FreeType 2.1: only a UNICODE charmap is automatically activated. - // If no charmap is activated automatically, just use the first one. - if ( ft_face->charmap == 0 && ft_face->num_charmaps > 0 ) - FT_Select_Charmap( ft_face, ft_face->charmaps[0]->encoding ); - - faces_.push_back( FaceData( ft_face ) ); - - init(); - } - // Go with a face that the user has already opened. Face::Face ( FT_Face face, float point_size, FT_UInt resolution ) @@ -186,7 +162,7 @@ namespace OGLFT { FT_Done_Face( faces_[i].face_ ); } - // Add another Face to select characters from file. + // Add another Face to select characters from bool Face::addAuxiliaryFace ( const char* filename ) { @@ -204,25 +180,7 @@ namespace OGLFT { return true; } - // Add another Face to select characters from memory. - - bool Face::addAuxiliaryFace ( const FT_Byte* data_base, const FT_Long data_size ) - { - FT_Face ft_face; - - FT_Error error = FT_New_Memory_Face( Library::instance(), data_base, data_size, 0, &ft_face ); - - if ( error != 0 ) - return false; - - faces_.push_back( FaceData( ft_face ) ); - - setCharSize(); - - return true; - } - - // Add another Face to select characters from (face) + // Add another Face to select characters from bool Face::addAuxiliaryFace ( FT_Face face ) { @@ -398,7 +356,7 @@ namespace OGLFT { if ( string_rotation_ != 0. ) { float angle; if ( string_rotation_ < 0. ) { - angle = 360.f - fmod( fabs( string_rotation_ ), 360.f ); + angle = 360. - fmod( fabs( string_rotation_ ), 360.f ); } else { angle = fmod( string_rotation_, 360.f ); @@ -454,29 +412,40 @@ namespace OGLFT { BBox Face::measure ( const char* s ) { - BBox bbox; - char c; + BBox bbox; + char c; - if ( ( c = *s++ ) != 0 ) { + if ( ( c = *s++ ) != 0 ) { - bbox = measure( c ); + bbox = measure( c ); - for ( c = *s; c != 0; c = *++s ) { + for ( c = *s; c != 0; c = *++s ) { - BBox char_bbox = measure( c ); + BBox char_bbox = measure( c ); - bbox += char_bbox; - } - } + bbox += char_bbox; - return bbox; - } + /* + std::cerr << "adding " << c + << " y_max_: " << bbox.y_max_ << " y_min: " << bbox.y_min_ + << " advance.dy: " << bbox.advance_.dy_ + << " advance.dx: " << bbox.advance_.dx_ - BBox Face::measureRaw ( const char* s ) - { - BBox bbox; + << std::endl; + */ + assert (bbox.y_max_ - bbox.y_min_ != 0.); - for ( char c = *s; c != 0; c = *++s ) { + } + } + + return bbox; + } + + BBox Face::measureRaw ( const char* s ) + { + BBox bbox; + + for ( char c = *s; c != 0; c = *++s ) { BBox char_bbox; unsigned int f; @@ -592,7 +561,7 @@ namespace OGLFT { float angle; if ( string_rotation_ < 0. ) { - angle = 360.f - fmod( fabs( string_rotation_ ), 360.f ); + angle = 360. - fmod( fabs( string_rotation_ ), 360.f ); } else { angle = fmod( string_rotation_, 360.f ); @@ -664,21 +633,13 @@ namespace OGLFT { // 3. optionally anything after it. // Note that since everything is optional, the match always succeeds. QRegExp format_regexp("((?:[^%]|%%)*)(%[0-9]*\\.?[0-9]*[efgp])?((?:[^%]|%%)*)"); -#if OGLFT_QT_VERSION == 3 /*int pos = */ format_regexp.search( format ); -#elif OGLFT_QT_VERSION == 4 - /*int pos = */ format_regexp.exactMatch( format ); -#endif QStringList list = format_regexp.capturedTexts(); QStringList::Iterator it = list.begin(); -#if OGLFT_QT_VERSION == 3 it = list.remove( it ); // Remove the "matched" string, leaving the pieces -#elif OGLFT_QT_VERSION == 4 - it = list.erase( it ); // Remove the "matched" string, leaving the pieces -#endif if ( it == list.end() ) return QString::null; // Probably an error @@ -696,28 +657,20 @@ namespace OGLFT { if ( !(*it).isEmpty() ) { // Reparse this to extract the details of the format QRegExp specifier_regexp( "([0-9]*)\\.?([0-9]*)([efgp])" ); -#if OGLFT_QT_VERSION == 3 (void)specifier_regexp.search( *it ); -#elif OGLFT_QT_VERSION == 4 - (void)specifier_regexp.exactMatch( *it ); -#endif QStringList specifier_list = specifier_regexp.capturedTexts(); QStringList::Iterator sit = specifier_list.begin(); -#if OGLFT_QT_VERSION == 3 + sit = specifier_list.remove( sit ); -#elif OGLFT_QT_VERSION == 4 - sit = specifier_list.erase( sit ); -#endif + int width = (*sit).toInt(); ++sit; int precision = (*sit).toInt(); ++sit; -#if OGLFT_QT_VERSION == 3 + type = (*sit).at(0).latin1(); -#elif OGLFT_QT_VERSION == 4 - type = (*sit).at(0).toLatin1(); -#endif + // The regular formats just use Qt's number formatting capability if ( type == 'e' || type == 'f' || type == 'g' ) value_format = QString( "%1" ).arg( number, width, type, precision ); @@ -752,18 +705,18 @@ namespace OGLFT { // Format the numerator and shift to 0xE000 sequence QString numerator = QString::number( b ); for ( uint i = 0; i < numerator.length(); i++ ) { - numerator[i] = QChar( numerator.at(i).unicode() - - QChar('0').unicode() + - 0xE000 ); + numerator.at(i) = QChar( numerator.at(i).unicode() - + QChar('0').unicode() + + 0xE000 ); } value_format += numerator; value_format += QChar( 0xE00a ); // The '/' // Format the denominator and shift to 0xE010 sequence QString denominator = QString::number( c ); for ( uint i = 0; i < denominator.length(); i++ ) { - denominator[i] = QChar( denominator.at(i).unicode() - - QChar('0').unicode() + - 0xE010 ); + denominator.at(i) = QChar( denominator.at(i).unicode() - + QChar('0').unicode() + + 0xE010 ); } value_format += denominator; } @@ -1039,6 +992,21 @@ namespace OGLFT { draw( c ); } + + // Draw the (latin1) character at the given position. The MODELVIEW + // matrix is modified by the glyph advance. + + void Face::draw ( GLfloat x, GLfloat y, GLfloat z, unsigned char c ) + { + glTranslatef( x, y, z ); + + glColor4f( foreground_color_[R], foreground_color_[G], foreground_color_[B], + foreground_color_[A] ); + + glRasterPos2i( 0, 0 ); + + draw( c ); + } #ifndef OGLFT_NO_QT // Draw the (UNICODE) character at the given position. The MODELVIEW // matrix is modified by the glyph advance. @@ -1054,7 +1022,23 @@ namespace OGLFT { draw( c ); } + + // Draw the (UNICODE) character at the given position. The MODELVIEW + // matrix is modified by the glyph advance. + + void Face::draw ( GLfloat x, GLfloat y, GLfloat z, QChar c ) + { + glTranslatef( x, y, z ); + + glColor4f( foreground_color_[R], foreground_color_[G], foreground_color_[B], + foreground_color_[A] ); + + glRasterPos2i( 0, 0 ); + + draw( c ); + } #endif /* OGLFT_NO_QT */ + // Draw the (latin1) string at the given position. void Face::draw ( GLfloat x, GLfloat y, const char* s ) @@ -1074,7 +1058,7 @@ namespace OGLFT { case LEFT: dx = -bbox.x_min_; break; case CENTER: - dx = -( bbox.x_min_ + bbox.x_max_ ) / 2.f; break; + dx = -( bbox.x_min_ + bbox.x_max_ ) / 2.; break; case RIGHT: dx = -bbox.x_max_; break; default: @@ -1084,7 +1068,7 @@ namespace OGLFT { case BOTTOM: dy = -bbox.y_min_; break; case MIDDLE: - dy = -( bbox.y_min_ + bbox.y_max_ ) / 2.f; break; + dy = -( bbox.y_min_ + bbox.y_max_ ) / 2.; break; case TOP: dy = -bbox.y_max_; break; default: @@ -1115,6 +1099,66 @@ namespace OGLFT { glPopMatrix(); } + // Draw the (latin1) string at the given position. + + void Face::draw ( GLfloat x, GLfloat y, GLfloat z, const char* s ) + { + if ( !advance_ ) + glPushMatrix(); + + if ( horizontal_justification_ != ORIGIN || + vertical_justification_ != BASELINE ) { + glPushMatrix(); + + BBox bbox = measure_nominal( s ); + + GLfloat dx = 0, dy = 0; + + switch ( horizontal_justification_ ) { + case LEFT: + dx = -bbox.x_min_; break; + case CENTER: + dx = -( bbox.x_min_ + bbox.x_max_ ) / 2.; break; + case RIGHT: + dx = -bbox.x_max_; break; + default: + break; + } + switch ( vertical_justification_ ) { + case BOTTOM: + dy = -bbox.y_min_; break; + case MIDDLE: + dy = -( bbox.y_min_ + bbox.y_max_ ) / 2.; break; + case TOP: + dy = -bbox.y_max_; break; + default: + break; + } + + // There is probably a less expensive way to compute this + + glRotatef( string_rotation_, 0., 0., 1. ); + glTranslatef( dx, dy, 0 ); + glRotatef( -string_rotation_, 0., 0., 1. ); + } + + glTranslatef( x, y, z ); + + glColor4f( foreground_color_[R], foreground_color_[G], foreground_color_[B], + foreground_color_[A] ); + + glRasterPos2i( 0, 0 ); + + draw( s ); + + if ( horizontal_justification_ != ORIGIN || + vertical_justification_ != BASELINE ) + glPopMatrix(); + + if ( !advance_ ) + glPopMatrix(); + } + #ifndef OGLFT_NO_QT // Draw the (UNICODE) string at the given position. @@ -1138,8 +1182,6 @@ namespace OGLFT { dx = -( bbox.x_min_ + bbox.x_max_ ) / 2.; break; case RIGHT: dx = -bbox.x_max_; break; - case ORIGIN: - break; } switch ( vertical_justification_ ) { case BOTTOM: @@ -1148,8 +1190,6 @@ namespace OGLFT { dy = -( bbox.y_min_ + bbox.y_max_ ) / 2.; break; case TOP: dy = -bbox.y_max_; break; - case BASELINE: - break; } // There is probably a less expensive way to compute this @@ -1176,12 +1216,124 @@ namespace OGLFT { glPopMatrix(); } + // Draw the (UNICODE) string at the given position. + + void Face::draw ( GLfloat x, GLfloat y, GLfloat z, const QString& s ) + { + if ( !advance_ ) + glPushMatrix(); + + if ( horizontal_justification_ != ORIGIN || + vertical_justification_ != BASELINE ) { + glPushMatrix(); + + // In 3D, we need to exert more care in the computation of the + // bounding box of the text. NOTE: Needs to be fixed up for + // polygonal faces, too... + + BBox bbox; + // Code from measure_nominal, but changed to use measureRaw instead + if ( string_rotation_ == 0. ) + bbox = measureRaw( s ); + + else { + // Undo rotation + for ( unsigned int f = 0; f < faces_.size(); f++ ) + FT_Set_Transform( faces_[f].face_, 0, 0 ); + + bbox = measureRaw( s ); + + // Redo rotation + float angle; + if ( string_rotation_ < 0. ) { + angle = 360. - fmod( fabs( string_rotation_ ), 360.f ); + } + else { + angle = fmod( string_rotation_, 360.f ); + } + + FT_Matrix rotation_matrix; + FT_Vector sinus; + + FT_Vector_Unit( &sinus, (FT_Angle)(angle * 0x10000L) ); + + rotation_matrix.xx = sinus.x; + rotation_matrix.xy = -sinus.y; + rotation_matrix.yx = sinus.y; + rotation_matrix.yy = sinus.x; + + for ( unsigned int f = 0; f < faces_.size(); f++ ) + FT_Set_Transform( faces_[f].face_, &rotation_matrix, 0 ); + } + + // Determine the offset into the bounding box which will appear + // at the user's specified position. + GLfloat dx = 0, dy = 0; + switch ( horizontal_justification_ ) { + case LEFT: + dx = bbox.x_min_; break; + case CENTER: + dx = ( bbox.x_min_ + bbox.x_max_ ) / 2; break; + case RIGHT: + dx = bbox.x_max_; break; + } + switch ( vertical_justification_ ) { + case BOTTOM: + dy = bbox.y_min_; break; + case MIDDLE: + dy = ( bbox.y_min_ + bbox.y_max_ ) /2; break; + case TOP: + dy = bbox.y_max_; break; + } + + // **Now** rotate these coordinates around into 3D modeling coordinates! + GLint viewport[4]; + GLdouble modelview[16], projection[16]; + + glGetIntegerv( GL_VIEWPORT, viewport ); + glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); + glGetDoublev( GL_PROJECTION_MATRIX, projection ); + + GLdouble x0, y0, z0; + gluUnProject( 0, 0, 0, modelview, projection, viewport, &x0, &y0, &z0 ); + + GLdouble dx_m, dy_m, dz_m; + gluUnProject( dx, dy, 0., modelview, projection, viewport,&dx_m,&dy_m,&dz_m ); + + glTranslated( x0-dx_m, y0-dy_m, z0-dz_m ); + } + + glTranslatef( x, y, z ); + + glColor4f( foreground_color_[R], foreground_color_[G], foreground_color_[B], + foreground_color_[A] ); + + glRasterPos2i( 0, 0 ); + + draw( s ); + + if ( horizontal_justification_ != ORIGIN || + vertical_justification_ != BASELINE ) + glPopMatrix(); + + if ( !advance_ ) + glPopMatrix(); + } + // Draw the number at the given position per the given format. void Face::draw ( GLfloat x, GLfloat y, const QString& format, double number ) { draw( x, y, format_number( format, number ) ); } + + // Draw the number at the given position per the given format. + + void Face::draw ( GLfloat x, GLfloat y, GLfloat z, const QString& format, + double number ) + { + draw( x, y, z, format_number( format, number ) ); + } #endif /* OGLFT_NO_QT */ Raster::Raster ( const char* filename, float point_size, FT_UInt resolution ) @@ -1192,15 +1344,6 @@ namespace OGLFT { init(); } - Raster::Raster ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Face( data_base, data_size, point_size, resolution ) - { - if ( !isValid() ) return; - - init(); - } - Raster::Raster ( FT_Face face, float point_size, FT_UInt resolution ) : Face( face, point_size, resolution ) { @@ -1291,19 +1434,19 @@ namespace OGLFT { GLdouble x, y, z; gluUnProject( bbox.x_min_, bbox.y_min_, 0., modelview, projection, viewport, &x, &y, &z ); - bbox.x_min_ = (float)( x - x0 ); - bbox.y_min_ = (float)( y - y0 ); + bbox.x_min_ = x - x0; + bbox.y_min_ = y - y0; gluUnProject( bbox.x_max_, bbox.y_max_, 0., modelview, projection, viewport, &x, &y, &z ); - bbox.x_max_ = (float)( x - x0 ); - bbox.y_max_ = (float)( y - y0 ); + bbox.x_max_ = x - x0; + bbox.y_max_ = y - y0; gluUnProject( bbox.advance_.dx_, bbox.advance_.dy_, 0., modelview, projection, viewport, &x, &y, &z ); - bbox.advance_.dx_ = (float)( x - x0 ); - bbox.advance_.dy_ = (float)( y - y0 ); + bbox.advance_.dx_ = x - x0; + bbox.advance_.dy_ = y - y0; return bbox; } @@ -1378,11 +1521,6 @@ namespace OGLFT { return bbox; } - - BBox Raster::measure ( const QString& format, double number ) - { - return Face::measure( format, number ); - } #endif /* OGLFT_NO_QT */ GLuint Raster::compileGlyph ( FT_Face face, FT_UInt glyph_index ) @@ -1422,7 +1560,7 @@ namespace OGLFT { if ( error != 0 ) return; - rotation_offset_y_ = rotation_reference_face_->glyph->bitmap.rows / 2.f; + rotation_offset_y_ = rotation_reference_face_->glyph->bitmap.rows / 2.; } void Raster::clearCaches ( void ) @@ -1441,11 +1579,6 @@ namespace OGLFT { : Raster( filename, point_size, resolution ) {} - Monochrome::Monochrome ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Raster( data_base, data_size, point_size, resolution ) - {} - Monochrome::Monochrome ( FT_Face face, float point_size, FT_UInt resolution ) : Raster( face, point_size, resolution ) {} @@ -1543,7 +1676,7 @@ namespace OGLFT { error = FT_Glyph_Transform( glyph, &rotation_matrix, &rotation_offset ); } - error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_mono, 0, 1 ); + error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_MONO, 0, 1 ); if ( error != 0 ) { FT_Done_Glyph( glyph ); @@ -1559,10 +1692,10 @@ namespace OGLFT { GLubyte* inverted_bitmap = invertBitmap( bitmap_glyph->bitmap ); glBitmap( bitmap_glyph->bitmap.width, bitmap_glyph->bitmap.rows, - (GLfloat)-bitmap_glyph->left, - (GLfloat)( bitmap_glyph->bitmap.rows - bitmap_glyph->top ), - face->glyph->advance.x / 64.f, - face->glyph->advance.y / 64.f, + -bitmap_glyph->left, + bitmap_glyph->bitmap.rows - bitmap_glyph->top, + face->glyph->advance.x / 64., + face->glyph->advance.y / 64., inverted_bitmap ); FT_Done_Glyph( glyph ); @@ -1571,15 +1704,10 @@ namespace OGLFT { } Grayscale::Grayscale ( const char* filename, float point_size, - FT_UInt resolution ) + FT_UInt resolution ) : Raster( filename, point_size, resolution ) {} - Grayscale::Grayscale ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Raster( data_base, data_size, point_size, resolution ) - {} - Grayscale::Grayscale ( FT_Face face, float point_size, FT_UInt resolution ) : Raster( face, point_size, resolution ) {} @@ -1655,7 +1783,7 @@ namespace OGLFT { error = FT_Glyph_Transform( glyph, &rotation_matrix, &rotation_offset ); } - error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, 0, 1 ); + error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, 0, 1 ); if ( error != 0 ) { FT_Done_Glyph( glyph ); @@ -1684,8 +1812,8 @@ namespace OGLFT { glPixelTransferf( GL_ALPHA_BIAS, background_color_[A] ); glBitmap( 0, 0, 0, 0, - (GLfloat)bitmap_glyph->left, - (GLfloat)( bitmap_glyph->top - bitmap_glyph->bitmap.rows ), + bitmap_glyph->left, + bitmap_glyph->top - bitmap_glyph->bitmap.rows, 0 ); glDrawPixels( bitmap_glyph->bitmap.width, bitmap_glyph->bitmap.rows, @@ -1696,9 +1824,9 @@ namespace OGLFT { // (without querying the state) glBitmap( 0, 0, 0, 0, - (GLfloat)( -bitmap_glyph->left + face->glyph->advance.x / 64.f ), - (GLfloat)( bitmap_glyph->bitmap.rows - bitmap_glyph->top + - face->glyph->advance.y / 64. ), + -bitmap_glyph->left + face->glyph->advance.x / 64., + bitmap_glyph->bitmap.rows - bitmap_glyph->top + + face->glyph->advance.y / 64., 0 ); FT_Done_Glyph( glyph ); @@ -1709,15 +1837,10 @@ namespace OGLFT { } Translucent::Translucent ( const char* filename, float point_size, - FT_UInt resolution ) + FT_UInt resolution ) : Raster( filename, point_size, resolution ) {} - Translucent::Translucent ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Raster( data_base, data_size, point_size, resolution ) - {} - Translucent::Translucent ( FT_Face face, float point_size, FT_UInt resolution ) : Raster( face, point_size, resolution ) {} @@ -1800,7 +1923,7 @@ namespace OGLFT { error = FT_Glyph_Transform( glyph, &rotation_matrix, &rotation_offset ); } - error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, 0, 1 ); + error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, 0, 1 ); if ( error != 0 ) { FT_Done_Glyph( glyph ); @@ -1830,8 +1953,8 @@ namespace OGLFT { // OpenGL have a similar function for pixmaps?) glBitmap( 0, 0, 0, 0, - (GLfloat)bitmap_glyph->left, - (GLfloat)( bitmap_glyph->top - bitmap_glyph->bitmap.rows ), + bitmap_glyph->left, + bitmap_glyph->top - bitmap_glyph->bitmap.rows, 0 ); glDrawPixels( bitmap_glyph->bitmap.width, bitmap_glyph->bitmap.rows, @@ -1842,9 +1965,9 @@ namespace OGLFT { // (without querying the state) glBitmap( 0, 0, 0, 0, - -bitmap_glyph->left + face->glyph->advance.x / 64.f, + -bitmap_glyph->left + face->glyph->advance.x / 64., bitmap_glyph->bitmap.rows - bitmap_glyph->top + - face->glyph->advance.y / 64.f, + face->glyph->advance.y / 64., 0 ); FT_Done_Glyph( glyph ); @@ -1862,14 +1985,6 @@ namespace OGLFT { init(); } - Polygonal::Polygonal ( const FT_Byte* data_base, const FT_Long data_size, float point_size, FT_UInt resolution) - : Face( data_base, data_size, point_size, resolution ) - { - if ( !isValid() ) return; - - init(); - } - Polygonal::Polygonal ( FT_Face face, float point_size, FT_UInt resolution ) : Face( face, point_size, resolution ) { @@ -1895,11 +2010,11 @@ namespace OGLFT { // they're passed to the GLU tessellation routines. if ( resolution_ != 0 ) - vector_scale_ = ( point_size_ * resolution_ ) / - (float)( faces_.front().face_->units_per_EM * 72 ); + vector_scale_ = (GLdouble)( point_size_ * resolution_ ) / + (GLdouble)( faces_.front().face_->units_per_EM * 72 ); else // According to the FreeType documentation, resolution == 0 -> 72 DPI - vector_scale_ = ( point_size_ ) / - (float)( faces_.front().face_->units_per_EM ); + vector_scale_ = (GLdouble)( point_size_ ) / + (GLdouble)( faces_.front().face_->units_per_EM ); color_tess_ = 0; texture_tess_ = 0; @@ -2024,10 +2139,10 @@ namespace OGLFT { return; vector_scale_ = ( point_size_ * resolution_ ) / - ( 72.f * rotation_reference_face_->units_per_EM ); + ( 72. * rotation_reference_face_->units_per_EM ); rotation_offset_y_ = - ( rotation_reference_face_->glyph->metrics.horiBearingY / 2.f ) / 64.f + ( rotation_reference_face_->glyph->metrics.horiBearingY / 2. ) / 64. * vector_scale_; } @@ -2074,8 +2189,7 @@ namespace OGLFT { bbox = ft_bbox; bbox.advance_ = faces_[f].face_->glyph->advance; - bbox *= - ( point_size_ * resolution_ ) / ( 72.f * faces_[f].face_->units_per_EM ); + bbox *= ( point_size_ * resolution_ ) / ( 72. * faces_[f].face_->units_per_EM ); return bbox; } @@ -2151,14 +2265,6 @@ namespace OGLFT { init(); } - Outline::Outline ( const FT_Byte* data_base, const FT_Long data_size, float point_size, FT_UInt resolution) - : Polygonal( data_base, data_size, point_size, resolution ) - { - if ( !isValid() ) return; - - init(); - } - Outline::Outline ( FT_Face face, float point_size, FT_UInt resolution ) : Polygonal( face, point_size, resolution ) { @@ -2185,23 +2291,22 @@ namespace OGLFT { if ( error != 0 ) return; - FT_Glyph g; + FT_OutlineGlyph g; - error = FT_Get_Glyph( face->glyph, &g ); + error = FT_Get_Glyph( face->glyph, (FT_Glyph*)&g ); - if ( error != 0 || g->format != FT_GLYPH_FORMAT_OUTLINE ) + if ( error != 0 ) return; - vector_scale_ = ( point_size_ * resolution_ ) / - ( 72.f * face->units_per_EM ); + vector_scale_ = ( point_size_ * resolution_ ) / ( 72. * face->units_per_EM ); if ( character_rotation_.active_ ) { glPushMatrix(); - glTranslatef( ( face->glyph->metrics.width / 2.f + - face->glyph->metrics.horiBearingX ) / 64.f + glTranslatef( ( face->glyph->metrics.width / 2. + + face->glyph->metrics.horiBearingX ) / 64. * vector_scale_, rotation_offset_y_, - 0.f ); + 0. ); if ( character_rotation_.x_ != 0. ) glRotatef( character_rotation_.x_, 1., 0., 0. ); @@ -2212,11 +2317,11 @@ namespace OGLFT { if ( character_rotation_.z_ != 0. ) glRotatef( character_rotation_.z_, 0., 0., 1. ); - glTranslatef( -( face->glyph->metrics.width / 2.f + - face->glyph->metrics.horiBearingX ) / 64.f + glTranslatef( -( face->glyph->metrics.width / 2. + + face->glyph->metrics.horiBearingX ) / 64. * vector_scale_, -rotation_offset_y_, - 0.f ); + 0. ); } contour_open_ = false; @@ -2225,8 +2330,7 @@ namespace OGLFT { // the outlines of the font by calling the various routines stored in // outline_interface_. These routines in turn call the GL vertex routines. - error = FT_Outline_Decompose( &((FT_OutlineGlyph)g)->outline, - &interface_, this ); + error = FT_Outline_Decompose( &g->outline, &interface_, this ); FT_Done_Glyph( (FT_Glyph)g ); @@ -2242,9 +2346,9 @@ namespace OGLFT { // Drawing a character always advances the MODELVIEW. - glTranslatef( face->glyph->advance.x / 64.f * vector_scale_, - face->glyph->advance.y / 64.f * vector_scale_, - 0.f ); + glTranslatef( face->glyph->advance.x / 64. * vector_scale_, + face->glyph->advance.y / 64. * vector_scale_, + 0. ); for ( VILI vili = vertices_.begin(); vili != vertices_.end(); vili++ ) delete *vili; @@ -2425,15 +2529,6 @@ namespace OGLFT { init(); } - Filled::Filled ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Polygonal( data_base, data_size, point_size, resolution ) - { - if ( !isValid() ) return; - - init(); - } - Filled::Filled ( FT_Face face, float point_size, FT_UInt resolution ) : Polygonal( face, point_size, resolution ) { @@ -2453,16 +2548,11 @@ namespace OGLFT { tess_obj_ = gluNewTess(); -#if defined(WIN32) - typedef void (CALLBACK*(CB))(); -#else - typedef GLUTessCallback CB; -#endif - gluTessCallback( tess_obj_, GLU_TESS_VERTEX, CB(vertexCallback) ); - gluTessCallback( tess_obj_, GLU_TESS_BEGIN, CB(beginCallback) ); - gluTessCallback( tess_obj_, GLU_TESS_END, CB(endCallback) ); - gluTessCallback( tess_obj_, GLU_TESS_COMBINE_DATA, CB(combineCallback) ); - gluTessCallback( tess_obj_, GLU_TESS_ERROR, CB(errorCallback) ); + gluTessCallback( tess_obj_, GLU_TESS_VERTEX, (GLUTessCallback)vertexCallback ); + gluTessCallback( tess_obj_, GLU_TESS_BEGIN, (GLUTessCallback)beginCallback ); + gluTessCallback( tess_obj_, GLU_TESS_END, (GLUTessCallback)endCallback ); + gluTessCallback( tess_obj_, GLU_TESS_COMBINE_DATA, (GLUTessCallback)combineCallback ); + gluTessCallback( tess_obj_, GLU_TESS_ERROR, (GLUTessCallback)errorCallback ); } Filled::~Filled ( void ) @@ -2477,20 +2567,19 @@ namespace OGLFT { if ( error != 0 ) return; - FT_Glyph g; + FT_OutlineGlyph g; - error = FT_Get_Glyph( face->glyph, &g ); + error = FT_Get_Glyph( face->glyph, (FT_Glyph*)&g ); - if ( error != 0 || g->format != FT_GLYPH_FORMAT_OUTLINE ) + if ( error != 0 ) return; - vector_scale_ = ( point_size_ * resolution_ ) / - ( 72.f * face->units_per_EM ); + vector_scale_ = ( point_size_ * resolution_ ) / ( 72. * face->units_per_EM ); if ( character_rotation_.active_ ) { glPushMatrix(); - glTranslatef( ( face->glyph->metrics.width / 2.f + - face->glyph->metrics.horiBearingX ) / 64.f + glTranslatef( ( face->glyph->metrics.width / 2. + + face->glyph->metrics.horiBearingX ) / 64. * vector_scale_, rotation_offset_y_, 0. ); @@ -2504,11 +2593,11 @@ namespace OGLFT { if ( character_rotation_.z_ != 0. ) glRotatef( character_rotation_.z_, 0., 0., 1. ); - glTranslatef( -( face->glyph->metrics.width / 2.f + - face->glyph->metrics.horiBearingX ) / 64.f + glTranslatef( -( face->glyph->metrics.width / 2. + + face->glyph->metrics.horiBearingX ) / 64. * vector_scale_, -rotation_offset_y_, - 0.f ); + 0. ); } if ( depth_offset_ != 0. ) { @@ -2531,8 +2620,7 @@ namespace OGLFT { // interface_. These routines in turn call the GLU tessellation routines // to create OGL polygons. - error = FT_Outline_Decompose( &((FT_OutlineGlyph)g)->outline, - &interface_, this ); + error = FT_Outline_Decompose( &g->outline, &interface_, this ); FT_Done_Glyph( (FT_Glyph)g ); @@ -2776,15 +2864,6 @@ namespace OGLFT { init(); } - Solid::Solid ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Filled( data_base, data_size, point_size, resolution ) - { - if ( !isValid() ) return; - - init(); - } - Solid::Solid ( FT_Face face, float point_size, FT_UInt resolution ) : Filled( face, point_size, resolution ) { @@ -2881,7 +2960,7 @@ namespace OGLFT { // are defined counter-clockwise. Trust the flag set by FreeType to // indicate this since it is critical to getting the orientation of the // surface normals correct. - if ( g->outline.flags & ft_outline_reverse_fill ) { + if ( g->outline.flags & FT_OUTLINE_REVERSE_FILL ) { extrusion_.normal_sign_.x_ = -1; extrusion_.normal_sign_.y_ = 1; } @@ -3158,15 +3237,6 @@ namespace OGLFT { init(); } - Texture::Texture ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Face( data_base, data_size, point_size, resolution ) - { - if ( !isValid() ) return; - - init(); - } - Texture::Texture ( FT_Face face, float point_size, FT_UInt resolution ) : Face( face, point_size, resolution ) { @@ -3262,7 +3332,7 @@ namespace OGLFT { if ( error != 0 ) return; - rotation_offset_y_ = rotation_reference_face_->glyph->bitmap.rows / 2.f; + rotation_offset_y_ = rotation_reference_face_->glyph->bitmap.rows / 2.; } BBox Texture::measure ( unsigned char c ) @@ -3388,39 +3458,39 @@ namespace OGLFT { if ( character_rotation_.active_ ) { glPushMatrix(); - glTranslatef( ( texture_info.width_ / 2.f + + glTranslatef( ( texture_info.width_ / 2. + texture_info.left_bearing_ ), - rotation_offset_y_, 0.f ); + rotation_offset_y_, 0. ); if ( character_rotation_.x_ != 0. ) - glRotatef( character_rotation_.x_, 1.f, 0.f, 0.f ); + glRotatef( character_rotation_.x_, 1., 0., 0. ); if ( character_rotation_.y_ != 0. ) - glRotatef( character_rotation_.y_, 0.f, 1.f, 0.f ); + glRotatef( character_rotation_.y_, 0., 1., 0. ); if ( character_rotation_.z_ != 0. ) - glRotatef( character_rotation_.z_, 0.f, 0.f, 1.f ); + glRotatef( character_rotation_.z_, 0., 0., 1. ); - glTranslatef( -( texture_info.width_ / 2.f + + glTranslatef( -( texture_info.width_ / 2. + texture_info.left_bearing_ ), - -rotation_offset_y_, 0.f ); + -rotation_offset_y_, 0. ); } glBegin( GL_QUADS ); glTexCoord2i( 0, 0 ); - glVertex2i( texture_info.left_bearing_, texture_info.bottom_bearing_ ); + glVertex2f( texture_info.left_bearing_, texture_info.bottom_bearing_ ); - glTexCoord2f( texture_info.texture_s_, 0.f ); - glVertex2i( texture_info.left_bearing_ + texture_info.width_, + glTexCoord2f( texture_info.texture_s_, 0. ); + glVertex2f( texture_info.left_bearing_ + texture_info.width_, texture_info.bottom_bearing_ ); glTexCoord2f( texture_info.texture_s_, texture_info.texture_t_ ); - glVertex2i( texture_info.left_bearing_ + texture_info.width_, + glVertex2f( texture_info.left_bearing_ + texture_info.width_, texture_info.bottom_bearing_ + texture_info.height_ ); - glTexCoord2f( 0.f, texture_info.texture_t_ ); - glVertex2i( texture_info.left_bearing_, + glTexCoord2f( 0., texture_info.texture_t_ ); + glVertex2f( texture_info.left_bearing_, texture_info.bottom_bearing_ + texture_info.height_ ); glEnd(); @@ -3430,8 +3500,8 @@ namespace OGLFT { } // Drawing a character always advances the MODELVIEW. - glTranslatef( texture_info.advance_.x / 64.f, - texture_info.advance_.y / 64.f, + glTranslatef( texture_info.advance_.x / 64., + texture_info.advance_.y / 64., 0. ); } @@ -3485,11 +3555,6 @@ namespace OGLFT { : Texture( filename, point_size, resolution ) {} - MonochromeTexture::MonochromeTexture ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Texture( data_base, data_size, point_size, resolution ) - {} - MonochromeTexture::MonochromeTexture ( FT_Face face, float point_size, FT_UInt resolution ) : Texture( face, point_size, resolution ) @@ -3545,7 +3610,7 @@ namespace OGLFT { if ( error != 0 ) return; - error = FT_Render_Glyph( face->glyph, ft_render_mode_mono ); + error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_MONO ); if ( error != 0 ) return; @@ -3598,11 +3663,6 @@ namespace OGLFT { : Texture( filename, point_size, resolution ) {} - GrayscaleTexture::GrayscaleTexture ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Texture( data_base, data_size, point_size, resolution ) - {} - GrayscaleTexture::GrayscaleTexture ( FT_Face face, float point_size, FT_UInt resolution ) : Texture( face, point_size, resolution ) @@ -3653,7 +3713,7 @@ namespace OGLFT { if ( error != 0 ) return; - error = FT_Render_Glyph( face->glyph, ft_render_mode_normal ); + error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL ); if ( error != 0 ) return; @@ -3707,11 +3767,6 @@ namespace OGLFT { : Texture( filename, point_size, resolution ) {} - TranslucentTexture::TranslucentTexture ( const FT_Byte* data_base, const FT_Long data_size, - float point_size, FT_UInt resolution ) - : Texture( data_base, data_size, point_size, resolution ) - {} - TranslucentTexture::TranslucentTexture ( FT_Face face, float point_size, FT_UInt resolution ) : Texture( face, point_size, resolution ) @@ -3763,7 +3818,7 @@ namespace OGLFT { if ( error != 0 ) return; - error = FT_Render_Glyph( face->glyph, ft_render_mode_normal ); + error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL ); if ( error != 0 ) return; diff --git a/engine/libraries/oglft/tests/Demo3UnicodeExample.h b/engine/libraries/oglft/tests/Demo3UnicodeExample.h index a4277ea..887c2ba 100644 --- a/engine/libraries/oglft/tests/Demo3UnicodeExample.h +++ b/engine/libraries/oglft/tests/Demo3UnicodeExample.h @@ -1,7 +1,7 @@ /* * Demo3UnicodeExample.h: Sample font for demo3 example. * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: Demo3UnicodeExample.h,v 1.2 2002/07/11 20:56:06 allen Exp $ * * 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 diff --git a/engine/libraries/oglft/tests/demo.cpp b/engine/libraries/oglft/tests/demo.cpp index ed71f59..a3126ef 100644 --- a/engine/libraries/oglft/tests/demo.cpp +++ b/engine/libraries/oglft/tests/demo.cpp @@ -1,7 +1,7 @@ /* * demo.cpp: Demo of the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: demo.cpp,v 1.4 2002/07/11 20:58:38 allen Exp $ * * 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 @@ -20,8 +20,13 @@ #include #include #include +using namespace std; + #include +#ifdef HAVE_CONFIG_H +#include +#endif #include static const char* USAGE = " fontfile"; @@ -49,11 +54,12 @@ static OGLFT::TranslucentTexture* translucent_texture_face; static float dy; static int viewport_width; static int viewport_height; +static int x_rot, y_rot, z_rot; -static void init ( int /*argc*/, char* argv[] ) +static void init ( int argc, char* argv[] ) { - std::cout << glGetString( GL_VENDOR ) << " " << glGetString( GL_RENDERER ) << " " - << glGetString( GL_VERSION ) << std::endl; + cout << glGetString( GL_VENDOR ) << " " << glGetString( GL_RENDERER ) << " " + << glGetString( GL_VERSION ) << endl; commands_face = new OGLFT::Monochrome( argv[1], point_size / 2. ); commands_face->setHorizontalJustification( OGLFT::Face::CENTER ); @@ -63,7 +69,7 @@ static void init ( int /*argc*/, char* argv[] ) monochrome_face->setForegroundColor( 1., 0., 0., 1. ); if ( !monochrome_face->isValid() ) { - std::cerr << "failed to open face. exiting." << std::endl; + cerr << "failed to open face. exiting." << endl; exit( 1 ); } @@ -112,7 +118,7 @@ static void init ( int /*argc*/, char* argv[] ) // Set various general parameters which don't affect performance (yet). glClearColor( .75, .75, .75, 1. ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); -#if defined(GL_RASTER_POSITION_UNCLIPPED_IBM) +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); #endif glEnable( GL_LIGHT0 ); @@ -309,7 +315,12 @@ static void display ( void ) glutSwapBuffers(); } -static void key ( unsigned char key, int /*x*/, int /*y*/ ) +static void idle ( void ) +{ + glutPostRedisplay(); +} + +static void key ( unsigned char key, int x, int y ) { switch ( key ) { case 'a': @@ -355,7 +366,7 @@ static void done ( void ) int main ( int argc, char* argv[] ) { if ( argc != 2 ) { - std::cerr << argv[0] << USAGE << std::endl; + cerr << argv[0] << USAGE << endl; return 1; } @@ -371,7 +382,9 @@ int main ( int argc, char* argv[] ) glutReshapeFunc( reshape ); glutDisplayFunc( display ); glutKeyboardFunc( key ); - +#if 0 + glutIdleFunc( idle ); +#endif glutMainLoop(); return 0; diff --git a/engine/libraries/oglft/tests/demo2.cpp b/engine/libraries/oglft/tests/demo2.cpp index 6b48259..cbbb920 100644 --- a/engine/libraries/oglft/tests/demo2.cpp +++ b/engine/libraries/oglft/tests/demo2.cpp @@ -1,7 +1,7 @@ /* * demo2.cpp: Second Demo of the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: demo2.cpp,v 1.7 2003/10/01 14:04:49 allen Exp $ * * 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 @@ -18,9 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +using namespace std; + +#include #include +#include #include #include FT_MULTIPLE_MASTERS_H @@ -39,7 +43,7 @@ static OGLFT::Monochrome* oglft_face; static int viewport_width; static int viewport_height; -static void init ( int /*argc*/, char* argv[] ) +static void init ( int argc, char* argv[] ) { std::cout << glGetString( GL_VENDOR ) << " " << glGetString( GL_RENDERER ) << " " << glGetString( GL_VERSION ) << std::endl; @@ -74,8 +78,9 @@ static void init ( int /*argc*/, char* argv[] ) oglft_face = new OGLFT::Filled( ft_face, 14 ); #else glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); - +#endif oglft_face = new OGLFT::Monochrome( ft_face, 14 ); #endif oglft_face->setHorizontalJustification( OGLFT::Face::LEFT ); @@ -126,7 +131,7 @@ static void display ( void ) for ( int j = 0; j <= 4; j++ ) { FT_Set_MM_Design_Coordinates( ft_face, master_info.num_axis, axis_averages ); - snprintf( buffer, sizeof(buffer), " Style at axis = %ld\n", axis_averages[i] ); + snprintf( buffer, sizeof(buffer), " Style at axis = %d\n", axis_averages[i] ); y -= 20.; oglft_face->draw( 0., y, buffer ); @@ -140,7 +145,7 @@ static void display ( void ) glutSwapBuffers(); } -static void key ( unsigned char key, int /*x*/, int /*y*/ ) +static void key ( unsigned char key, int x, int y ) { switch ( key ) { case 'q': @@ -153,6 +158,11 @@ static void key ( unsigned char key, int /*x*/, int /*y*/ ) glutPostRedisplay(); } +static void idle ( void ) +{ + glutPostRedisplay(); +} + static void done ( void ) { } @@ -176,7 +186,9 @@ int main ( int argc, char* argv[] ) glutReshapeFunc( reshape ); glutDisplayFunc( display ); glutKeyboardFunc( key ); - +#if 0 + glutIdleFunc( idle ); +#endif glutMainLoop(); return 0; diff --git a/engine/libraries/oglft/tests/demo3.cpp b/engine/libraries/oglft/tests/demo3.cpp index a7bdb45..47e810b 100644 --- a/engine/libraries/oglft/tests/demo3.cpp +++ b/engine/libraries/oglft/tests/demo3.cpp @@ -1,7 +1,7 @@ /* * demo3.cpp: Third Demo of the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: demo3.cpp,v 1.6 2003/10/01 14:05:08 allen Exp $ * * 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 @@ -19,20 +19,21 @@ */ #include #include +using namespace std; #include #include -#include "OGLFT.h" -#include "vignette.h" -#include "vignette.moc" +#include +#include +#include -#include "Demo3UnicodeExample.h" -#include "Demo3UnicodeExample2.h" +#include +#include class Vignette0 : public Vignette { - static const unsigned int FRAME_COUNT = 32; + static const unsigned int FRAME_COUNT = 33; static const unsigned int FRAME_RATE = 16; const char* text_; @@ -583,7 +584,9 @@ public: std::cout << "Vignette 5" << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_LIGHT0 ); } @@ -946,13 +949,15 @@ public: { std::cout << "Vignette 8" << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif glPushAttrib( GL_POLYGON_BIT ); } void draw ( unsigned int frame_number ) { - char save_char = '\0'; + char save_char; if ( frame_number < text_length_ ) { save_char = text_[frame_number]; text_[frame_number] = '\0'; @@ -1177,18 +1182,14 @@ public: face_ = new OGLFT::Translucent( fontfile, 18, 75 ); // Now, create a second face, in this case, using a built-in font. -#if 0 FT_Library library = OGLFT::Library::instance(); FT_Face ft_face; - FT_New_Memory_Face( library, Demo3UnicodeExample_ttf, + int a = FT_New_Memory_Face( library, Demo3UnicodeExample_ttf, Demo3UnicodeExample_ttf_size, 0, &ft_face ); - + cout << "The return value from new mem face is " << a << endl; + cout << "Ft face is " << ft_face << endl; face_->addAuxiliaryFace( ft_face ); -#else - // Somewhat simpler with new interface. - face_->addAuxiliaryFace( Demo3UnicodeExample_ttf, - Demo3UnicodeExample_ttf_size ); -#endif + face_->setForegroundColor( 0., .5, .75 ); // Manually create the equation in UNICODE points @@ -1237,7 +1238,9 @@ public: std::cout << "Vignette 11" << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_BLEND ); } @@ -1251,19 +1254,15 @@ public: glTranslated( left, 0, 0 ); } - void draw ( unsigned int /*frame_number*/ ) + void draw ( unsigned int frame_number ) { face_->setHorizontalJustification( OGLFT::Face::LEFT ); face_->draw( 2., 128., "This frame demonstrates two...no three...features:" ); face_->draw( 2., 96., "1. Drawing a UNICODE string (using Qt's QString)." ); face_->draw( 2., 64., "2. Combining two fonts to cover more UNICODE points." ); face_->draw( 2., 32., "3. Embedding a font in the program." ); - face_->setHorizontalJustification( OGLFT::Face::CENTER ); face_->draw( 250., 0., equation_ ); - - face_->setHorizontalJustification( OGLFT::Face::LEFT ); - face_->draw( 2., -32., "Thanks to Oliver Bock for the font-in-memory code!" ); } void finish ( void ) @@ -1293,7 +1292,7 @@ public: #else face_ = new OGLFT::Filled( fontfile, 18, 75 ); #endif - face_->setForegroundColor( 0., .75, .75 ); + face_->setForegroundColor( 0., .5, .75 ); // Now, create a second face, in this case, using a built-in font. FT_Library library = OGLFT::Library::instance(); @@ -1333,7 +1332,7 @@ public: glTranslated( left, 0, 0 ); } - void draw ( unsigned int /*frame_number*/ ) + void draw ( unsigned int frame_number ) { face_->setVerticalJustification( OGLFT::Face::TOP ); face_->setHorizontalJustification( OGLFT::Face::CENTER ); @@ -1354,7 +1353,7 @@ public: glPushMatrix(); glTranslated( j*42, -i * 18, 0 ); - glColor3f( .25, .25, .25 ); + glColor3f( .5, .5, 0. ); glRectd( bbox.x_min_, bbox.y_min_, bbox.x_max_, bbox.y_max_ ); face_->draw( 0, 0, "%p\"", a ); @@ -1371,7 +1370,7 @@ public: glPushMatrix(); glTranslated( 250.+cosr*24, 96.+sinr*24, 0 ); - glColor3f( .25, .25, .25 ); + glColor3f( .5, .5, 0. ); glRectd( bbox.x_min_, bbox.y_min_, bbox.x_max_, bbox.y_max_ ); face_->draw( 0, 0, "%p\"", 1.015625 ); @@ -1389,7 +1388,7 @@ public: CharacterView::CharacterView ( bool flank_speed, const char* fontfile, QWidget* parent, const char* name ) - : QGLWidget( ), flank_speed_( flank_speed ) + : QGLWidget( parent, name ), flank_speed_( flank_speed ) { vignettes.enqueue( new Vignette0( "Welcome to OGLFT!", fontfile ) ); vignettes.enqueue( new Vignette1( "The OpenGL/FreeType library", fontfile ) ); @@ -1400,7 +1399,7 @@ CharacterView::CharacterView ( bool flank_speed, const char* fontfile, vignettes.enqueue( new Vignette8( "Measuring the text.", fontfile ) ); vignettes.enqueue( new Vignette6( "Per vertex color", fontfile ) ); vignettes.enqueue( new Vignette7( "Per vertex texture coord", fontfile ) ); - vignettes.enqueue( new Vignette10( "Each glyph can have it's own display list", fontfile ) ); + vignettes.enqueue( new Vignette10( "Each glyph can have its own display list", fontfile ) ); vignettes.enqueue( new Vignette11( "QString Example", fontfile ) ); vignettes.enqueue( new Vignette12( "Formatting Numbers", fontfile ) ); vignettes.enqueue( new Vignette4( "OGLFT", fontfile ) ); @@ -1430,7 +1429,7 @@ void CharacterView::redraw ( void ) frame_counter_++; animation_frame_counter_++; - if ( animation_frame_counter_ >= animation_frame_count_ ) { + if ( animation_frame_counter_ == animation_frame_count_ ) { redraw_timer_.stop(); vignettes.current()->finish(); delete vignettes.dequeue(); @@ -1512,10 +1511,6 @@ void CharacterView::keyPressEvent ( QKeyEvent* e ) case Key_Q: case Key_Escape: qApp->exit( 0 ); - case Key_Return: - // "Speed up the harvest." L, Skywalker - animation_frame_counter_ = animation_frame_count_; - updateGL(); } } diff --git a/engine/libraries/oglft/tests/speedtest.cpp b/engine/libraries/oglft/tests/speedtest.cpp index b24a7af..260c1ef 100644 --- a/engine/libraries/oglft/tests/speedtest.cpp +++ b/engine/libraries/oglft/tests/speedtest.cpp @@ -1,7 +1,7 @@ /* * speedtest.cpp: Performance test for the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: speedtest.cpp,v 1.6 2003/10/01 14:08:30 allen Exp $ * * 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 @@ -19,13 +19,15 @@ */ #include #include +using namespace std; #include +#include #include #include "speedtest.h" -#include "speedtest.moc" + class Vignette0 : public Vignette { @@ -35,7 +37,7 @@ class Vignette0 : public Vignette { OGLFT::Face* face_; public: - Vignette0 ( const char* text, const char* /*fontfile*/ ) : text_( text ) + Vignette0 ( const char* text, const char* fontfile ) : text_( text ) { } @@ -46,7 +48,7 @@ public: std::cout << "Vignette 0: Color and depth buffer clearing only" << std::endl; } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { } @@ -75,10 +77,12 @@ public: { std::cout << "Vignette 1: MONOCHROME: immediate drawing: " << text_ << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -108,10 +112,12 @@ public: { std::cout << "Vignette 2: MONOCHROME: cached glyphs: " << text_ << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -144,11 +150,13 @@ public: { std::cout << "Vignette 3: MONOCHROME: display list: " << text_ << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glRasterPos2f( 0., 0. ); glCallList( dlist_ ); @@ -181,10 +189,12 @@ public: { std::cout << "Vignette 4: GRAYSCALE: immediate drawing: " << text_ << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -214,10 +224,12 @@ public: { std::cout << "Vignette 5: GRAYSCALE: cached glyphs: " << text_ << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -249,11 +261,13 @@ public: { std::cout << "Vignette 6: GRAYSCALE: display list: " << text_ << std::endl; glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glPushMatrix(); glRasterPos2f( 0., 0. ); @@ -290,10 +304,12 @@ public: glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -326,10 +342,12 @@ public: glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -364,11 +382,13 @@ public: glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); +#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM ) glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM ); +#endif dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glPushMatrix(); glRasterPos2f( 0., 0. ); @@ -405,7 +425,7 @@ public: std::cout << "Vignette 10: OUTLINE: immediate drawing: " << text_ << std::endl; } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -436,7 +456,7 @@ public: std::cout << "Vignette 11: OUTLINE: cached glyphs: " << text_ << std::endl; } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -471,7 +491,7 @@ public: dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { // glPushMatrix(); glCallList( dlist_ ); @@ -506,7 +526,7 @@ public: std::cout << "Vignette 13: FILLED: immediate drawing: " << text_ << std::endl; } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -537,7 +557,7 @@ public: std::cout << "Vignette 14: FILLED: cached glyphs: " << text_ << std::endl; } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -571,7 +591,7 @@ public: dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glPushMatrix(); glCallList( dlist_ ); @@ -608,7 +628,7 @@ public: glEnable( GL_LIGHT0 ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -642,7 +662,7 @@ public: glEnable( GL_LIGHT0 ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -679,7 +699,7 @@ public: dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glPushMatrix(); glCallList( dlist_ ); @@ -720,7 +740,7 @@ public: glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -755,7 +775,7 @@ public: glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -793,7 +813,7 @@ public: dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glPushMatrix(); glCallList( dlist_ ); @@ -832,7 +852,7 @@ public: glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -867,7 +887,7 @@ public: glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -905,7 +925,7 @@ public: dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glPushMatrix(); glCallList( dlist_ ); @@ -946,7 +966,7 @@ public: glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -984,7 +1004,7 @@ public: glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { face_->draw( 0., 0., text_ ); } @@ -1025,7 +1045,7 @@ public: dlist_ = face_->compile( text_ ); } - void draw ( int /*frame_number*/ ) + void draw ( int frame_number ) { glPushMatrix(); glCallList( dlist_ ); diff --git a/engine/libraries/oglft/tests/speedtest.h b/engine/libraries/oglft/tests/speedtest.h index 4463cbc..508ee08 100644 --- a/engine/libraries/oglft/tests/speedtest.h +++ b/engine/libraries/oglft/tests/speedtest.h @@ -1,7 +1,7 @@ /* -*- c++ -*- * speedtest.h: Header for Performance test for the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: speedtest.h,v 1.2 2002/02/04 19:01:17 allen Exp $ * * 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 diff --git a/engine/libraries/oglft/tests/tutorial1.cpp b/engine/libraries/oglft/tests/tutorial1.cpp index e3c401f..8eb7208 100644 --- a/engine/libraries/oglft/tests/tutorial1.cpp +++ b/engine/libraries/oglft/tests/tutorial1.cpp @@ -1,7 +1,7 @@ /* * tutorial1.cpp: Tutorial for the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: tutorial1.cpp,v 1.5 2003/10/01 14:08:49 allen Exp $ * * 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 @@ -18,9 +18,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +using namespace std; #include - +#include #include // Note: this will depend on where you've installed OGLFT // Declare a Face variable of the desired style diff --git a/engine/libraries/oglft/tests/tutorial2.cpp b/engine/libraries/oglft/tests/tutorial2.cpp index c95a637..755ac39 100644 --- a/engine/libraries/oglft/tests/tutorial2.cpp +++ b/engine/libraries/oglft/tests/tutorial2.cpp @@ -1,7 +1,7 @@ /* * tutorial2.cpp: Tutorial for the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: tutorial2.cpp,v 1.5 2003/10/01 14:09:12 allen Exp $ * * 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 @@ -18,9 +18,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +using namespace std; #include - +#include #include // Note: this will depend on where you've installed OGLFT #define USE_BITMAP_FACE @@ -94,13 +95,11 @@ static void idle ( void ) // it by 4 degrees face->setStringRotation( face->stringRotation() + 4 ); -#if !defined(WIN32) + // Too fast even without acceleration struct timespec request = { 0, 40000000 }; nanosleep( &request, 0 ); -#else - Sleep( 40 ); -#endif + glutPostRedisplay(); } diff --git a/engine/libraries/oglft/tests/tutorial3.cpp b/engine/libraries/oglft/tests/tutorial3.cpp index 9025564..6fafe2d 100644 --- a/engine/libraries/oglft/tests/tutorial3.cpp +++ b/engine/libraries/oglft/tests/tutorial3.cpp @@ -1,7 +1,7 @@ /* * tutorial3.cpp: Tutorial for the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: tutorial3.cpp,v 1.5 2003/10/01 14:09:28 allen Exp $ * * 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 @@ -18,15 +18,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -#if defined(_MSC_VER) -#define _USE_MATH_DEFINES -#endif #include #include #include // The STL vector #include // The STL algorithms -#include +using namespace std; +#include +#include #include // Note: this will depend on where you've installed OGLFT // A Face variable of the desired style @@ -80,8 +79,7 @@ void init ( const char* filename ) // Next, generate a sequence of relative displacements for ( int i=0; i<13; i++ ) { - float dy = AMPLITUDE * ( sinf( (i+1) * 2.f * (float)M_PI / 13.f ) - - sinf( i * 2.f * (float)M_PI / 13.f ) ); + float dy = AMPLITUDE * ( sin( (i+1) * 2 * M_PI / 13 ) - sin( i * 2 * M_PI / 13 ) ); glNewList( dlist, GL_COMPILE ); glTranslatef( 0., dy, 0. ); @@ -95,7 +93,7 @@ void init ( const char* filename ) // Next, generate a sequence of absolute displacements for ( int i=0; i<13; i++ ) { - float y = AMPLITUDE * sinf( i * 2.f * (float)M_PI / 13.f ); + float y = AMPLITUDE * sin( i * 2 * M_PI / 13 ); glNewList( dlist, GL_COMPILE ); glTranslatef( 0., y, 0. ); @@ -129,7 +127,7 @@ void init ( const char* filename ) // Make it (sea) green - solid->setForegroundColor( 143.f/255.f, 188.f/255.f, 143.f/255.f ); + solid->setForegroundColor( 143./255., 188./255., 143./255. ); // Set the window's background color @@ -139,8 +137,8 @@ void init ( const char* filename ) // version of the absolute displacements which we'll cycle through) for ( int i = 0; i <= 52; i++ ) { - float s = sinf( i * 2.f * (float)M_PI / 52.f ); - float c = cosf( i * 2.f * (float)M_PI / 52.f ); + float s = sin( i * 2 * M_PI / 52 ); + float c = cos( i * 2 * M_PI / 52 ); vertex v; v.y = AMPLITUDE * s; v.nx = c; @@ -165,7 +163,7 @@ static void display ( void ) solid->draw( 250., 250., "Hello, World!" ); - glTranslatef( 254.f - ( bbox.x_max_ + bbox.x_min_ ) / 2.f, 255.f, 0.f ); + glTranslatef( 254.- ( bbox.x_max_ + bbox.x_min_ ) / 2., 255., 0. ); glBegin( GL_QUAD_STRIP ); @@ -204,10 +202,10 @@ static void reshape ( int width, int height ) // (note we rotate the model instead of the view so that the lighting // is fixed relative to the view instead of the model) - glTranslatef( width/2.f, height/2.f, 0.f ); - glRotatef( 25.f, 1.f, 0.f, 0.f ); - glRotatef( 25.f, 0.f, 1.f, 0.f ); - glTranslatef( -width/2.f, -height/2.f, 0. ); + glTranslatef( width/2, height/2, 0. ); + glRotatef( 25., 1., 0., 0. ); + glRotatef( 25., 0., 1., 0. ); + glTranslatef( -width/2, -height/2, 0. ); } static void idle ( void ) @@ -234,19 +232,15 @@ static void idle ( void ) solid->characterDisplayLists()[0] = solid->characterDisplayLists()[13+1]; glutPostRedisplay(); -#if !defined(WIN32) + // Too fast even without acceleration struct timespec request = { 0, 80000000 }; nanosleep( &request, 0 ); -#else - Sleep( 800 ); -#endif } -static void key ( unsigned char c, int /*x*/, int /*y*/ ) +static void key ( unsigned char c, int x, int y ) { switch ( c ) { - case 'q': case 27: exit( 0 ); } diff --git a/engine/libraries/oglft/tests/vignette.h b/engine/libraries/oglft/tests/vignette.h index 3809d80..9ebcf2b 100644 --- a/engine/libraries/oglft/tests/vignette.h +++ b/engine/libraries/oglft/tests/vignette.h @@ -1,7 +1,7 @@ /* -*- c++ -*- * speedtest.h: Header for Performance test for the OGLFT library * Copyright (C) 2002 lignum Computing, Inc. - * $Id$ + * $Id: vignette.h,v 1.2 2002/02/04 19:01:23 allen Exp $ * * 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 @@ -22,16 +22,9 @@ #include -#if OGLFT_QT_VERSION == 3 #include #include #include -#elif OGLFT_QT_VERSION == 4 -#include -#include -#include -#include -#endif // Little animation vignettes. The function calls essentially follow // those of the Qt OpenGL widget and are called at the corresponding times. @@ -74,11 +67,8 @@ Q_OBJECT unsigned int animation_frame_counter_; static const unsigned int PERFORMANCE_SAMPLE_RATE_HZ = 1; -#if OGLFT_QT_VERSION == 3 + QQueue vignettes; -#elif OGLFT_QT_VERSION == 4 - QQueue vignettes; -#endif protected slots: void redraw ( void );