Fixup fractals demo so it doesn't get way ahead of display - some Linux

OpenGL implementations can queue dozens of frames...

Also fix controls in "flying" mode - the Y axis was reversed.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1907 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-01-03 14:08:08 +00:00
parent 1775984dbe
commit 81be28e2dd
6 changed files with 76 additions and 37 deletions

View File

@ -1,5 +1,10 @@
CHANGES IN FLTK 1.1.0b9
- The fractals demo would get far ahead of the UI with
some Linux OpenGL drivers. Now use glFinish() instead
of glFlush() so we are at most 1 frame ahead.
- The fractals demo Y axis controls were backwards for
the "flying" mode.
- MacOS: cleaned up src/Fl_mac.cxx
- MacOS: fixed Fl::wait(0.0), fixed Cmd-Q handling
- Update CygWin support for Fl::add_fd().

View File

@ -1,5 +1,5 @@
#
# "$Id: Makefile,v 1.19.2.7.2.26 2002/01/01 15:11:32 easysw Exp $"
# "$Id: Makefile,v 1.19.2.7.2.27 2002/01/03 14:08:08 easysw Exp $"
#
# Test/example program makefile for the Fast Light Tool Kit (FLTK).
#
@ -207,9 +207,9 @@ cube$(EXEEXT): cube.o
echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) cube.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@
$(POSTBUILD) $@ ../FL/mac.r
fractals$(EXEEXT): fractals.o
fractals$(EXEEXT): fractals.o fracviewer.o
echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) fractals.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@
$(CXX) -I.. $(CXXFLAGS) fractals.o fracviewer.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@
$(POSTBUILD) $@ ../FL/mac.r
fullscreen$(EXEEXT): fullscreen.o
echo Linking $@...
@ -261,5 +261,5 @@ uninstall:
@echo Nothing to uninstall in test directory.
#
# End of "$Id: Makefile,v 1.19.2.7.2.26 2002/01/01 15:11:32 easysw Exp $".
# End of "$Id: Makefile,v 1.19.2.7.2.27 2002/01/03 14:08:08 easysw Exp $".
#

View File

