Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish Project3,Bo Zhang, all the details are written in readme, including a video link. #3

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2d26aed
Begin
wulinjiansheng Oct 1, 2014
4973828
Finish diffuse and specular
wulinjiansheng Oct 2, 2014
4a87372
Add fresnel reflection and refraction
wulinjiansheng Oct 3, 2014
4b03667
Finish OBJ reader and thrust stream compaction
wulinjiansheng Oct 5, 2014
9c674dc
Finally finish texture map, add MAP attribute
wulinjiansheng Oct 5, 2014
5255ddf
Add DOF,motion blur, 'half' of bump map
wulinjiansheng Oct 7, 2014
1689cf0
Delete readings,going to write readme
wulinjiansheng Oct 7, 2014
5318e96
Update README.md
wulinjiansheng Oct 7, 2014
3d18b96
Update README.md
wulinjiansheng Oct 7, 2014
bf73721
Update README.md
wulinjiansheng Oct 7, 2014
3c77ee4
Update README.md
wulinjiansheng Oct 7, 2014
e998ce3
Update README.md
wulinjiansheng Oct 7, 2014
b6ad0fb
Update README.md
wulinjiansheng Oct 7, 2014
34604e0
Update README.md
wulinjiansheng Oct 7, 2014
b03a646
Update README.md
wulinjiansheng Oct 7, 2014
bb47ba9
Update README.md
wulinjiansheng Oct 7, 2014
26613ed
Update README.md
wulinjiansheng Oct 7, 2014
5ce63aa
Update README.md
wulinjiansheng Oct 7, 2014
b801e8a
Update README.md
wulinjiansheng Oct 7, 2014
d70cc43
Update README.md
wulinjiansheng Oct 7, 2014
87594ee
Update README.md
wulinjiansheng Oct 7, 2014
540db17
Update README.md
wulinjiansheng Oct 7, 2014
28f24a9
Update README.md
wulinjiansheng Oct 7, 2014
6c66722
Update README.md
wulinjiansheng Oct 7, 2014
03fff80
Update README.md
wulinjiansheng Oct 7, 2014
230f90f
Update README.md
wulinjiansheng Oct 7, 2014
89197e3
Update README.md
wulinjiansheng Oct 7, 2014
c2cde66
Update README.md
wulinjiansheng Oct 7, 2014
2c5d5dc
Update README.md
wulinjiansheng Oct 7, 2014
a99c8c7
Update README.md
wulinjiansheng Oct 7, 2014
ea80c5b
Update README.md
wulinjiansheng Oct 7, 2014
0a9a3ac
Update README.md
wulinjiansheng Oct 7, 2014
4893589
Update README.md
wulinjiansheng Oct 7, 2014
c554a52
Update README.md
wulinjiansheng Oct 7, 2014
37fd03c
Update README.md
wulinjiansheng Oct 7, 2014
1f59c0c
Change some bugs and add SSAA pics
wulinjiansheng Oct 7, 2014
d013e08
Update README.md
wulinjiansheng Oct 7, 2014
37b058d
chang pic
wulinjiansheng Oct 7, 2014
a56bc6f
Update README.md
wulinjiansheng Oct 7, 2014
749aac8
Update README.md
wulinjiansheng Oct 8, 2014
ef1514d
Update README.md
wulinjiansheng Oct 8, 2014
f03a1ef
Update README.md
wulinjiansheng Oct 8, 2014
247e7dc
Update README.md
wulinjiansheng Oct 8, 2014
530780c
Update README.md
wulinjiansheng Oct 8, 2014
94d6880
Add Performance Evaluation picture
wulinjiansheng Oct 8, 2014
4c999c1
Update README.md
wulinjiansheng Oct 8, 2014
d277cd2
Finish Porject 3
wulinjiansheng Oct 8, 2014
8f1a3b9
Add FPS
wulinjiansheng Dec 7, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Performance Evaluation.bmp
Binary file not shown.
Binary file added Performance Evaluation.xlsx
Binary file not shown.
518 changes: 248 additions & 270 deletions README.md

Large diffs are not rendered by default.

Binary file added external/lib/win/FreeImage/FreeImage.dll
Binary file not shown.
Binary file added external/lib/win/FreeImage/FreeImage.lib
Binary file not shown.
1,104 changes: 1,104 additions & 0 deletions src/FreeImage.h

Large diffs are not rendered by default.

Binary file added src/FreeImage.lib
Binary file not shown.
113 changes: 113 additions & 0 deletions src/clock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@

#ifndef __MMC_CLOCK_H__
#define __MMC_CLOCK_H__

#include "timer.h"

