Adding the 'subwinfix.patch' patch to set the focus in the Windows code. Includes a demo program. See e-mail from Evan Felix dated 3/17/11 4:22 PM

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@906 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2011-03-18 03:21:56 +00:00
parent c6a776f086
commit eb247de77f
7 changed files with 331 additions and 2 deletions

3
.gitattributes vendored
View File

@ -128,6 +128,9 @@ freeglut/freeglut/progs/demos/spaceball/spaceball_static.dsp -text
freeglut/freeglut/progs/demos/spaceball/vmath.c -text freeglut/freeglut/progs/demos/spaceball/vmath.c -text
freeglut/freeglut/progs/demos/spaceball/vmath.h -text freeglut/freeglut/progs/demos/spaceball/vmath.h -text
freeglut/freeglut/progs/demos/spaceball/vmath.inl -text freeglut/freeglut/progs/demos/spaceball/vmath.inl -text
freeglut/freeglut/progs/demos/subwin/Makefile.am -text
freeglut/freeglut/progs/demos/subwin/subwin.c -text
freeglut/freeglut/progs/demos/subwin/subwin.dsp -text
freeglut/freeglut/src/Makefile.am svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/Makefile.am svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/freeglut_callbacks.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/freeglut_callbacks.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/freeglut_cursor.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/freeglut_cursor.c svn_keywords=Author+Date+Id+Revision

View File

@ -97,5 +97,5 @@ if test "x$enable_debug" = xyes; then
fi fi
# Generate output. # Generate output.
AC_CONFIG_FILES([Makefile doc/Makefile include/GL/Makefile include/Makefile progs/Makefile progs/demos/CallbackMaker/Makefile progs/demos/Fractals/Makefile progs/demos/Fractals_random/Makefile progs/demos/Lorenz/Makefile progs/demos/Makefile progs/demos/One/Makefile progs/demos/shapes/Makefile progs/demos/smooth_opengl3/Makefile progs/demos/spaceball/Makefile src/Makefile]) AC_CONFIG_FILES([Makefile doc/Makefile include/GL/Makefile include/Makefile progs/Makefile progs/demos/CallbackMaker/Makefile progs/demos/Error/Makefile progs/demos/Fractals/Makefile progs/demos/Fractals_random/Makefile progs/demos/Lorenz/Makefile progs/demos/Makefile progs/demos/One/Makefile progs/demos/shapes/Makefile progs/demos/smooth_opengl3/Makefile progs/demos/spaceball/Makefile src/Makefile])
AC_OUTPUT AC_OUTPUT

View File

@ -1,2 +1,2 @@
EXTRA_DIST = demos.dsw EXTRA_DIST = demos.dsw
SUBDIRS = CallbackMaker Fractals Fractals_random Lorenz One shapes smooth_opengl3 spaceball SUBDIRS = CallbackMaker Fractals Fractals_random Lorenz One shapes smooth_opengl3 spaceball subwin

View File

@ -0,0 +1,5 @@
EXTRA_DIST = subwin.c subwin.dsp
noinst_PROGRAMS = subwin
subwin_SOURCES = subwin.c
subwin_LDFLAGS = -export-dynamic ../../../src/lib@LIBRARY@.la
subwin_CFLAGS = -I$(top_srcdir)/include $(X_CFLAGS)

View File

