major tests (alpha)
This commit is contained in:
parent
00f73521a3
commit
42faa7adae
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Source.hpp,v 1.1 2005/07/05 06:44:56 cozman Exp $
|
||||
// $Id: Source.hpp,v 1.2 2005/07/17 07:14:09 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_AUDIO_SOURCE_HPP
|
||||
#define PHOTON_AUDIO_SOURCE_HPP
|
||||
@ -251,7 +251,7 @@ void Source<ResMgrT>::rewind()
|
||||
template<class ResMgrT>
|
||||
void Source<ResMgrT>::setLooping(bool loop)
|
||||
{
|
||||
alSourcefv(sourceID_, AL_LOOPING, loop);
|
||||
alSourcei(sourceID_, AL_LOOPING, loop);
|
||||
}
|
||||
|
||||
template<class ResMgrT>
|
||||
|
@ -5,13 +5,14 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Font.hpp,v 1.4 2005/07/04 03:06:48 cozman Exp $
|
||||
// $Id: Font.hpp,v 1.5 2005/07/17 07:14:09 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_VIDEO_FONT_HPP
|
||||
#define PHOTON_VIDEO_FONT_HPP
|
||||
|
||||
#include "video/FontResourceManager.hpp"
|
||||
#include "ResourceManaged.hpp"
|
||||
#include "video/Color.hpp"
|
||||
|
||||
namespace photon
|
||||
{
|
||||
@ -74,6 +75,22 @@ public:
|
||||
Font& operator=(const Font &rhs);
|
||||
operator bool() const;
|
||||
|
||||
// Group: Coloring
|
||||
public:
|
||||
// Function: setColor
|
||||
// Set draw color of the font.
|
||||
//
|
||||
// Parameters:
|
||||
// color - <Color> to shade font glyphs when drawn.
|
||||
void setColor(const Color& color);
|
||||
|
||||
// Function: getColor
|
||||
// Get draw color of the font.
|
||||
//
|
||||
// Returns:
|
||||
// Currently set <Color> to shade font glyphs when drawn.
|
||||
Color getColor() const;
|
||||
|
||||
// Group: Drawing
|
||||
public:
|
||||
void drawText(float x, float y, const char *str, ...) const;
|
||||
@ -120,6 +137,8 @@ private:
|
||||
std::ostringstream ss_;
|
||||
float drawX_;
|
||||
float drawY_;
|
||||
// color
|
||||
Color color_;
|
||||
};
|
||||
|
||||
}
|
||||
|
13
photon.mm
13
photon.mm
@ -8,11 +8,17 @@
|
||||
<node ID="Freemind_Link_1613164220" TEXT="better SConstruct file">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node ID="Freemind_Link_614612335" TEXT="all stable ZEngine/Nova features (except music)">
|
||||
<node ID="Freemind_Link_614612335" TEXT="all stable ZEngine/Nova features ">
|
||||
<font NAME="SansSerif" SIZE="12"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node ID="Freemind_Link_642651361" TEXT="Colored fonts">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node ID="Freemind_Link_985678305" TEXT="callbacks for better input handling"/>
|
||||
<node ID="Freemind_Link_485484686" TEXT="Music">
|
||||
<icon BUILTIN="help"/>
|
||||
</node>
|
||||
</node>
|
||||
<node ID="Freemind_Link_1104675603" TEXT="Tests">
|
||||
<node ID="Freemind_Link_288973656" TEXT="Texture">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
@ -33,8 +39,7 @@
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node ID="Freemind_Link_25725154" TEXT="Audio">
|
||||
<node COLOR="#000000" ID="Freemind_Link_1981834308" TEXT="integrate playing of >1 sample"/>
|
||||
<node COLOR="#000000" ID="Freemind_Link_212747291" TEXT="allow control via keyboard"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node ID="Freemind_Link_1348104879" TEXT="Kernel/AppCore">
|
||||
<node ID="Freemind_Link_1664207862" TEXT="how to test?"/>
|
||||
@ -76,7 +81,7 @@
|
||||
<node ID="Freemind_Link_1080393911" TEXT="audio:: could using some cleaning"/>
|
||||
<node ID="Freemind_Link_632977685" TEXT="make compilation succeed without OpenAL"/>
|
||||
</node>
|
||||
<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 $">
|
||||
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.18 2005/07/17 07:14:09 cozman Exp $">
|
||||
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
|
||||
</node>
|
||||
</node>
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Font.cpp,v 1.4 2005/07/04 03:06:48 cozman Exp $
|
||||
// $Id: Font.cpp,v 1.5 2005/07/17 07:14:09 cozman Exp $
|
||||
|
||||
#include "video/Font.hpp"
|
||||
|
||||
@ -71,6 +71,16 @@ Font::operator bool() const
|
||||
return isValid();
|
||||
}
|
||||
|
||||
void Font::setColor(const Color& color)
|
||||
{
|
||||
color_ = color;
|
||||
}
|
||||
|
||||
Color Font::getColor() const
|
||||
{
|
||||
return color_;
|
||||
}
|
||||
|
||||
void Font::drawText(float x, float y, const char *str, ...) const
|
||||
{
|
||||
if(!isValid())
|
||||
@ -85,6 +95,10 @@ void Font::drawText(float x, float y, const char *str, ...) const
|
||||
std::vsnprintf(buf, 1024, str, args); // avoid buffer overflow
|
||||
va_end(args);
|
||||
|
||||
// push attrib before setting color
|
||||
glPushAttrib(GL_CURRENT_BIT);
|
||||
glColor4ub(color_.red, color_.green, color_.blue, color_.alpha);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texID_);
|
||||
glPushMatrix();
|
||||
glTranslated(x,y,0);
|
||||
@ -106,6 +120,7 @@ void Font::drawText(float x, float y, const char *str, ...) const
|
||||
//glCallLists(static_cast<int>(std::strlen(buf)), GL_UNSIGNED_BYTE, buf);
|
||||
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
void Font::drawText(float x, float y, const std::string& str) const
|
||||
@ -115,6 +130,10 @@ void Font::drawText(float x, float y, const std::string& str) const
|
||||
throw PreconditionException("Invalid Font::drawText call.");
|
||||
}
|
||||
|
||||
// push attrib before setting color
|
||||
glPushAttrib(GL_CURRENT_BIT);
|
||||
glColor4ub(color_.red, color_.green, color_.blue, color_.alpha);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texID_);
|
||||
glPushMatrix();
|
||||
glTranslated(x,y,0);
|
||||
@ -136,6 +155,7 @@ void Font::drawText(float x, float y, const std::string& str) const
|
||||
//glCallLists(static_cast<int>(std::strlen(buf)), GL_UNSIGNED_BYTE, buf);
|
||||
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
std::ostream& Font::beginDraw(float x, float y)
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Audio_test.cpp,v 1.1 2005/07/06 02:10:07 cozman Exp $
|
||||
// $Id: Audio_test.cpp,v 1.2 2005/07/17 07:14:09 cozman Exp $
|
||||
|
||||
#include "photon.hpp"
|
||||
using namespace photon;
|
||||
@ -28,29 +28,160 @@ public:
|
||||
log.addSink(csp);
|
||||
|
||||
video.setOrthoView(800,600);
|
||||
|
||||
video::Font::addResource("font","data/FreeMono.ttf",20);
|
||||
font.open("font");
|
||||
|
||||
Sample::addResource("wavdata/ocean.wav");
|
||||
sample.open("wavdata/ocean.wav");
|
||||
sample.play();
|
||||
Sample::addResource("chimes","data/chimes.wav");
|
||||
Sample::addResource("ocean","data/ocean.wav");
|
||||
Sample::addResource("rain","data/rain.wav");
|
||||
Sample::addResource("stream","data/stream.wav");
|
||||
Sample::addResource("thunder","data/thunder.wav");
|
||||
Sample::addResource("waterdrop","data/waterdrop.wav");
|
||||
|
||||
chimes.open("chimes");
|
||||
ocean.open("ocean");
|
||||
rain.open("rain");
|
||||
stream.open("stream");
|
||||
thunder.open("thunder");
|
||||
waterdrop.open("waterdrop");
|
||||
|
||||
chimes.setLooping(true);
|
||||
ocean.setLooping(true);
|
||||
rain.setLooping(true);
|
||||
stream.setLooping(true);
|
||||
thunder.setLooping(true);
|
||||
waterdrop.setLooping(true);
|
||||
|
||||
for(int i=0; i < 6; ++i)
|
||||
status[i] = "NOT ";
|
||||
}
|
||||
|
||||
void checkKeys()
|
||||
{
|
||||
static const std::string NOT_PLAYING = "NOT ";
|
||||
static scalar lastCheck = 0;
|
||||
|
||||
if(app.getTime() - lastCheck > 0.1)
|
||||
{
|
||||
lastCheck = app.getTime();
|
||||
|
||||
if(app.keyPressed(KEY_C))
|
||||
{
|
||||
if(status[0] == NOT_PLAYING)
|
||||
{
|
||||
chimes.play();
|
||||
status[0] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
chimes.stop();
|
||||
status[0] = NOT_PLAYING;
|
||||
}
|
||||
}
|
||||
if(app.keyPressed(KEY_O))
|
||||
{
|
||||
if(status[1] == NOT_PLAYING)
|
||||
{
|
||||
ocean.play();
|
||||
status[1] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
ocean.stop();
|
||||
status[1] = NOT_PLAYING;
|
||||
}
|
||||
}
|
||||
if(app.keyPressed(KEY_R))
|
||||
{
|
||||
if(status[2] == NOT_PLAYING)
|
||||
{
|
||||
rain.play();
|
||||
status[2] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
rain.stop();
|
||||
status[2] = NOT_PLAYING;
|
||||
}
|
||||
}
|
||||
if(app.keyPressed(KEY_S))
|
||||
{
|
||||
if(status[3] == NOT_PLAYING)
|
||||
{
|
||||
stream.play();
|
||||
status[3] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.stop();
|
||||
status[3] = NOT_PLAYING;
|
||||
}
|
||||
}
|
||||
if(app.keyPressed(KEY_T))
|
||||
{
|
||||
if(status[4] == NOT_PLAYING)
|
||||
{
|
||||
thunder.play();
|
||||
status[4] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
thunder.stop();
|
||||
status[4] = NOT_PLAYING;
|
||||
}
|
||||
}
|
||||
if(app.keyPressed(KEY_W))
|
||||
{
|
||||
if(status[5] == NOT_PLAYING)
|
||||
{
|
||||
waterdrop.play();
|
||||
status[5] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
waterdrop.stop();
|
||||
status[5] = NOT_PLAYING;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update()
|
||||
{
|
||||
{
|
||||
static const photon::uint fontHeight(font.getHeight());
|
||||
static double t=0;
|
||||
|
||||
|
||||
if(app.getTime() - t > 1.0)
|
||||
{
|
||||
app.setTitle("FPS: " +
|
||||
boost::lexical_cast<std::string>(app.getFramerate()) );
|
||||
t = app.getTime();
|
||||
}
|
||||
|
||||
|
||||
checkKeys();
|
||||
|
||||
video.clear();
|
||||
|
||||
font.beginDraw(0, 0*fontHeight) << "(C)himes is " << status[0] <<
|
||||
"playing" << font.endDraw();
|
||||
font.beginDraw(0, 1*fontHeight) << "(O)cean is " << status[1] <<
|
||||
"playing" << font.endDraw();
|
||||
font.beginDraw(0, 2*fontHeight) << "(R)ain is " << status[2] <<
|
||||
"playing" << font.endDraw();
|
||||
font.beginDraw(0, 3*fontHeight) << "(S)tream is " << status[3] <<
|
||||
"playing" << font.endDraw();
|
||||
font.beginDraw(0, 4*fontHeight) << "(T)hunder is " << status[4] <<
|
||||
"playing" << font.endDraw();
|
||||
font.beginDraw(0, 5*fontHeight) << "(W)aterdrop is " << status[5] <<
|
||||
"playing" << font.endDraw();
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
audio::Sample sample;
|
||||
video::Font font;
|
||||
audio::Sample chimes, ocean, rain, stream, thunder, waterdrop;
|
||||
std::string status[6];
|
||||
|
||||
Log log;
|
||||
AppCore& app;
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Font_test.cpp,v 1.4 2005/07/04 03:06:48 cozman Exp $
|
||||
// $Id: Font_test.cpp,v 1.5 2005/07/17 07:14:09 cozman Exp $
|
||||
|
||||
#include "photon.hpp"
|
||||
using namespace photon;
|
||||
@ -30,11 +30,12 @@ public:
|
||||
|
||||
video.setOrthoView(800,600);
|
||||
|
||||
video::Font::addResource("font1","data/arial.ttf",32);
|
||||
video::Font::addResource("font2","data/FreeMono.ttf",18);
|
||||
video::Font::addResource("font1","data/FreeMono.ttf",32);
|
||||
video::Font::addResource("font2","data/FreeSerif.ttf",18);
|
||||
|
||||
font.open("font1");
|
||||
font2.open("font2");
|
||||
|
||||
}
|
||||
|
||||
void update()
|
||||
@ -50,10 +51,12 @@ public:
|
||||
|
||||
video.clear();
|
||||
|
||||
font.setColor(video::Color(0,128,128));
|
||||
font.drawText(0, 0, "Photon");
|
||||
font.setColor(video::Color(255,0,0));
|
||||
font.drawText(font.calcStringWidth("Photon"), font.getHeight(),
|
||||
"FPS: %.0f", app.getFramerate() );
|
||||
font2.beginDraw(200, 200) << "another font" << font2.endDraw();
|
||||
font2.beginDraw(200, 200) << "another plain font" << font2.endDraw();
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user