@ -1,11 +1,11 @@
//
// "$Id: fractals.cxx,v 1.5.2.6.2.3 2002/01/01 15:11:33 easysw Exp $"
// "$Id: fractals.cxx,v 1.5.2.6.2.4 2002/01/03 14:08:08 easysw Exp $"
//
// Fractal drawing demo for the Fast Light Tool Kit (FLTK).
//
// This is a GLUT demo program, with modifications to
// demonstrate how to add fltk controls to a glut program. The glut
// code is unchanged except for the end (search for fltk to find changes).
// demonstrate how to add FLTK controls to a GLUT program. The GLUT
// code is unchanged except for the end (search for FLTK to find changes).
//
// Copyright 1998-2002 by Bill Spitzak and others.
//
@ -63,9 +63,9 @@ int main(int, char**) {
#include <FL/glut.H>
#ifdef __APPLE__
# include <OpenGL/glu.h>
# include <OpenGL/glu.h>
#else
# include <GL/glu.h> // added for fltk
# include <GL/glu.h> // added for FLTK
#endif
#include <stdio.h>
@ -76,14 +76,14 @@ int main(int, char**) {
#include <time.h> /* for random seed */
#include "fracviewer.c" // changed from .h for fltk
#include "fracviewer.h"
#if defined(WIN32) || defined(__EMX__)
# define drand48() (((float) rand())/((float) RAND_MAX))
# define srand48(x) (srand((x)))
# define drand48() (((float) rand())/((float) RAND_MAX))
# define srand48(x) (srand((x)))
#elif defined __APPLE__
# define drand48() (((float) rand())/((float) RAND_MAX))
# define srand48(x) (srand((x)))
# define drand48() (((float) rand())/((float) RAND_MAX))
# define srand48(x) (srand((x)))
#endif
typedef enum { NOTALLOWED, MOUNTAIN, TREE, ISLAND, BIGMTN, STEM, LEAF,
@ -624,7 +624,6 @@ void reshape(int w, int h)
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
@ -645,8 +644,12 @@ void display(void)
if (DrawAxes)
glCallList(AXES);
glutSwapBuffers();
glFlush();
//
// Use glFinish() instead of glFlush() to avoid getting many frames
// ahead of the display (problem with some Linux OpenGL implementations...)
//
glFinish();
}
void visible(int v)
@ -742,7 +745,7 @@ void MenuInit(void)
/**************************** MAIN *****************************/
/***************************************************************/
// fltk-style callbacks to Glut menu callback translators:
// FLTK-style callbacks to Glut menu callback translators:
void setlevel(Fl_Widget*, void *value) {setlevel(long(value));}
void choosefract(Fl_Widget*, void *value) {choosefract(long(value));}
@ -755,9 +758,9 @@ void handlemenu(Fl_Widget*, void *value) {handlemenu(long(value));}
int main(int argc, char** argv)
{
// glutInit(&argc, argv); // this line removed for fltk
// glutInit(&argc, argv); // this line removed for FLTK
// create fltk window:
// create FLTK window:
Fl_Window window(512+20, 512+100);
window.resizable(window);
@ -813,5 +816,5 @@ int main(int argc, char** argv)
#endif
//
// End of "$Id: fractals.cxx,v 1.5.2.6.2.3 2002/01/01 15:11:33 easysw Exp $".
// End of "$Id: fractals.cxx,v 1.5.2.6.2.4 2002/01/03 14:08:08 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
/*
* fractviewer.c [from agviewer.c (version 1.0)]
* fractviewer.cxx [from agviewer.c (version 1.0)]
*
* AGV: a glut viewer. Routines for viewing a 3d scene w/ glut
*
@ -12,12 +12,26 @@
* http://www.cs.hmc.edu/people/pwinston
*/
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <config.h>
#include "fracviewer.h"
#if HAVE_GL && HAVE_GL_GLU_H
# include <FL/glut.h>
# ifdef __APPLE__
# include <OpenGL/glu.h>
# else
# include <GL/glu.h> // added for FLTK
# endif
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <sys/types.h>
# include <time.h>
# if !defined(WIN32) && !defined(__EMX__)
# include <sys/time.h>
# endif // !WIN32 && !__EMX__
# include "fracviewer.h"
/* Some <math.h> files do not define M_PI... */
#ifndef M_PI
@ -133,7 +147,7 @@ int ConstrainEl(void);
void MoveOn(int v);
void SetMove(float newmove);
static void normalize(GLfloat v[3]);
static void ncrossprod(float v1[3], float v2[3], float cp[3]);
void ncrossprod(float v1[3], float v2[3], float cp[3]);
/***************************************************************/
@ -223,7 +237,6 @@ int ConstrainEl(void)
*/
void agvMove(void)
{
switch (MoveMode) {
case FLYING:
Ex += EyeMove*sin(TORAD(EyeAz))*cos(TORAD(EyeEl));
@ -378,7 +391,7 @@ void agvHandleMotion(int x, int y)
switch (downb) {
case GLUT_LEFT_BUTTON:
EyeEl = downEl + EL_SENS * ((MoveMode == FLYING) ? -deltay : deltay);
EyeEl = downEl + EL_SENS * deltay;
ConstrainEl();
EyeAz = downAz + AZ_SENS * deltax;
dAz = PREV_DAZ*dAz + CUR_DAZ*(lastAz - EyeAz);
@ -453,7 +466,7 @@ static void normalize(GLfloat v[3])
}
/* calculates a normalized crossproduct to v1, v2 */
static void ncrossprod(float v1[3], float v2[3], float cp[3])
void ncrossprod(float v1[3], float v2[3], float cp[3])
{
cp[0] = v1[1]*v2[2] - v1[2]*v2[1];
cp[1] = v1[2]*v2[0] - v1[0]*v2[2];
@ -494,3 +507,4 @@ void agvMakeAxesList(int displaylistnum)
}
#endif // HAVE_GL && HAVE_GL_GLU_H

View File

@ -95,6 +95,7 @@ void agvMakeAxesList(int displaylist);
void ncrossprod(float v1[3], float v2[3], float cp[3]);

View File

@ -77,6 +77,11 @@ cube.o: ../FL/Fl_Button.H ../FL/Fl_Radio_Light_Button.H
cube.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H ../FL/Fl_Slider.H
cube.o: ../FL/Fl_Valuator.H ../FL/Fl_Gl_Window.H ../FL/Fl_Window.H ../FL/gl.h
CubeMain.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
CubeMain.o: CubeViewUI.h ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
CubeMain.o: ../FL/Fl_Group.H ../FL/Fl_Roller.H ../FL/Fl_Valuator.H
CubeMain.o: ../FL/Fl_Slider.H ../FL/Fl_Box.H CubeView.h ../FL/Fl_Gl_Window.H
CubeMain.o: ../FL/Fl_Window.H ../FL/gl.h ../FL/Fl_Value_Slider.H
CubeMain.o: ../FL/Fl_Slider.H
CubeView.o: CubeView.h ../config.h ../FL/Fl.H ../FL/Enumerations.H
CubeView.o: ../FL/Fl_Export.H ../FL/Fl_Gl_Window.H ../FL/Fl_Window.H
CubeView.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/gl.h
@ -142,9 +147,8 @@ forms.o: ../FL/Fl_Input.H ../FL/Fl_Menu_Button.H ../FL/Fl_Positioner.H
forms.o: ../FL/Fl_Value_Slider.H ../FL/Fl_Timer.H srs.xbm
fractals.o: ../config.h ../FL/glut.H ../FL/gl.h ../FL/Enumerations.H
fractals.o: ../FL/Fl_Export.H ../FL/Fl.H ../FL/Fl_Gl_Window.H
fractals.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H fracviewer.c
fractals.o: ../GL/glut.h fracviewer.h ../FL/Fl_Button.H ../FL/Fl_Group.H
fractals.o: ../FL/Fl_Window.H
fractals.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H fracviewer.h
fractals.o: ../FL/Fl_Button.H ../FL/Fl_Group.H ../FL/Fl_Window.H
fullscreen.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fullscreen.o: ../FL/Fl_Single_Window.H ../FL/Fl_Window.H ../FL/Fl_Group.H
fullscreen.o: ../FL/Fl_Widget.H ../FL/Fl_Hor_Slider.H ../FL/Fl_Slider.H
@ -192,6 +196,10 @@ input.o: ../FL/Fl_Multiline_Input.H ../FL/Fl_Button.H
input.o: ../FL/Fl_Toggle_Button.H ../FL/Fl_Button.H ../FL/Fl_Color_Chooser.H
input.o: ../FL/Fl_Group.H ../FL/Fl_Box.H ../FL/Fl_Return_Button.H
input.o: ../FL/Fl_Choice.H ../FL/Fl_Value_Input.H ../FL/Fl_Valuator.H
keyboard.o: keyboard_ui.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
keyboard.o: keyboard.h ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
keyboard.o: ../FL/Fl_Button.H ../FL/Fl_Output.H ../FL/Fl_Input_.H
keyboard.o: ../FL/Fl_Box.H ../FL/Fl_Dial.H ../FL/Fl_Valuator.H
label.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
label.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H ../FL/Fl_Group.H
label.o: ../FL/Fl_Widget.H ../FL/Fl_Box.H ../FL/Fl_Hor_Value_Slider.H
@ -203,7 +211,11 @@ line_style.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
line_style.o: ../FL/Fl_Value_Slider.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
line_style.o: ../FL/fl_draw.H ../FL/Fl_Choice.H
list_visuals.o: ../config.h
mandelbrot.o: ../FL/fl_draw.H ../FL/Enumerations.H ../FL/Fl_Export.H
mandelbrot.o: mandelbrot_ui.h ../FL/Fl.H ../FL/Enumerations.H
mandelbrot.o: ../FL/Fl_Export.H mandelbrot.h ../FL/Fl_Box.H ../FL/Fl_Slider.H
mandelbrot.o: ../FL/Fl_Valuator.H ../FL/Fl_Window.H ../FL/Fl_Group.H
mandelbrot.o: ../FL/Fl_Widget.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
mandelbrot.o: ../FL/fl_draw.H
menubar.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Box.H
menubar.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
menubar.o: ../FL/Fl_Menu_Bar.H ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H
@ -273,8 +285,12 @@ shape.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
shape.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
shape.o: ../FL/Fl_Hor_Slider.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
shape.o: ../FL/math.h ../FL/gl.h ../FL/Fl_Gl_Window.H ../FL/Fl_Window.H
shiny.o: ../config.h ../FL/fl_message.H ../FL/fl_ask.H ../FL/Enumerations.H
shiny.o: ../FL/Fl_Export.H ../FL/fl_draw.H ../FL/gl.h
shiny.o: ../config.h shiny_panel.h ../FL/Fl.H ../FL/Enumerations.H
shiny.o: ../FL/Fl_Export.H ../FL/Fl_Window.H ../FL/Fl_Group.H
shiny.o: ../FL/Fl_Widget.H ../FL/Fl_Box.H ../FL/Fl_Group.H ../FL/Fl_Button.H
shiny.o: ../FL/Fl_Value_Slider.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
shiny.o: ../FL/Fl_Slider.H ../FL/fl_message.H ../FL/fl_ask.H ../FL/fl_draw.H
shiny.o: ../FL/gl.h
subwindow.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
subwindow.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
subwindow.o: ../FL/Fl_Toggle_Button.H ../FL/Fl_Button.H