@ -0,0 +1,220 @@
/*! \file subwin.c
\ingroup demos
This program is a test harness for the subwindows
in OpenGLUT. Based Originally on shape.c demo.
\author Written by Evan Felix February 2011
\author Portions Copyright (C) 2004, the OpenGLUT project contributors. <br>
OpenGLUT branched from freeglut in February, 2004.
\image html openglut_subwin.png OpenGLUT Sub Window Demonstration
\include demos/subwin/subwin.c
*/
#include <GL/freeglut.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
/* DUMP MEMORY LEAKS */
#include <crtdbg.h>
#endif
#define MAXSTR 16
char **strings;
int mainwin;
/*!
Does printf()-like work using freeglut/OpenGLUT
glutBitmapString(). Uses a fixed font. Prints
at the indicated row/column position.
Limitation: Cannot address pixels.
Limitation: Renders in screen coords, not model coords.
*/
static void shapesPrintf (int row, int col, const char *fmt, ...)
{
static char buf[256];
int viewport[4];
void *font = GLUT_BITMAP_9_BY_15;
va_list args;
va_start(args, fmt);
#if defined(WIN32) && !defined(__CYGWIN__)
(void) _vsnprintf (buf, sizeof(buf), fmt, args);
#else
(void) vsnprintf (buf, sizeof(buf), fmt, args);
#endif
va_end(args);
glGetIntegerv(GL_VIEWPORT,viewport);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,viewport[2],0,viewport[3],-1,1);
glRasterPos2i
(
glutBitmapWidth(font, ' ') * col,
- glutBitmapHeight(font) * (row+2) + viewport[3]
);
glutBitmapString (font, (unsigned char*)buf);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
/* GLUT callback Handlers */
static void
resize(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//gluOrtho2D(0, width, 0, height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
}
static void display(void)
{
int win = glutGetWindow();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3d(1,0,0);
glDisable(GL_LIGHTING);
glColor3d(0.1,0.1,0.4);
if (win == mainwin) {
shapesPrintf (2, 3, "Move The mounse into different windows");
shapesPrintf (3, 3, "pressing keys will add to the string");
}
shapesPrintf (5, 3, "Window: %d", win);
shapesPrintf (6, 3, "String: %s", strings[win]);
glutSwapBuffers();
}
static void
key(unsigned char key, int x, int y)
{
char *s,str[2];
int win = glutGetWindow();
switch (key)
{
case 27 :
case 'Q':
case 'q': glutLeaveMainLoop () ; break;
default:
s=strings[win];
if (strlen(s)+1>MAXSTR) {
s[0]=0;
}
str[0]=key;
str[1]=0;
strcat(s,str);
break;
}
glutPostRedisplay();
}
static void special (int key, int x, int y)
{
switch (key)
{
default:
break;
}
glutPostRedisplay();
}
static void
entry(int state)
{
int win = glutGetWindow();
printf("Win: %d, state: %d\n",win,state);
}
/* Program entry point */
int
main(int argc, char *argv[])
{
int winmax,sw1,sw2,i;
glutInitWindowSize(640,480);
glutInitWindowPosition(40,40);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);
glutCreateWindow("OpenGLUT Sub Windows");
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutEntryFunc(entry);
glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ) ;
glClearColor(1,1,1,1);
mainwin = glutGetWindow();
winmax=mainwin;
sw1=glutCreateSubWindow(mainwin,4,240,314,236);
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutEntryFunc(entry);
glClearColor(0.7,0.7,0.7,1);
winmax = sw1 > winmax ? sw1 : winmax;
sw2=glutCreateSubWindow(mainwin,328,240,314,236);
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutEntryFunc(entry);
glClearColor(0.7,0.7,0.7,1);
winmax = sw2 > winmax ? sw2 : winmax;
strings = malloc(sizeof(char *)*(winmax+1));
for (i=0;i<winmax+1;i++) {
strings[i] = malloc(sizeof(char)*MAXSTR+1);
strings[i][0]=0;
}
glutMainLoop();
#ifdef _MSC_VER
/* DUMP MEMORY LEAK INFORMATION */
_CrtDumpMemoryLeaks () ;
#endif
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,100 @@
# Microsoft Developer Studio Project File - Name="subwin" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=subwin - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "subwin.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "subwin.mak" CFG="subwin - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "subwin - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "subwin - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "subwin - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../../../Release"
!ELSEIF "$(CFG)" == "subwin - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../Debug"
!ENDIF
# Begin Target
# Name "subwin - Win32 Release"
# Name "subwin - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\subwin.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -1921,6 +1921,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
fgUpdateMenuHighlight( window->ActiveMenu ); fgUpdateMenuHighlight( window->ActiveMenu );
break; break;
} }
SetFocus(window->Window.Handle);
fgState.Modifiers = fghGetWin32Modifiers( ); fgState.Modifiers = fghGetWin32Modifiers( );