* Hopefully I did THIS one right (used 'cvs update' to Merge)

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
This commit is contained in:
sandalle 2003-06-18 22:26:50 +00:00
parent eb6f583bb9
commit 77f40de0ba
10 changed files with 1922 additions and 1546 deletions

View File

@ -136,24 +136,26 @@ October 24, 2002:
(51) Changed "freeglut_state.c" so the "glutGet" calls with window position and size don't move the windows down and to the right one pixel.
*******************************************************************************************
* Changes starting in May 2003
*******************************************************************************************
(52) Implement single-buffered rendering (or its emulation) in Windows.
(53) Implement Eero Pajarre's "GLUT_ICON" code.
(54) Fixes for the window positioning problem.
(55) Fixed a couple of compiler warnings and other bugs. Changed "freeglut_main.c" to remove a compiler warning. Changed "freeglut_structure.c" to set the current window before calling the window closure callback.
(55) Fixed a couple of compiler warnings and other bugs. Changed "freeglut_main.c" to remove a compiler warning. Changed "freeglut_structure.c" to set the current window before calling the window closure callback.
*******************************************************************************************
* Changes on 17 June 2003
* Changes on 17-19 June 2003
*******************************************************************************************
(56) Added glutGetProcAddress()
(56) Added glutGetProcAddress()
(57) Added GLUT_FPS env var.
(58) Implemented Aleksandar Donev's user data changes: added user data fields to window and menu structures and implemented functions to get and set them
(59) Added a "MenuDestroy" callback which sets a function that "freeglut" calls when a menu is destroyed.
(57) Added GLUT_FPS env var.

File diff suppressed because it is too large Load Diff

View File

@ -231,6 +231,13 @@ void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) )
glutCloseFunc( callback );
}
/* A. Donev: Destruction callback for menus */
void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
{
if( fgStructure.Menu == NULL ) return;
fgStructure.Menu->Destroy = callback;
}
/*
* Deprecated version of glutMenuStatusFunc callback setting method
*/

View File

