Input test

This commit is contained in:
James Turk 2005-07-17 06:19:08 +00:00
parent 9d6e8db0cf
commit 9fdbe1f04b
5 changed files with 120 additions and 33 deletions

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: AppCore.hpp,v 1.5 2005/03/15 19:22:07 cozman Exp $ // $Id: AppCore.hpp,v 1.6 2005/07/17 06:19:18 cozman Exp $
#ifndef PHOTON_APPCORE_HPP #ifndef PHOTON_APPCORE_HPP
#define PHOTON_APPCORE_HPP #define PHOTON_APPCORE_HPP
@ -187,8 +187,8 @@ public:
void update(); void update();
private: private:
uint mouseX_; int mouseX_;
uint mouseY_; int mouseY_;
bool active_; bool active_;
bool timerPaused_; bool timerPaused_;
bool unpauseOnActive_; bool unpauseOnActive_;

View File

@ -7,34 +7,12 @@
<font NAME="SansSerif" SIZE="12"/> <font NAME="SansSerif" SIZE="12"/>
<node ID="Freemind_Link_1613164220" TEXT="better SConstruct file"> <node ID="Freemind_Link_1613164220" TEXT="better SConstruct file">
<icon BUILTIN="button_ok"/> <icon BUILTIN="button_ok"/>
<icon BUILTIN="button_ok"/>
</node> </node>
<node ID="Freemind_Link_614612335" TEXT="all stable ZEngine/Nova features"> <node ID="Freemind_Link_614612335" TEXT="all stable ZEngine/Nova features (except music)">
<font NAME="SansSerif" SIZE="12"/> <font NAME="SansSerif" SIZE="12"/>
<node ID="Freemind_Link_1795651487" TEXT="&quot;ResourceManage&quot;ment">
<icon BUILTIN="button_ok"/>
<icon BUILTIN="button_ok"/> <icon BUILTIN="button_ok"/>
</node> </node>
<node ID="Freemind_Link_50716011" TEXT="Texture"> <node ID="Freemind_Link_985678305" TEXT="callbacks for better input handling"/>
<icon BUILTIN="button_ok"/>
<node ID="Freemind_Link_385334177" TEXT="Image">
<icon BUILTIN="button_ok"/>
</node>
<node ID="Freemind_Link_561271163" TEXT="Font">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node ID="Freemind_Link_107267630" TEXT="&quot;Engine&quot;">
<icon BUILTIN="button_ok"/>
</node>
<node ID="Freemind_Link_1045379727" TEXT="Sample">
<icon BUILTIN="button_ok"/>
</node>
<node ID="Freemind_Link_1851655735" TEXT="Music">
<icon BUILTIN="help"/>
<node COLOR="#fa6801" ID="Freemind_Link_1326895357" TEXT="Music likely bumped to 0.2 release"/>
</node>
</node>
<node ID="Freemind_Link_1104675603" TEXT="Tests"> <node ID="Freemind_Link_1104675603" TEXT="Tests">
<node ID="Freemind_Link_288973656" TEXT="Texture"> <node ID="Freemind_Link_288973656" TEXT="Texture">
<icon BUILTIN="button_ok"/> <icon BUILTIN="button_ok"/>
@ -51,7 +29,9 @@
<node ID="Freemind_Link_1961072093" TEXT="Font"> <node ID="Freemind_Link_1961072093" TEXT="Font">
<icon BUILTIN="button_ok"/> <icon BUILTIN="button_ok"/>
</node> </node>
<node COLOR="#000000" ID="Freemind_Link_964892891" TEXT="Input"/> <node COLOR="#000000" ID="Freemind_Link_964892891" TEXT="Input">
<icon BUILTIN="button_ok"/>
</node>
<node ID="Freemind_Link_25725154" TEXT="Audio"> <node ID="Freemind_Link_25725154" TEXT="Audio">
<node COLOR="#000000" ID="Freemind_Link_1981834308" TEXT="integrate playing of &gt;1 sample"/> <node COLOR="#000000" ID="Freemind_Link_1981834308" TEXT="integrate playing of &gt;1 sample"/>
<node COLOR="#000000" ID="Freemind_Link_212747291" TEXT="allow control via keyboard"/> <node COLOR="#000000" ID="Freemind_Link_212747291" TEXT="allow control via keyboard"/>
@ -96,7 +76,7 @@
<node ID="Freemind_Link_1080393911" TEXT="audio:: could using some cleaning"/> <node ID="Freemind_Link_1080393911" TEXT="audio:: could using some cleaning"/>
<node ID="Freemind_Link_632977685" TEXT="make compilation succeed without OpenAL"/> <node ID="Freemind_Link_632977685" TEXT="make compilation succeed without OpenAL"/>
</node> </node>
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.16 2005/07/17 05:38:44 cozman Exp $"> <node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.17 2005/07/17 06:19:08 cozman Exp $">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/> <font ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node> </node>
</node> </node>

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: AppCore.cpp,v 1.8 2005/06/13 05:38:06 cozman Exp $ // $Id: AppCore.cpp,v 1.9 2005/07/17 06:19:18 cozman Exp $
#include "AppCore.hpp" #include "AppCore.hpp"
@ -174,6 +174,8 @@ void AppCore::UpdateTask::update()
// update the display here instead of VideoCore (since it belongs to glfw) // update the display here instead of VideoCore (since it belongs to glfw)
glfwSwapBuffers(); glfwSwapBuffers();
glfwGetMousePos(&mouseX_, &mouseY_);
// keep track of time between frames // keep track of time between frames
secPerFrame_ = curTime-lastUpdate_; secPerFrame_ = curTime-lastUpdate_;
lastUpdate_ = curTime; lastUpdate_ = curTime;

