windowed/fullscreen fix

This commit is contained in:
James Turk 2005-11-15 02:59:08 +00:00
parent ea8ba7d458
commit 4fb8e96267
15 changed files with 55 additions and 51 deletions

View File

@ -1,11 +1,13 @@
Changelog for Photon Changelog for Photon
$Id: CHANGELOG.txt,v 1.13 2005/11/13 07:59:48 cozman Exp $ $Id: CHANGELOG.txt,v 1.14 2005/11/15 02:59:08 cozman Exp $
! : Major Changes (potentially breaking existing code) ! : Major Changes (potentially breaking existing code)
+ : New Features + : New Features
* : Minor Changes (bugfixes and behind-the-scenes changes) * : Minor Changes (bugfixes and behind-the-scenes changes)
0.1.0 0.1.0
! Changed createDisplay to use an enum to set fullscreen/windowed mode.
* Added first official tutorial.
* Major documentation sweep, much more useful for casual users. Also fixed * Major documentation sweep, much more useful for casual users. Also fixed
tons of documentation mismatches. tons of documentation mismatches.
* Fixed bug where app would hang if run() was called with no active state or * Fixed bug where app would hang if run() was called with no active state or

View File

@ -5,7 +5,7 @@
# James Turk (jpt2433@rit.edu) # James Turk (jpt2433@rit.edu)
# #
# Version: # Version:
# $Id: SConstruct,v 1.24 2005/11/13 07:59:48 cozman Exp $ # $Id: SConstruct,v 1.25 2005/11/15 02:59:08 cozman Exp $
import os,os.path import os,os.path
import glob import glob
@ -96,7 +96,7 @@ env.Default(LIBRARY)
# Documentation # Documentation
ndoc = env.Command('docs/index.html', './include', ndoc = env.Command('docs/index.html', './include',
"""NaturalDocs -nag -i $SOURCES -i ndoc/pages -o HTML ./docs -p ./ndoc""") """NaturalDocs -nag -i $SOURCES -i ndoc/pages -i ndoc/tutorials -o HTML ./docs -p ./ndoc""")
env.Alias("docs",ndoc) env.Alias("docs",ndoc)
env.AlwaysBuild(ndoc) env.AlwaysBuild(ndoc)
@ -112,9 +112,3 @@ for test_src in test_srcs:
'physfs','corona','freetype'])) 'physfs','corona','freetype']))
env.Alias('tests',tests) env.Alias('tests',tests)
# Visual C++ Projects
#if(os.name == 'nt'):
# msvc = env.MSVSProject(target = 'msvc/photon' + env['MSVSPROJECTSUFFIX'],
# srcs = getFilesMulti(SRC_DIRS, '*.cpp'), incs = INC_FILES,
# buildtarget = lib, variant = 'Release')
# env.Alias('msvc',msvc)

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Application.hpp,v 1.23 2005/11/13 07:59:48 cozman Exp $ // $Id: Application.hpp,v 1.24 2005/11/15 02:59:08 cozman Exp $
#ifndef PHOTON_APPLICATION_HPP #ifndef PHOTON_APPLICATION_HPP
#define PHOTON_APPLICATION_HPP #define PHOTON_APPLICATION_HPP
@ -105,12 +105,13 @@ public:
// alphaBits - desired bits per pixel for alpha value // alphaBits - desired bits per pixel for alpha value
// depthBits - desired bitdepth of depth buffer // depthBits - desired bitdepth of depth buffer
// stencilBits - desired bitdepth of stencil buffer // stencilBits - desired bitdepth of stencil buffer
// fullscreen - true: fullscreen, false: windowed // fullscreen - <DisplayMode>, DISP_FULLSCREEN or DISP_WINDOWED
// [title - title of application, optional] // [title - title of application, optional]
void createDisplay(uint width, uint height, void createDisplay(uint width, uint height,
uint redBits, uint greenBits, uint blueBits, uint redBits, uint greenBits, uint blueBits,
uint alphaBits, uint depthBits, uint stencilBits, uint alphaBits, uint depthBits, uint stencilBits,
bool fullscreen, const std::string& title="Photon App"); DisplayMode mode,
const std::string& title="Photon App");
// Function: createDisplay // Function: createDisplay
// This function attempts to create a display with the given parameters. // This function attempts to create a display with the given parameters.
@ -123,10 +124,10 @@ public:
// bpp - desired bits per pixel (aka bitdepth) of display // bpp - desired bits per pixel (aka bitdepth) of display
// depthBits - desired bitdepth of depth buffer // depthBits - desired bitdepth of depth buffer
// stencilBits - desired bitdepth of stencil buffer // stencilBits - desired bitdepth of stencil buffer
// fullscreen - true: fullscreen, false: windowed // fullscreen - <DisplayMode>, DISP_FULLSCREEN or DISP_WINDOWED
// [title - title of application, optional] // [title - title of application, optional]
void createDisplay(uint width, uint height, uint bpp, void createDisplay(uint width, uint height, uint bpp,
uint depthBits, uint stencilBits, bool fullscreen, uint depthBits, uint stencilBits, DisplayMode mode,
const std::string& title="Photon App"); const std::string& title="Photon App");
// Function: setTitle // Function: setTitle

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: entrypoint.hpp,v 1.10 2005/08/16 06:32:39 cozman Exp $ // $Id: entrypoint.hpp,v 1.11 2005/11/15 02:59:08 cozman Exp $
#ifndef PHOTON_ENTRYPOINT_HPP #ifndef PHOTON_ENTRYPOINT_HPP
@ -33,7 +33,7 @@
// Application& app(Application::getInstance); // Application& app(Application::getInstance);
// //
// // create window // // create window
// app.createDisplay(800,600,32,0,0,false); // app.createDisplay(800,600,32,0,0,DISP_WINDOWED);
// //
// // set current state // // set current state
// app.setState<MainMenu>(); // app.setState<MainMenu>();

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: types.hpp,v 1.9 2005/11/13 07:59:48 cozman Exp $ // $Id: types.hpp,v 1.10 2005/11/15 02:59:08 cozman Exp $
#ifndef PHOTON_TYPES_HPP #ifndef PHOTON_TYPES_HPP
#define PHOTON_TYPES_HPP #define PHOTON_TYPES_HPP
@ -330,6 +330,16 @@ enum ScrollDir
SCROLL_UP, SCROLL_DOWN SCROLL_UP, SCROLL_DOWN
}; };
// Enum: DisplayMode
// Enumeration defining types of displays.
//
// DISP_WINDOWED - Windowed Mode
// DISP_FULLSCREEN - Fullscreen Mode
enum DisplayMode
{
DISP_WINDOWED, DISP_FULLSCREEN
};
} }
#endif //PHOTON_TYPES_HPP #endif //PHOTON_TYPES_HPP