@ -160,7 +160,12 @@ static struct name_address_pair glut_functions[] = {
{ "glutLeaveMainLoop", (void *) glutLeaveMainLoop },
{ "glutCloseFunc", (void *) glutCloseFunc },
{ "glutWMCloseFunc", (void *) glutWMCloseFunc },
{ "glutSetOption ", (void *) glutSetOption },
{ "glutMenuDestroyFunc", (void *) glutMenuDestroyFunc },
{ "glutSetOption", (void *) glutSetOption },
{ "glutSetWindowData", (void *) glutSetWindowData },
{ "glutGetWindowData", (void *) glutGetWindowData },
{ "glutSetMenuData", (void *) glutSetMenuData },
{ "glutGetMenuData", (void *) glutGetMenuData },
{ "glutBitmapHeight", (void *) glutBitmapHeight },
{ "glutStrokeHeight", (void *) glutStrokeHeight },
{ "glutBitmapString", (void *) glutBitmapString },

View File

@ -28,13 +28,6 @@
#ifndef FREEGLUT_INTERNAL_H
#define FREEGLUT_INTERNAL_H
/*
* Be sure to update these for every release!
*/
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_PATCH 0
/*
* Freeglut is meant to be available under all Unix/X11 and Win32 platforms.
*/
@ -126,8 +119,6 @@ typedef void (* FGCBmotion )( int, int );
typedef void (* FGCBpassive )( int, int );
typedef void (* FGCBentry )( int );
typedef void (* FGCBwindowStatus )( int );
typedef void (* FGCBmenuState )( int );
typedef void (* FGCBmenuStatus )( int, int, int );
typedef void (* FGCBselect )( int, int, int );
typedef void (* FGCBjoystick )( unsigned int, int, int, int );
typedef void (* FGCBkeyboardUp )( unsigned char, int, int );
@ -147,6 +138,8 @@ typedef void (* FGCBdestroy )( void );
*/
typedef void (* FGCBidle )( void );
typedef void (* FGCBtimer )( int );
typedef void (* FGCBmenuState )( int );
typedef void (* FGCBmenuStatus )( int, int, int );
/*
* The callback used when creating/using menus
@ -386,9 +379,11 @@ typedef struct tagSFG_Menu SFG_Menu;
struct tagSFG_Menu
{
SFG_Node Node;
void *UserData ; /* A. Donev: User data passed back at callback */
int ID; /* The global menu ID */
SFG_List Entries; /* The menu entries list */
FGCBmenu Callback; /* The menu callback */
FGCBdestroy Destroy; /* A. Donev: Destruction callback */
GLboolean IsActive; /* Is the menu selected? */
int Width; /* Menu box width in pixels */
int Height; /* Menu box height in pixels */
@ -422,6 +417,7 @@ struct tagSFG_Window
SFG_Context Window; /* Window and OpenGL context */
SFG_WindowState State; /* The window state */
SFG_WindowCallbacks Callbacks; /* The window callbacks */
void *UserData ; /* A. Donev: A pointer to user data used in rendering */
SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */
SFG_Menu* ActiveMenu; /* The window's active menu */

View File

@ -204,20 +204,20 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
* Have the menu box drawn first. The +- values are
* here just to make it more nice-looking...
*/
glColor4f( 0.0, 0.0, 0.0, 1.0 );
glColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
glBegin( GL_QUADS );
glVertex2f( menu->X , menu->Y - 1 );
glVertex2f( menu->X + menu->Width, menu->Y - 1 );
glVertex2f( menu->X + menu->Width, menu->Y + 4 + menu->Height );
glVertex2f( menu->X , menu->Y + 4 + menu->Height );
glVertex2i( menu->X , menu->Y - 1 );
glVertex2i( menu->X + menu->Width, menu->Y - 1 );
glVertex2i( menu->X + menu->Width, menu->Y + 4 + menu->Height );
glVertex2i( menu->X , menu->Y + 4 + menu->Height );
glEnd();
glColor4f( 0.3, 0.4, 0.5, 1.0 );
glColor4f( 0.3f, 0.4f, 0.5f, 1.0f );
glBegin( GL_QUADS );
glVertex2f( menu->X - 2 , menu->Y + 1 );
glVertex2f( menu->X - 2 + menu->Width, menu->Y + 1 );
glVertex2f( menu->X - 2 + menu->Width, menu->Y + 2 + menu->Height );
glVertex2f( menu->X - 2 , menu->Y + 2 + menu->Height );
glVertex2i( menu->X - 2 , menu->Y + 1 );
glVertex2i( menu->X - 2 + menu->Width, menu->Y + 1 );
glVertex2i( menu->X - 2 + menu->Width, menu->Y + 2 + menu->Height );
glVertex2i( menu->X - 2 , menu->Y + 2 + menu->Height );
glEnd();
/*
@ -241,12 +241,12 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
/*
* So have the highlight drawn...
*/
glColor4f( 0.2, 0.3, 0.4, 1.0 );
glColor4f( 0.2f, 0.3f, 0.4f, 1.0f );
glBegin( GL_QUADS );
glVertex2f( menu->X - 2 , menu->Y + (menuID + 0)*FREEGLUT_MENU_HEIGHT + 1 );
glVertex2f( menu->X - 2 + menu->Width, menu->Y + (menuID + 0)*FREEGLUT_MENU_HEIGHT + 1 );
glVertex2f( menu->X - 2 + menu->Width, menu->Y + (menuID + 1)*FREEGLUT_MENU_HEIGHT + 2 );
glVertex2f( menu->X - 2 , menu->Y + (menuID + 1)*FREEGLUT_MENU_HEIGHT + 2 );
glVertex2i( menu->X - 2 , menu->Y + (menuID + 0)*FREEGLUT_MENU_HEIGHT + 1 );
glVertex2i( menu->X - 2 + menu->Width, menu->Y + (menuID + 0)*FREEGLUT_MENU_HEIGHT + 1 );
glVertex2i( menu->X - 2 + menu->Width, menu->Y + (menuID + 1)*FREEGLUT_MENU_HEIGHT + 2 );
glVertex2i( menu->X - 2 , menu->Y + (menuID + 1)*FREEGLUT_MENU_HEIGHT + 2 );
glEnd();
}
}
@ -844,4 +844,17 @@ void FGAPIENTRY glutDetachMenu( int button )
fgStructure.Window->Menu[ button ] = NULL;
}
/*
* A.Donev: Set and retrieve the menu's user data
*/
void* FGAPIENTRY glutGetMenuData( void )
{
return(fgStructure.Menu->UserData);
}
void FGAPIENTRY glutSetMenuData(void* data)
{
fgStructure.Menu->UserData=data;
}
/*** END OF FILE ***/

View File