105
test/Input_test.cpp Normal file
View File

@ -0,0 +1,105 @@
//This file is part of Photon (http://photon.sourceforge.net)
//Copyright (C) 2004-2005 James Turk
//
// Author:
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Input_test.cpp,v 1.1 2005/07/17 06:19:18 cozman Exp $
#include "photon.hpp"
using namespace photon;
#include <boost/lexical_cast.hpp>
class MainTask : public Task
{
public:
MainTask() :
Task("MainTask"),
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
{
LogSinkPtr csp( new ConsoleSink("console") );
log.addSink(csp);
video.setOrthoView(800,600);
video::Font::addResource("font","data/FreeMono.ttf",20);
font.open("font");
}
void update()
{
static double t=0;
if(app.getTime() - t > 1.0)
{
app.setTitle("FPS: " +
boost::lexical_cast<std::string>(app.getFramerate()) );
t = app.getTime();
}
static const photon::uint fontHeight(font.getHeight());
photon::uint curHeight(0);
video.clear();
font.beginDraw(0,curHeight) << "Mouse at " << app.getMouseX() << "," <<
app.getMouseY() << " wheel = " << app.getMouseWheelPos() <<
font.endDraw();
curHeight += fontHeight;
if(app.keyPressed(KEY_SPACE))
{
font.drawText(0,curHeight, "Space key is pressed.");
curHeight += fontHeight;
}
if(!app.keyPressed(KEY_RETURN))
{
font.drawText(0,curHeight, "Return key is NOT pressed.");
curHeight += fontHeight;
}
if(app.mouseButtonPressed(MB_LEFT))
{
font.drawText(0,curHeight, "Left mouse button is pressed.");
curHeight += fontHeight;
}
if(app.mouseButtonPressed(MB_MIDDLE))
{
font.drawText(0,curHeight, "Center mouse button is pressed.");
curHeight += fontHeight;
}
if(app.mouseButtonPressed(MB_RIGHT))
{
font.drawText(0,curHeight, "Right mouse button is pressed.");
curHeight += fontHeight;
}
}
private:
video::Font font;
Log log;
AppCore& app;
video::VideoCore& video;
};
class InputTest : public Application
{
public:
int main(const StrVec& args)
{
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
Kernel::getInstance().run();
return 0;
}
};
ENTRYPOINT(InputTest)

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Pen_test.cpp,v 1.1 2005/07/17 05:38:44 cozman Exp $ // $Id: Pen_test.cpp,v 1.2 2005/07/17 06:19:18 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -90,7 +90,7 @@ private:
video::VideoCore& video; video::VideoCore& video;
}; };
class FontTest : public Application class PenTest : public Application
{ {
public: public:
@ -106,4 +106,4 @@ public:
} }
}; };
ENTRYPOINT(FontTest) ENTRYPOINT(PenTest)