namespace mmc
{

/*! \brief High precision clock for timing events.

This class is implemented on top of the Timer class. Usually it is
not necessary to use the Timer class directly; instead, use this
class. */
class Clock
{
public:
/*! Construct a clock. */
inline Clock ();

/*! Reset the clock (0 time elapsed). */
inline void reset ();

/*! Call once per frame to update the internal clock state. */
inline void inc ();

/*! Returns the amount of time (in ms) elapsed between last
two calls to \p inc(). */
inline long queryInc () const;

/*! Returns the amount of time (in ms) elapsed since clock creation or
reset() was called. */
inline long queryTime () const;

/*! Pause the clock. */
inline void pauseToggle ();

private:
Timer *timer_;
MMC_TIME_TYPE inc_;
MMC_TIME_TYPE curTime_;
MMC_TIME_TYPE start_;
bool paused_;
double invFreq_;
};

//////////////////////////////////////////////////////////////////////
// Implementation.
//

inline
Clock::Clock ()
: paused_(false)
{
timer_ = new Timer;
invFreq_ = timer_->getInvFreq();
timer_->start();
reset();
}

void
Clock::reset ()
{
start_ = timer_->queryElapsed();
inc_ = curTime_ = 0;
}

void
Clock::inc ()
{
timer_->inc();
if (!paused_)
{
inc_ = timer_->queryInc();
curTime_ += inc_;
}
else
{
inc_ = 0;
}
}

// Converts internal clock increment to long in milliseconds.
long
Clock::queryInc () const
{
return (long) (1000.0 * inc_ * invFreq_);
}

// Converts internal clock time to long in milliseconds.
long
Clock::queryTime () const
{
return (long) (1000.0 * curTime_ * invFreq_);
}

void
Clock::pauseToggle ()
{
if (paused_)
{
paused_ = false;
}
else
{
paused_ = true;
inc_ = 0;
}
}

} // namespace mmc

#endif // __MMC_CLOCK_H__
57 changes: 57 additions & 0 deletions src/fps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "fps.h"
#include "clock.h"

using namespace mmc;

FpsTracker::FpsTracker (int smoothSteps)
: steps_(smoothSteps), nSnaps_(0)
{
clock_ = new Clock;
snaps_ = new long[steps_];
memset(snaps_, 0, sizeof(long) * steps_);
}

FpsTracker::~FpsTracker ()
{
delete snaps_;
delete clock_;
}

void
FpsTracker::timestamp ()
{
clock_->inc();
snaps_[nSnaps_ % steps_] = clock_->queryInc();
nSnaps_++;
}

float
FpsTracker::fpsAverage () const
{
int count = (nSnaps_ < steps_) ? nSnaps_ : steps_;
long sum = 0L;
for (int i = 0; i < count; ++i)
{
sum += snaps_[i];
}
if (!sum) sum = 1L; // prevent div-by-zero
return 1000.0f * count / (float) sum;
}

float
FpsTracker::fpsInstant () const
{
long inc = clock_->queryInc();
if (!inc) inc = 1L; // prevent div-by-zero
return 1000.0f / (float) inc;
}

void
FpsTracker::setNumSteps (int smoothSteps)
{
steps_ = smoothSteps;
delete snaps_;
snaps_ = new long[steps_];
memset(snaps_, 0, sizeof(long) * steps_);
nSnaps_ = 0;
}
54 changes: 54 additions & 0 deletions src/fps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

/*! \file fps.h
\brief Defines a class for keeping track of frames/sec.
\author Eric Chan
\date July 2003
*/

#ifndef __MMC_FPS_H__
#define __MMC_FPS_H__

#include <vector>

namespace mmc
{
class Clock;

/*! \brief Utility class for measuring framerate. */
class FpsTracker
{
public:
/*! Create a FpsTracker. \p smoothSteps is the window size
over which to average the time measurements. */
FpsTracker (int smoothSteps = 4);

/*! Deallocate a FpsTracker. */
~FpsTracker ();

/*! Specify the window size \p smoothSteps over which the time
measurements will be averaged. */
void setNumSteps (int smoothSteps);

/*! Makes a timestamp (i.e. takes a snapshot); measures
time intervals between successful calls. Usually, you want
to call this function once per rendering loop. */
void timestamp ();

/*! Get the average FPS (averaged over \p smoothSteps
interval). */
float fpsAverage () const;

/*! Get the instantaneous FPS (estimated from the last frame
only). */
float fpsInstant () const;

private:
Clock *clock_;
int steps_;
int nSnaps_;
long *snaps_;
};

} // namespace mmc

#endif // __MMC_FPS_H__
Loading