From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- examples/opengl/gear/README | 4 + examples/opengl/gear/gear.cpp | 296 ++++++++++++++++++++++++++++++++++++++++++ examples/opengl/gear/gear.doc | 11 ++ examples/opengl/gear/gear.pro | 12 ++ 4 files changed, 323 insertions(+) create mode 100644 examples/opengl/gear/README create mode 100644 examples/opengl/gear/gear.cpp create mode 100644 examples/opengl/gear/gear.doc create mode 100644 examples/opengl/gear/gear.pro (limited to 'examples/opengl/gear') diff --git a/examples/opengl/gear/README b/examples/opengl/gear/README new file mode 100644 index 000000000..15f55e77d --- /dev/null +++ b/examples/opengl/gear/README @@ -0,0 +1,4 @@ + +The gear example + +This example program demonstrates how to use OpenGL display lists. diff --git a/examples/opengl/gear/gear.cpp b/examples/opengl/gear/gear.cpp new file mode 100644 index 000000000..843f56384 --- /dev/null +++ b/examples/opengl/gear/gear.cpp @@ -0,0 +1,296 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ +// +// Draws a gear. +// +// Portions of this code have been borrowed from Brian Paul's Mesa +// distribution. +// + +#include +#include +#include + +#if defined(Q_CC_MSVC) +#pragma warning(disable:4305) // init: truncation from const double to float +#endif + +/* + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth ) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth/2.0; + r2 = outer_radius + tooth_depth/2.0; + + const double pi = 3.14159264; + da = 2.0*pi / teeth / 4.0; + + glShadeModel( GL_FLAT ); + + glNormal3f( 0.0, 0.0, 1.0 ); + + /* draw front face */ + glBegin( GL_QUAD_STRIP ); + for (i=0;i<=teeth;i++) { + angle = i * 2.0*pi / teeth; + glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); + glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 ); + glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); + glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 ); + } + glEnd(); + + /* draw front sides of teeth */ + glBegin( GL_QUADS ); + da = 2.0*pi / teeth / 4.0; + for (i=0;i= 2 ) { + bool ok = TRUE; + timer_interval = TQString::fromLatin1( argv[1] ).toInt( &ok ); + if ( !ok ) + timer_interval = 10; + } + + GearWidget w; + a.setMainWidget( &w ); + w.show(); + return a.exec(); +} diff --git a/examples/opengl/gear/gear.doc b/examples/opengl/gear/gear.doc new file mode 100644 index 000000000..2fe049a93 --- /dev/null +++ b/examples/opengl/gear/gear.doc @@ -0,0 +1,11 @@ +/*! \page opengl-gear-example.html + + \ingroup opengl-examples + \title OpenGL Gear Example + + +This example demonstrates how to use OpenGL display lists. + +See \c{$QTDIR/examples/opengl/gear} for the source code. + +*/ diff --git a/examples/opengl/gear/gear.pro b/examples/opengl/gear/gear.pro new file mode 100644 index 000000000..b91691cba --- /dev/null +++ b/examples/opengl/gear/gear.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = gear + +CONFIG += qt opengl warn_on release +CONFIG -= dlopen_opengl +!mac:unix:LIBS += -lm +DEPENDPATH = ../include + +REQUIRES = opengl + +HEADERS = +SOURCES = gear.cpp -- cgit v1.2.1