@ -252,6 +252,7 @@ void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
/*
* If the programmer defined a destroy callback, call it
* A. Donev: But first make this the active window
*/
if ( window->Callbacks.Destroy != NULL )
{
@ -358,6 +359,18 @@ void fgDestroyMenu( SFG_Menu* menu )
fghRemoveMenuFromMenu( from, menu );
}
/*
* If the programmer defined a destroy callback, call it
* A. Donev: But first make this the active menu
*/
if ( menu->Destroy != NULL )
{
SFG_Menu *activeMenu=fgStructure.Menu;
fgStructure.Menu = menu;
menu->Destroy () ;
fgStructure.Menu = activeMenu;
}
/*
* Now we are pretty sure the menu is not used anywhere
* and that we can remove all of its entries

View File

@ -80,7 +80,9 @@
#include "../include/GL/freeglut.h"
#include "freeglut_internal.h"
#ifdef TARGET_HOST_WIN32
#pragma warning ( once:4305 )
#endif
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
@ -166,7 +168,7 @@ static void teapot( GLint grid, GLdouble scale, GLenum type )
glPushMatrix();
glRotatef(270.0, 1.0, 0.0, 0.0);
glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
glScaled(0.5 * scale, 0.5 * scale, 0.5 * scale);
glTranslatef(0.0, 0.0, -1.5);
for (i = 0; i < 10; i++) {

View File

@ -555,12 +555,10 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
if ( !isSubWindow )
{
/*
* Update the window position and dimensions, taking account of window decorations
* Update the window dimensions, taking account of window decorations.
* "freeglut" is to create the window with the outside of its border at (x,y)
* and with dimensions (w,h).
*/
x -= (GetSystemMetrics( SM_CXSIZEFRAME ) );
y -= (GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) );
if ( y < 0 ) y = 0 ;
w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 + GetSystemMetrics( SM_CYCAPTION );
}
@ -1030,8 +1028,8 @@ void FGAPIENTRY glutReshapeWindow( int width, int height )
/*
* Adjust the size of the window to allow for the size of the frame
*/
width += (GetSystemMetrics( SM_CXSIZEFRAME ) - 1)*2;
height += (GetSystemMetrics( SM_CYSIZEFRAME ) - 1)*2 + GetSystemMetrics( SM_CYCAPTION );
width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION );
}
else /* This is a subwindow, get the parent window's position and subtract it off */
{
@ -1078,16 +1076,6 @@ void FGAPIENTRY glutPositionWindow( int x, int y )
*/
GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
if ( fgStructure.Window->Parent == NULL ) /* If this is not a subwindow ... */
{
/*
* Adjust the position of the window to allow for the size of the frame
*/
x -= (GetSystemMetrics( SM_CXSIZEFRAME ) - 1);
y -= (GetSystemMetrics( SM_CYSIZEFRAME ) - 1 + GetSystemMetrics( SM_CYCAPTION ));
if ( y < 0 ) y = 0 ;
}
/*
* Reposition the window, forcing a redraw to happen
*/
@ -1176,6 +1164,19 @@ void FGAPIENTRY glutFullScreen( void )
);
}
/*
* A.Donev: Set and retrieve the window's user data
*/
void* FGAPIENTRY glutGetWindowData( void )
{
return(fgStructure.Window->UserData);
}
void FGAPIENTRY glutSetWindowData(void* data)
{
fgStructure.Window->UserData=data;
}
/*** END OF FILE ***/

View File

@ -47,12 +47,6 @@
#define GLUT_WINDOW_BORDER_WIDTH 0x01FA
#define GLUT_WINDOW_HEADER_HEIGHT 0x01FB
/*
* Runtime version checking with glutGet
*/
#define GLUT_VERSION 0x01FC
/*
* Process loop function, see freeglut_main.c
*/
@ -64,11 +58,18 @@ FGAPI void FGAPIENTRY glutLeaveMainLoop( void );
*/
FGAPI void FGAPIENTRY glutCloseFunc( void (* callback)( void ) );
FGAPI void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) );
/* A. Donev: Also a destruction callback for menus */
FGAPI void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) );
/*
* State setting and retrieval functions, see freeglut_state.c
*/
FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value ) ;
/* A.Donev: User-data manipulation */
FGAPI void* FGAPIENTRY glutGetWindowData( void );
FGAPI void FGAPIENTRY glutSetWindowData(void* data);
FGAPI void* FGAPIENTRY glutGetMenuData( void );
FGAPI void FGAPIENTRY glutSetMenuData(void* data);
/*
* Font stuff, see freeglut_font.c