to try it on others; (^&).
Deallocated some resources that we are creating. VERY slight memory leak,
but plugged now.
These two complete the first two "Open issues" ( (a) and (b) ). The first
one also completes X support for glutSetCursor(). If others can verify,
we can fully demote the outstanding bug over this to WIN32-specific.
I'll delete the dead Open issues and re-letter the others if someone will
cross-check me. Or if no one says anything in a day or two. (^&
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@310 7f0cb862-5218-0410-a997-914c9d46530a
good to apply:
* Don't write a == CONST. Instead, write CONST == a. Or, more generally
(in C like languages): Avoid putting an lvalue on the left-hand side of
an == comparison. (For consistancy, I try to avoid lvalues on the left-
hand side of any comparison---but == is the most notorious.)
(An "lvalue" is a value that can safely go on the left side of an
"=" assignment, of course. (^&)
* Do not write
if( !condition )
return;
other_thing;
return;
(See page 18 of K&P's _The Elements of Programming Style_.)
Instead, it is better to just write:
if( condition )
other_thing;
return;
There are times when sacrificing structured programming (e.g., via
multiple return statements) is okay. But, here, there is no apparent
gain---indeed, there seems only loss---in the non-structured code.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@308 7f0cb862-5218-0410-a997-914c9d46530a
reflects that {button} is already shifted to the GLUT numbering, and
hence should be counted as 3&4, 5&6, etc.
The other change was simply to clarify the computation of {direction}.
The original code did some clever arithmetic. The new code is more
straightforward, even if it requires more lines to express.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@306 7f0cb862-5218-0410-a997-914c9d46530a
array-of-pointers). Mostly deleted commented-out struct-based code.
Also added some XXX comments that I though should be pondered. (My
own pair of eyes, and one brain cell, were not sufficient at this time
to decide what to do for those ponderables. (^&)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@304 7f0cb862-5218-0410-a997-914c9d46530a
callback pointers) to a "CallBacks" array in fgState. (This is to allow
us to write a loop to clear all callbacks from windows when the window is
dead/dying. Using this, we can safely assign NULL to each in a loop.)
Support includes two new macros, FETCH_WCB() and INVOKE_WCB(). See
freeglut_internal.h for more details there.
Some typedefs of function pointer types were altered to make them more
uniform (necessary for the macros).
All references to window-based callbacks in freeglut are updated to
use the new macros.
Old usages will cause compile-time errors.
As a side bonus, the new invocation macro sets the current window and
checks pointers so that these common steps can be uniformly done on
every window-based callback. This makes it easier to do things right.
At the same time, the array notation (and now required associated casts)
make it harder to bypass the macros and abuse the function pointers,
in general.
After this commit, I will go through the code and clean up dangling issues
about formatting. This commit is just a "it now works, let's checkpoint it"
type of affair.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@303 7f0cb862-5218-0410-a997-914c9d46530a
a pointer before deallocating some memory.
He also removed one obsolete comment, and added some more comments.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@300 7f0cb862-5218-0410-a997-914c9d46530a
One bug fix from John: Execution state bug-fix in glutMainLoop(), per his
post yesterday.
One fix from me: Changed "if( ButtonPress )" to "if( pressed )".
{ButtonPress} is a constant.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@299 7f0cb862-5218-0410-a997-914c9d46530a
I [John] converted everything to double precision to avoid compiler
warnings. I also added a feature to check for memory leaks under
Windows and removed a memory leak (surprise!).
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@296 7f0cb862-5218-0410-a997-914c9d46530a
Smoothed over some code style issues while I was here, but left the
init-string parsing alone for now.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@292 7f0cb862-5218-0410-a997-914c9d46530a
I believe, checked if *either* a wheel or button callback was set,
and then decided which to use---and unconditionally called it.
I left the "either" check in, but added additional checks before
actually doing the invocation.
* Lots of reformatting. Massive. The usual suspects, though, and fairly
trivial: Re-indenting to standard size, shuffling some spaces to match
the freeglut "standard" of:
if( ... )
...and:
func( ... )
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@285 7f0cb862-5218-0410-a997-914c9d46530a
Flushing the X protocol stack every little bit both adds clutter to the
code and may impede performance.
It seems that we should be able to get rid of these, though
allowing client code to directly call glutMainLoopEvent() does make it
a little more complicated.
Something to ponder.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@279 7f0cb862-5218-0410-a997-914c9d46530a
* Removed TABs.
* Made indentation consistant.
* Deleted say-nothing-new comments.
* Changed an *error*check* from an assert to an if().
(The error-check was on window creation; we don't want to
lose that if the user compiles with asserts deactivated.
Also, assert()s really tell us more about programming errors,
rather than run-time errors, so it is a little misleading to
use assert() for error-checks, even if you can depend upon
assert()s never being compiled away to null statements.)
* Added some XXX comments for things that bear some rumination.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@275 7f0cb862-5218-0410-a997-914c9d46530a
Code facelift included:
* Consistant indentation.
* Removal of all TABs (there were a bunch).
* Fit to 80 columns.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@273 7f0cb862-5218-0410-a997-914c9d46530a
little changes to the code appearance.
* Fit the comments at the start of the file to fit 80 columns.
* Noted an unusual feature of the ATTRIB() macro.
* Added ATTRIB_VAL() macro which is really just two ATTRIB()s.
This lets us put things like {ATTRIB (GLX_RED_SIZE); ATTRIB (1);}
on one statement: {ATTRIB_VAL (GLX_RED_SIZE, 1);}.
I did this to preserve some of the layout of information while also
avoiding the nasty semi-visible ";" in the middle of a line of code.
And by putting the {braces} in the macro definition, I was able to
visually clean code of the form:
if (condition)
{
ATTRIB( X ); ATTRIB( 1 );
}
...rewriting as:
if (condition)
ATTRIB_VAL( X, 1 );
* Eliminated a bunch of say-nothing-new comments in fgChooseVisual().
* Combined some semi-useful comments into a block comment summarizing
a loop.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@272 7f0cb862-5218-0410-a997-914c9d46530a
point of view (at least, insofar as: The original file's code was INCON-
SISTANT. I did not remove the "!= NULL" stuff, did not address the
shortest-branch-first issue for if-else statements, and left some rather
ugly "if (x) {... return y} /* else do this */ return NULL;" garbage.
This should, I think, be re-written as "if (x) return y; else return NULL;"
or even better, "ret = NULL; if (x) ret = y; return ret;"
In short, the code still has some issues, but I think that it's a bit
better.
(Oh, I also got rid of oustanding TABs.)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@271 7f0cb862-5218-0410-a997-914c9d46530a
Fit most of the code to no more than 80 columns.
Raised some issues about completeness/correctness of trying to
decrement the max-window-ID (apparently in order to partially
recycle some window IDs to slightly slow the rate of growth of
window IDs). (I didn't change what the code does, though.)
The functionality of the code should be unchanged.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@270 7f0cb862-5218-0410-a997-914c9d46530a
WIN32 code. Take abs(direction) as the number of ticks, and count it
down.
<stdlib.h> *should* be included by freeglut_internal.h, I think, so it
should be okay; otherwise add a suitable #include.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@268 7f0cb862-5218-0410-a997-914c9d46530a
Now I've lost track of what I said I'd done. Something like:
* Fixed some issues with multiple wheels.
* Noted in comments some issues about other-than-3-real-buttons.
* Fixed formatting to fit 80 columns.
* Removed some BCPL/C++ style comments (//) that are not legal, and
which, if memory servers, are not even strictly legal when disabled
by preprocessor directives. E.g.,
#if 0
not-syntactically-valid-C
#endif
...is not legal. Though most cpp's will discard the bracketed material
completely before the main C compiler pass has a chance to analyze the
syntax. (MSVC++ and GCC both don't seem to mind the BCPL style comments
in plain C, but let's keep the sources clean, eh?)
* Fixed a problem that would have caused freeglut to report doubled
wheel events under XFree86.
Not tested other than compiling. Personally, I think that the interface
is inherently broken at this point unless you are willing to get user-
configuration. (Which would then solve the complaint that Steve had
about computing the tick-size on behalf of applications.) I.e., there
is NO WAY to know if we have the right buttons to start wheels at, or
if there are any buttons after the first wheel(s), etc. We just have to
guess---and if we are wrong, we can get varying degrees of brokeness.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@267 7f0cb862-5218-0410-a997-914c9d46530a
So I've copied the way the game mode does it. It's not ideal but it works.
The glutGet() for the window border sizes will also have to be fixed at
some point.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@266 7f0cb862-5218-0410-a997-914c9d46530a
It now correctly places the window in X11.
It now uses system dependant code for more efficient use of
windowing system calls.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@265 7f0cb862-5218-0410-a997-914c9d46530a
I missed a few lines that went past 80 columns. (^&
Also made formatting more consistant.
Added a couple of XXX comments re. FreeBSD vs. general BSD #ifdef's.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@264 7f0cb862-5218-0410-a997-914c9d46530a
* Fit lines to 80 columns. (It does get tiresome seeing long lines
forced to break by the right-hand border of windows...(^&)
* Eliminated say-nothing-new comments.
* Made formatting more consistant in spots.
* Eliminated some hard TAB characters.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@263 7f0cb862-5218-0410-a997-914c9d46530a
numbers for OS releases corresponding to system headers.
I modified it to also work with NetBSD; I cannot confirm if it is safe with
any other systems, so it remains protected by a #if.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@262 7f0cb862-5218-0410-a997-914c9d46530a
Added some XXX's where comments seemed to require future attention.
Added some new comments with XXX's where future attention seems profitable.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@261 7f0cb862-5218-0410-a997-914c9d46530a
Re-tweaked some lines (mostly got rid of some TABs, but also resulted
in some changed indentation).
Reformatted a big comment to fit to 80 columns.
Removed bogus references to "Linux". (UNIX, and/or X11 were relavent,
and "UNIX/X11" was substituted for "Linux" in those places. This includes
UNIX-alike systems.)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@259 7f0cb862-5218-0410-a997-914c9d46530a
Cleanup of fghGetConfig(). (One return statement, simpler code.)
Made glutSetOption() have a more consistant style---and also got its lines
to stay under 80 columns.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@258 7f0cb862-5218-0410-a997-914c9d46530a
(I would have picked them up before, but wanted the bug-fix and
conversion-to-error-message changes to go in before I did more
superficial stuff.)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@257 7f0cb862-5218-0410-a997-914c9d46530a
((a) || (b)) was defined to have value as:
(a) if (a) != 0
(b) if (a) == 0
...instead, it has value 0/1. This was causing a bug. It's probably
just as well, since what I was trying to do definitely fell into the
category of "clever code" rather than "clear code".
Sorry.
* Made glutSetKeyRepeat() call fgError() if you go out of range. (The
old code silently did nothing---not even a warning.)
If it is really desirable to keep running, we should probably at least
generate an fgWarning().
* Deleted some say-nothing-new comments.
* XXX added: Is glutSetKeyRepeat() deprecated?
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@256 7f0cb862-5218-0410-a997-914c9d46530a
* Removed some say-nothing-useful comments.
* Added some tentative mouse-wheel support.
* Fairly massive reformatting of code.
I made some secondary changes to his changes:
* One compilation error was fixed (missing close-paren + semicolon).
* Deleted a few ore say-nothing-useful comments.
* Some of John's code was strangely formatted to the point that it
seemed completely out of place, so I took the liberty of reformatting
it. Since I used GNU EMACS's <tab> key (which re-indents rather than
inserts TAB characters), I had to propogate some indentation changes
a little further than the bare necessity to match up with John's
changes. (John seems to shoot for 2-space indents, while EMACS
(and I, I confess) strongly prefer 4-space indents. The code that
I was re-indenting had been put to 8-space indents, however.)
I have *not* tested the code beyond compiling. I assume that John did
(and that the compilation error was a result a minor change just before
asking me to commit).
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@255 7f0cb862-5218-0410-a997-914c9d46530a
There should be no alterations to how the code performs.
(I modified how the X11 section of the set-cursor code is indented to
slightly better match (IMHO) the rest of his changes.)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@254 7f0cb862-5218-0410-a997-914c9d46530a
in some cases, the Menu member variable can be NULL.)
Corrected the menu-attach code to make sure that both Window and Menu
pointers are non-NULL (rather than "at least one").
Rewrote button-checks to more simply and more clearly assert that the
"menu button" is a valid button for menu actions: Instead of laboriously
comparing against the three valid buttons (0, 1, 2 or GLUT_BUTTON_*),
we do a simpler range-check and the upper bound is {FREEGLUT_MAX_MENUS},
allowing us to change the number of menuable buttons fairly easily in
the future.
Also deleted a few say-nothing-new comments.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@250 7f0cb862-5218-0410-a997-914c9d46530a
governed menu aesthetics. I think that it's better to have a default
that works than to break completely, should freeglut ever be ported to
a new (non-WIN32, non-UNIX/X11) target.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@248 7f0cb862-5218-0410-a997-914c9d46530a
* Updated an old "TODO BEFORE STABLE" comment.
* Expanded a comment re. some #define macros.
* Made colors and font choice system dependant. The UNIX freeglut
menus look more like UNIX GLUT menus, now. (This is PURELY a
cosmetic change. But it achieves better compatibility visually.)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@247 7f0cb862-5218-0410-a997-914c9d46530a
* Deleted numerous say-nothing-new comments.
* Reformatted a say-something-useful comment to fit on an 80-column
display.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@246 7f0cb862-5218-0410-a997-914c9d46530a
code that really needs to be system-specific is the window event handling,
which in MS-WINDOWS is tucked into a separate function. In UNIX/X11, it's
all spilled out into glutMainLoopEvent() for some reason.
If the X11 code could be tucked into another function, glutMainLoopEvent()
could be platform-independant.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@245 7f0cb862-5218-0410-a997-914c9d46530a
glutMainLoop(), per discussion on the list. The code looks okay,
to me, though I remain less than wholly convinced that treating idles
as special cases is the best way to go. Still, a case can be made
for taking "non-event" idle callbacks out of the "event loop".
From an organizational perspective, I think that it's an improvement,
and it fixes a bug for at least one program.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@244 7f0cb862-5218-0410-a997-914c9d46530a
The lines that he was altering were very oddly-split, so while I was at
it, I repaired the line-break damage.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@243 7f0cb862-5218-0410-a997-914c9d46530a
code was not setting the GLUT window prior to calling callbacks.)
Please verify. If so, this closes out, I think, the latter half of
that bug report, so anyone with the means to modify/close bug reports
should do so upon verification of the fix.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@242 7f0cb862-5218-0410-a997-914c9d46530a
...
/*
* <Enslish recapituation of the single following C statement>
*/
<single C statement>
...and rewrote as:
...
<single C statement>
freeglut_main.c still has a lot of that in it, but it looks a bit
better, now.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@241 7f0cb862-5218-0410-a997-914c9d46530a
Deleted numerous 4-line "padding" sequences of C-as-English trans-
literation comments.
Re-indented some (but not all) code that is using 2-space indentation.
(Most of the freeglut code seems to be using 4-space indentation.)
I did not touch the "INIT DISPLAY STRING PARSING" code, since it is
filled with a ton of over-long lines and also appears to be in more
flux than the rest of the code. (Well, I added one error-check
to a strdup().)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@240 7f0cb862-5218-0410-a997-914c9d46530a
* Got rid of the "rewrite C as English" comments.
* Corrected several bogus references to "carriage returns" (in strings).
The symbols were newlines or EOLs or LFs (\n).
They were *not* carriage returns or CRs (\r).
* Clarified the comments on glBitmap() calls.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@232 7f0cb862-5218-0410-a997-914c9d46530a
Modified the two Fractals* demos so that they only clear (for the random
one) or redraw (for the non-random one) if there is need to do so. (E.g.,
pressing the space bar should not clear and redraw the random fractal since
no parameters are altered.)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@231 7f0cb862-5218-0410-a997-914c9d46530a
Mostly got rid of the say-it-in-English comments that were adding 1 line
of English and 2 or 3 lines of filler for each of several lines of C code.
Updated a couple of other comments, and tweaked some white-space.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@228 7f0cb862-5218-0410-a997-914c9d46530a
(Type NONE is not properly supported, yet.)
Corrected behavior for the several old types:
* Wrong glyphs.
* Reversed glyphs (left/right confusion!)
There are some remaining imperfections, but it's a lot closer to
GLUT comformity, now.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@226 7f0cb862-5218-0410-a997-914c9d46530a
none of them are Earth-shattering, but as I swept through
looking somewhat more systematically for errors, I picked
these off. See the diff's for details.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@225 7f0cb862-5218-0410-a997-914c9d46530a
* glutInit*() calls should preceed glutInit(), per se, generally.
This is so that glutInit()'s configuration (which picks up on user
parameters) can override application defaults.
* glutInit() should be called before ANY attempt to process {argv, argc}.
This is because there may be GLUT/freeglut parameters (such as
"-display" on X11).
* If the window is tall and skinny, rather than short and squat, we need
to handle aspect ratios differently.
The first is a user-interface bug. The second is a serious bug (especially
since the demo assumes that argv[1] contains a filename). The third is a
display bug.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@218 7f0cb862-5218-0410-a997-914c9d46530a
This is done so that subwindows on X11 will get "resize" events when
they are created. Old GLUT did this---presumably by design in order
to ensure that (a) All windows get notified of their size as soon as
the window exists, and (b) probably more importantly, so that windows
and sub-windows behave as much alike as possible. I believe that GLUT
was right to do this, and I believe that compatibility requires this
(I have a sample program that breaks in freeglut but not GLUT without
this fix).
I did not touch the Microsoft side, because I don't know what their
OS does---nor if old GLUT was historically system-dependant about this.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@217 7f0cb862-5218-0410-a997-914c9d46530a
The broad outlines are:
* Color schemes are now in variables, are closer to old GLUT, and
are system dependant (as old GLUT did).
* You can change the font to any bitmapped font more easily, which
can aid in finding a better approximation. (Old GLUT does not seem
to have used a GLUT font for the menus, which causes problems for
us.) The menus rescale automatically, including the triangle "arrow"
for sub-menus.
* Menus have real borders, and the placement of highlighting is
much improved.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@215 7f0cb862-5218-0410-a997-914c9d46530a
Untested, but it compiles for me.
Should also add Joystick support for older FreeBSD systems. Also
untested.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@211 7f0cb862-5218-0410-a997-914c9d46530a
first three can work with menus), in X. This closes a compatibility gap
with old GLUT, and leaves us the option of supporting scroll-wheels
properly.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@210 7f0cb862-5218-0410-a997-914c9d46530a
to sleep, we need to go through ALL windows to check for pending joysticks
and to check for pending redisplays. I was just going through all TOP-
LEVEL windows. Eeek. This won't do.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@205 7f0cb862-5218-0410-a997-914c9d46530a
#ifdef TARGET_HOST_...
to:
#if TARGET_HOST_...
in src/freeglut_init.c. These changes should not have any functional
impact at this time, but you don't want bad examples lying around to
trip people up later.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@203 7f0cb862-5218-0410-a997-914c9d46530a
* GLUT_SINGLE now should behave more or less correctly.
Thanks to Brian Paul!
* Sleeping is now cognizant of outstanding redisplays.
* Fractals_random has been restored more or less to as-before, save that
it uses the more minimal glFlush() rather than glutSwapBuffers().
glutSwapBuffers() was only required when freeglut was incorrectly
handling promotion to double-buffering.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@202 7f0cb862-5218-0410-a997-914c9d46530a
It now rasies the menu windows before showing them.
Move the show to after the reshape and position so we don't get a flash of
the menu window at it's old size and position.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@162 7f0cb862-5218-0410-a997-914c9d46530a
Authors - The first update in quite a while
ChangeLog - Added the recent changes
freeglut_callbacks.c - Added Aleksandar Donev's menu destruction callback
freeglut_internal.h - Added the user data to the structures and made the menu state/status callbacks window-independent
freeglut_menu.c - Removed several OpenGL compiler warnings and added A. Donev's menu user data functions
freeglut_structure.c - Added Aleksandar Donev's menu destruction callback
freeglut_teapot.c - Removed or suppressed several compiler warnings
freeglut_window.c - Updated the window positioning code and added A. Donev's window user data
freeglut_ext.h - Added the menu destruction callback and user data functions
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@79 7f0cb862-5218-0410-a997-914c9d46530a