View File

@ -43,7 +43,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); app.createDisplay(800,600,32,0,0,DISP_WINDOWED);
app.setState<SomeState>(); app.setState<SomeState>();
app.run(); app.run();
@ -102,7 +102,7 @@ the following two pieces of code produce identical results:
(code) (code)
// Sample 1 : Too Much Typing :( // Sample 1 : Too Much Typing :(
Application::getInstance().createDisplay(800,600,32,0,0,true); Application::getInstance().createDisplay(800,600,32,0,0,DISP_FULLSCREEN);
Application::getInstance().setState<SomeState>(); Application::getInstance().setState<SomeState>();
Application::getInstance().run(); Application::getInstance().run();
(end) (end)
@ -111,7 +111,7 @@ Application::getInstance().run();
(code) (code)
// Sample 2 : Preferred // Sample 2 : Preferred
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,true); app.createDisplay(800,600,32,0,0,DISP_FULLSCREEN);
app.setState<SomeState>(); app.setState<SomeState>();
app.run(); app.run();
(end) (end)
@ -119,7 +119,7 @@ app.run();
<Application> is a fairly important class, it provides the means for managing <Application> is a fairly important class, it provides the means for managing
the display, input, timer, task and state system. For simple 2D applications the display, input, timer, task and state system. For simple 2D applications
the only thing that needs to be done to configure the display is a single call the only thing that needs to be done to configure the display is a single call
to <Application::createDisplay> (width, height, depth, 0, 0, fullscreen, title). to <Application::createDisplay> (width, height, depth, 0, 0, displayMode, title).
The input, timing, and task systems will be addressed in future tutorials, or The input, timing, and task systems will be addressed in future tutorials, or
check them out in <Application's> docs. What about the state system? Well that check them out in <Application's> docs. What about the state system? Well that
brings us to our next topic... brings us to our next topic...
@ -199,7 +199,7 @@ int PhotonMain(const StrVec& args)
Application& app(Application::getInstance()); Application& app(Application::getInstance());
// create the display, in this case a 800x600 window with 32 bit depth // create the display, in this case a 800x600 window with 32 bit depth
app.createDisplay(800,600,32,0,0,false); app.createDisplay(800,600,32,0,0,DISP_WINDOWED);
// set the application state to SomeState (a State-derived class) // set the application state to SomeState (a State-derived class)
app.setState<SomeState>(); app.setState<SomeState>();
@ -256,4 +256,4 @@ if you need specific help try asking for help on the Photon mailing lists
(<http://lists.sourceforge.net/lists/listinfo/photon-users>). (<http://lists.sourceforge.net/lists/listinfo/photon-users>).
Written for Photon 0.1.0 by James: Written for Photon 0.1.0 by James:
$Id: tutorial01.txt,v 1.2 2005/11/14 20:14:18 cozman Exp $ $Id: tutorial01.txt,v 1.3 2005/11/15 02:59:08 cozman Exp $

View File

@ -8,9 +8,6 @@
<node CREATED="1129352407402" ID="_Freemind_Link_115594103" MODIFIED="1130559303873" TEXT="0.1.0" VSHIFT="-14"> <node CREATED="1129352407402" ID="_Freemind_Link_115594103" MODIFIED="1130559303873" TEXT="0.1.0" VSHIFT="-14">
<font BOLD="true" NAME="SansSerif" SIZE="12"/> <font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node CREATED="1129352407404" ID="_Freemind_Link_1084322991" MODIFIED="1129352407404" TEXT="Publicity"> <node CREATED="1129352407404" ID="_Freemind_Link_1084322991" MODIFIED="1129352407404" TEXT="Publicity">
<node CREATED="1129352407404" ID="_Freemind_Link_482028560" MODIFIED="1129352407404" TEXT="Tutorials">
<node CREATED="1130465655991" ID="Freemind_Link_1572314923" MODIFIED="1130465660152" TEXT="NDocTorials"/>
</node>
<node CREATED="1129352407404" ID="_Freemind_Link_1870184326" MODIFIED="1129352407404" TEXT="example game"> <node CREATED="1129352407404" ID="_Freemind_Link_1870184326" MODIFIED="1129352407404" TEXT="example game">
<node CREATED="1130471560606" ID="Freemind_Link_613629773" MODIFIED="1130471562533" TEXT="tank game"/> <node CREATED="1130471560606" ID="Freemind_Link_613629773" MODIFIED="1130471562533" TEXT="tank game"/>
</node> </node>
@ -60,7 +57,7 @@
</node> </node>
</node> </node>
</node> </node>
<node COLOR="#147f1e" CREATED="1129352407415" ID="_Freemind_Link_438641521" MODIFIED="1129352407415" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.31 2005/11/13 07:59:48 cozman Exp $"> <node COLOR="#147f1e" CREATED="1129352407415" ID="_Freemind_Link_438641521" MODIFIED="1129352407415" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.32 2005/11/15 02:59:08 cozman Exp $">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/> <font ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node> </node>
<node CREATED="1129352407415" ID="_Freemind_Link_853483912" MODIFIED="1129352407415" POSITION="left" TEXT="Current Problems"> <node CREATED="1129352407415" ID="_Freemind_Link_853483912" MODIFIED="1129352407415" POSITION="left" TEXT="Current Problems">

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Application.cpp,v 1.30 2005/10/28 22:12:44 cozman Exp $ // $Id: Application.cpp,v 1.31 2005/11/15 02:59:08 cozman Exp $
#include "Application.hpp" #include "Application.hpp"
@ -185,12 +185,12 @@ bool Application::isActive()
void Application::createDisplay(uint width, uint height, void Application::createDisplay(uint width, uint height,
uint redBits, uint greenBits, uint blueBits, uint redBits, uint greenBits, uint blueBits,
uint alphaBits, uint depthBits, uint stencilBits, uint alphaBits, uint depthBits, uint stencilBits,
bool fullscreen, const std::string &title) DisplayMode mode, const std::string &title)
{ {
GLboolean status; GLboolean status;
status = glfwOpenWindow(width, height, redBits, greenBits, status = glfwOpenWindow(width, height, redBits, greenBits, blueBits,
blueBits, alphaBits, depthBits, stencilBits, alphaBits, depthBits, stencilBits,
fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW); mode == DISP_FULLSCREEN ? GLFW_FULLSCREEN : GLFW_WINDOW);
if(status == GL_FALSE) if(status == GL_FALSE)
{ {
throw APIError("Failed to create display."); throw APIError("Failed to create display.");
@ -216,7 +216,7 @@ void Application::createDisplay(uint width, uint height,
} }
void Application::createDisplay(uint width, uint height, uint bpp, void Application::createDisplay(uint width, uint height, uint bpp,
uint depthBits, uint stencilBits, bool fullscreen, uint depthBits, uint stencilBits, DisplayMode mode,
const std::string &title) const std::string &title)
{ {
// call main version of createDisplay with individual values for rgba bits // call main version of createDisplay with individual values for rgba bits
@ -224,19 +224,19 @@ void Application::createDisplay(uint width, uint height, uint bpp,
{ {
case 8: case 8:
createDisplay(width, height, 3, 3, 2, 0, depthBits, stencilBits, createDisplay(width, height, 3, 3, 2, 0, depthBits, stencilBits,
fullscreen, title); mode, title);
break; break;
case 16: case 16:
createDisplay(width, height, 5, 6, 5, 0, depthBits, stencilBits, createDisplay(width, height, 5, 6, 5, 0, depthBits, stencilBits,
fullscreen, title); mode, title);
break; break;
case 24: case 24:
createDisplay(width, height, 8, 8, 8, 0, depthBits, stencilBits, createDisplay(width, height, 8, 8, 8, 0, depthBits, stencilBits,
fullscreen, title); mode, title);
break; break;
case 32: case 32:
createDisplay(width, height, 8, 8, 8, 8, depthBits, stencilBits, createDisplay(width, height, 8, 8, 8, 8, depthBits, stencilBits,
fullscreen, title); mode, title);
break; break;
default: default:
throw ArgumentException("bpp argument of createDisplay must be " throw ArgumentException("bpp argument of createDisplay must be "

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Audio_test.cpp,v 1.17 2005/08/18 05:59:56 cozman Exp $ // $Id: Audio_test.cpp,v 1.18 2005/11/15 02:59:08 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -186,7 +186,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); // create window app.createDisplay(800,600,32,0,0,DISP_WINDOWED); // create window
app.initAudioCore(); // initialize audio core app.initAudioCore(); // initialize audio core
// be sure to add FPSDisplayTask // be sure to add FPSDisplayTask

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Font_test.cpp,v 1.13 2005/08/17 06:35:56 cozman Exp $ // $Id: Font_test.cpp,v 1.14 2005/11/15 02:59:08 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -51,7 +51,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); // create window app.createDisplay(800,600,32,0,0,DISP_WINDOWED); // create window
// be sure to add FPSDisplayTask // be sure to add FPSDisplayTask
//TaskManager::getInstance().addTask(util::TaskPtr(new FPSDisplayTask())); //TaskManager::getInstance().addTask(util::TaskPtr(new FPSDisplayTask()));

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Image_test.cpp,v 1.13 2005/08/17 06:35:56 cozman Exp $ // $Id: Image_test.cpp,v 1.14 2005/11/15 02:59:08 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -62,7 +62,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); // create window app.createDisplay(800,600,32,0,0,DISP_WINDOWED); // create window
// be sure to add FPSDisplayTask // be sure to add FPSDisplayTask
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Input_test.cpp,v 1.12 2005/08/17 06:35:56 cozman Exp $ // $Id: Input_test.cpp,v 1.13 2005/11/15 02:59:08 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -121,7 +121,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); // create window app.createDisplay(800,600,32,0,0,DISP_WINDOWED); // create window
// be sure to add FPSDisplayTask // be sure to add FPSDisplayTask
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Pen_test.cpp,v 1.10 2005/08/17 06:35:56 cozman Exp $ // $Id: Pen_test.cpp,v 1.11 2005/11/15 02:59:08 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -75,7 +75,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); // create window app.createDisplay(800,600,32,0,0,DISP_WINDOWED); // create window
// be sure to add FPSDisplayTask // be sure to add FPSDisplayTask
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: State_test.cpp,v 1.4 2005/08/16 06:32:39 cozman Exp $ // $Id: State_test.cpp,v 1.5 2005/11/15 02:59:08 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -314,7 +314,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); // create window app.createDisplay(800,600,32,0,0,DISP_WINDOWED); // create window
app.setFixedUpdateStep(true, .01); app.setFixedUpdateStep(true, .01);
// add archives to search path // add archives to search path

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Texture_test.cpp,v 1.11 2005/08/17 06:35:56 cozman Exp $ // $Id: Texture_test.cpp,v 1.12 2005/11/15 02:59:08 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -75,7 +75,7 @@ int PhotonMain(const StrVec& args)
{ {
Application& app(Application::getInstance()); Application& app(Application::getInstance());
app.createDisplay(800,600,32,0,0,false); // create window app.createDisplay(800,600,32,0,0,DISP_WINDOWED); // create window
// be sure to add FPSDisplayTask // be sure to add FPSDisplayTask
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));