--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual Studio 2010\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Haptic Metronome", "Haptic Metronome\Haptic Metronome.vcxproj", "{46FB682E-53BE-41ED-8EF7-21FCD538023B}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Win32 = Debug|Win32\r
+ Release|Win32 = Release|Win32\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {46FB682E-53BE-41ED-8EF7-21FCD538023B}.Debug|Win32.ActiveCfg = Debug|Win32\r
+ {46FB682E-53BE-41ED-8EF7-21FCD538023B}.Debug|Win32.Build.0 = Debug|Win32\r
+ {46FB682E-53BE-41ED-8EF7-21FCD538023B}.Release|Win32.ActiveCfg = Release|Win32\r
+ {46FB682E-53BE-41ED-8EF7-21FCD538023B}.Release|Win32.Build.0 = Release|Win32\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
#include "Track.hpp"
#include "String.hpp"
#include "Tools.hpp"
+#include <stdint.h>
class MIDIReader
MIDIReader(const MIDIReader &);
FILE *_file;
- uint16 _nbtracks;
- uint16 _timedivision;
+ uint16_t _nbtracks;
+ uint16_t _timedivision;
// unsigned long int _position;
- uint8 readVariableLength(uint32 &);
- void readBytes(void *, uint32);
- void printBytes(uint8 *data, uint32 length);
- uint32 _position;
+ uint8_t readVariableLength(uint32_t &);
+ void readBytes(void *, uint32_t);
+ void printBytes(uint8_t *data, uint32_t length);
+ uint32_t _position;
};
#endif
#include "PrefixTree.hpp"
#ifdef __APPLE__
#include <SDL_mixer/SDL_mixer.h>
+#elif WIN32
+#include <SDL_mixer.h>
#else
#include <SDL/SDL_mixer.h>
#endif
#define __TEXTURE__
#include <GL/glew.h>
+#ifdef WIN32
+#include <SDL.h>
+#else
#include <SDL/SDL.h>
+#endif
// #include <SDL/SDL_opengl.h>
#include "String.hpp"
// void setTempo(uint32 t) { _currenttempo = t; }
// uint32 beatsToTicks(uint32 time) { return (time * _currenttempo * 480) / 60000.0; }
- uint32 beatsToTicks(uint32 time, uint32 tempo) { return (time * tempo * 480) / 60000.0; }
+ uint32 beatsToTicks(uint32 time, uint32 tempo) { return uint32((time * tempo * 480) / 60000.0); }
uint32 ticksToBeats(uint32 time) { return 60000000 / time; }
void displayTracks();
#define __VECTOR2D__
#include "Pair.hpp"
-/*
-#include <iostream>
+
+/*#include <iostream>
using namespace std;*/
template <class T> class Vector2D;
// const Vector2D & operator = (const Vector2D &s);
// bool operator == (const Vector2D &s) const;
- friend Vector2D operator + <>(const Vector2D &p1, const Vector2D &p2);
- friend Vector2D operator + <>(const T &a, const Vector2D &p);
- friend Vector2D operator + <>(const Vector2D &p1, const T &a);
- friend Vector2D operator - <>(const Vector2D &p1, const Vector2D &p2);
- friend Vector2D operator - <>(const T &a, const Vector2D &p);
- friend Vector2D operator - <>(const Vector2D &p1, const T &a);
+ friend Vector2D operator + (const Vector2D &p1, const Vector2D &p2);
+ friend Vector2D operator + (const T &a, const Vector2D &p);
+ friend Vector2D operator + (const Vector2D &p1, const T &a);
+ friend Vector2D operator - (const Vector2D &p1, const Vector2D &p2);
+ friend Vector2D operator - (const T &a, const Vector2D &p);
+ friend Vector2D operator - (const Vector2D &p1, const T &a);
Vector2D operator - (void);
- friend Vector2D operator * <>(const Vector2D &p1, const Vector2D &p2);
- friend Vector2D operator * <>(const T &a, const Vector2D &p);
- friend Vector2D operator * <>(const Vector2D &p1, const T &a);
- friend Vector2D operator / <>(const Vector2D &p1, const Vector2D &p2);
- friend Vector2D operator / <>(const T &a, const Vector2D &p);
- friend Vector2D operator / <>(const Vector2D &p1, const T &a);
+ friend Vector2D operator * (const Vector2D &p1, const Vector2D &p2);
+ friend Vector2D operator * (const T &a, const Vector2D &p);
+ friend Vector2D operator * (const Vector2D &p1, const T &a);
+ friend Vector2D operator / (const Vector2D &p1, const Vector2D &p2);
+ friend Vector2D operator / (const T &a, const Vector2D &p);
+ friend Vector2D operator / (const Vector2D &p1, const T &a);
//
// friend ostream &operator << <>(ostream &os, const Vector2D &s);
inline T &operator [] (const int &i);
inline const T &operator [] (const int &i) const;
- friend Vector3D operator + <>(const Vector3D &p1, const Vector3D &p2);
- friend Vector3D operator + <>(const T &a, const Vector3D &p);
- friend Vector3D operator + <>(const Vector3D &p1, const T &a);
- friend Vector3D operator - <>(const Vector3D &p1, const Vector3D &p2);
- friend Vector3D operator - <>(const T &a, const Vector3D &p);
- friend Vector3D operator - <>(const Vector3D &p1, const T &a);
+ friend Vector3D operator + (const Vector3D &p1, const Vector3D &p2);
+ friend Vector3D operator + (const T &a, const Vector3D &p);
+ friend Vector3D operator + (const Vector3D &p1, const T &a);
+ friend Vector3D operator - (const Vector3D &p1, const Vector3D &p2);
+ friend Vector3D operator - (const T &a, const Vector3D &p);
+ friend Vector3D operator - (const Vector3D &p1, const T &a);
Vector3D operator - (void);
- friend Vector3D operator * <>(const Vector3D &p1, const Vector3D &p2);
- friend Vector3D operator * <>(const T &a, const Vector3D &p);
- friend Vector3D operator * <>(const Vector3D &p1, const T &a);
- friend Vector3D operator / <>(const Vector3D &p1, const Vector3D &p2);
- friend Vector3D operator / <>(const T &a, const Vector3D &p);
- friend Vector3D operator / <>(const Vector3D &p1, const T &a);
+ friend Vector3D operator * (const Vector3D &p1, const Vector3D &p2);
+ friend Vector3D operator * (const T &a, const Vector3D &p);
+ friend Vector3D operator * (const Vector3D &p1, const T &a);
+ friend Vector3D operator / (const Vector3D &p1, const Vector3D &p2);
+ friend Vector3D operator / (const T &a, const Vector3D &p);
+ friend Vector3D operator / (const Vector3D &p1, const T &a);
private:
};
// For format explanation, see http://www.sonicspot.com/guide/midifiles.html
#include <MIDIReader.hpp>
-#include <arpa/inet.h>
+//#include <arpa/inet.h>
#include <iostream>
using namespace std;
#include <string.h>
if (!_file)
return;
- uint8 temp[4];
+ uint8_t temp[4];
//read the chunk ID
fread((void *)(temp), 1, 4, _file);
}
//read the chunk size
- uint32 chunksize;
+ uint32_t chunksize;
readBytes(&chunksize, 4);
cout << "Header size: " << chunksize << endl;
//read the format
- uint16 format;
+ uint16_t format;
readBytes(&format, 2);
cout << "Format type: " << format << endl;
void MIDIReader::skipTrack()
{
- uint8 temp[4];
+ uint8_t temp[4];
//read the chunk ID
fread((void *)(temp), 4, 1, _file);
// cerr << temp << endl;
}
//read the chunk size
- uint32 chunksize;
+ uint32_t chunksize;
readBytes(&chunksize, 4);
cout << "Chunk size: " << chunksize << endl;
fseek(_file, chunksize, SEEK_CUR);
void MIDIReader::readTrack(Track &tr)
{
- uint8 temp[4];
+ uint8_t temp[4];
//read the chunk ID
fread((void *)(temp), 4, 1, _file);
// cerr << temp << endl;
}
//read the chunk size
- uint32 chunksize;
+ uint32_t chunksize;
readBytes(&chunksize, 4);
cout << "Chunk size: " << chunksize << endl;
// readBytes((char *)(&temp2),4);
// printf("TEMP : %0x %0x %0x %0x\n", temp2[0], temp2[1], temp2[2], temp2[3]);
bool end = false;
- uint8 oldeventandchannel = 0;
- uint32 timestamp = 0;
+ uint8_t oldeventandchannel = 0;
+ uint32_t timestamp = 0;
// Track example;
//Read the events
while (_position < chunksize)
{
- uint32 delta;
+ uint32_t delta;
//The delta is a variable-length stuff
/*uint8 nblus = */readVariableLength(delta);
timestamp += delta;
- uint8 eventandchannel, tempevt;
+ uint8_t eventandchannel, tempevt;
// 4 bits for event type, and 4 others for the channel
readBytes(&tempevt, 1);
fseek(_file, -1, SEEK_CUR);
{
if (end)
cerr << "EXTRA EVT ";
- uint8 type;
+ uint8_t type;
readBytes(&type, 1);
- uint32 length;
- /*uint8 nblus = */readVariableLength(length);
+ uint32_t length;
+ /*uint8_t nblus = */readVariableLength(length);
- uint8 *data = new uint8[length];
+ uint8_t *data = new uint8_t[length];
readBytes(data, length);
- uint32 tempo = 0;
+ uint32_t tempo = 0;
switch(type)
{
else if ((eventandchannel & 0xf0) == 0xf0)// || (eventandchannel & 0xff) == 0xf7)
{
//May be something else
- uint32 length;
+ uint32_t length;
readVariableLength(length);
- uint8 *data = new uint8[length];
+ uint8_t *data = new uint8_t[length];
readBytes(data, length);
printf("System data\n");
delete []data;
else
{
// printf("Evt : %x %x %x\n", eventandchannel & 0xf0, eventandchannel & 0x0f, eventandchannel);
- uint8 par1, par2;
+ uint8_t par1, par2;
// position += 2;
// char *notenames[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
switch(eventandchannel & 0xf0)
cout << endl << "Total : " << total << endl;
}
-uint8 MIDIReader::readVariableLength(uint32 &nb)
+uint8_t MIDIReader::readVariableLength(uint32_t &nb)
{
- uint8 nblus = 0;
+ uint8_t nblus = 0;
nb = 0;
- uint8 temp;
+ uint8_t temp;
do
{
fread((void *)(&temp), 1, 1, _file);
return nblus;
}
-void MIDIReader::readBytes(void *data, uint32 nb)
+void MIDIReader::readBytes(void *data, uint32_t nb)
{
- uint8 temp[nb];
- fread((void *)(&temp), nb, 1, _file);
- for (uint32 i=0 ; i<nb ; i++)
- ((uint8 *)data)[i] = temp[nb - i - 1];
+ uint8_t *temp = new uint8_t[nb];
+ fread((void *)(temp), nb, 1, _file);
+ for (uint32_t i=0 ; i<nb ; i++)
+ ((uint8_t *)data)[i] = temp[nb - i - 1];
+ delete []temp;
_position += nb;
}
-void MIDIReader::printBytes(uint8 *data, uint32 length)
+void MIDIReader::printBytes(uint8_t *data, uint32_t length)
{
- for (uint32 i=0 ; i < length ; i++)
+ for (uint32_t i=0 ; i < length ; i++)
cout << data[length - i - 1];
cout << endl;
}
#include <iostream>
using namespace std;
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
+
String::String(const String &s)
:string(strdup(s.string))
{
if (a == 0)
string = (char *)malloc(2 * sizeof(char));
else if (a < 0)
- string = (char *)malloc(int(log10(-a) + 3) * sizeof(char));
+ string = (char *)malloc(int(log10(static_cast<double>(-a)) + 3) * sizeof(char));
else
- string = (char *)malloc(int(log10(a) + 2) * sizeof(char));
+ string = (char *)malloc(int(log10(static_cast<double>(a)) + 2) * sizeof(char));
sprintf(string, "%d", a);
}
// #include <SDL/SDL.h>
#ifdef __APPLE__
#include <SDL_image/SDL_image.h>
+#elif WIN32
+#include <SDL_image.h>
#else
#include <SDL/SDL_image.h>
#endif
#include <cmath>
#include <cstdio>
#include <sys/types.h>
+
#include <dirent.h>
+
using namespace std;
bool fileExists(const String &f)
#include "Track.hpp"
#include "Mixer.hpp"
+#include "Texture.hpp"
#include <map>
double SECONDSIZE = 0.050;
-
+extern Texture* texturesteel;
extern FILE *logfile;
void drawCube(double pos, double size, double colorx, double colory, double colorz)
{
+ glEnable(GL_TEXTURE_2D);
+ texturesteel->useTexture();
glBegin(GL_QUADS);
glColor3f(colorx, colory, colorz); // Set The Color To Green
/*
glVertex3f( size+pos,0,-size); // Bottom Right Of The Quad (Bottom)
*/
glNormal3f(0, 0.5, 0.5);
- glVertex3f( size/2+pos, size/3, size/2); // Top Right Of The Quad (Front)
- glVertex3f(-size/2+pos, size/3, size/2); // Top Left Of The Quad (Front)
- glVertex3f(-size+pos,0, size); // Bottom Left Of The Quad (Front)
- glVertex3f( size+pos,0, size); // Bottom Right Of The Quad (Front)
+ glTexCoord2d(1.0, 0.0); glVertex3f( size/2+pos, size/3, size/2); // Top Right Of The Quad (Front)
+ glTexCoord2d(0.0, 0.0); glVertex3f(-size/2+pos, size/3, size/2); // Top Left Of The Quad (Front)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size+pos,0, size); // Bottom Left Of The Quad (Front)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size+pos,0, size); // Bottom Right Of The Quad (Front)
glNormal3f(0, 0.5, -0.5);
- glVertex3f( size+pos,0,-size); // Bottom Left Of The Quad (Back)
- glVertex3f(-size+pos,0,-size); // Bottom Right Of The Quad (Back)
- glVertex3f(-size/2+pos, size/3,-size/2); // Top Right Of The Quad (Back)
- glVertex3f( size/2+pos, size/3,-size/2); // Top Left Of The Quad (Back)
+ glTexCoord2d(1.0, 0.0); glVertex3f( size+pos,0,-size); // Bottom Left Of The Quad (Back)
+ glTexCoord2d(0.0, 0.0); glVertex3f(-size+pos,0,-size); // Bottom Right Of The Quad (Back)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size/2+pos, size/3,-size/2); // Top Right Of The Quad (Back)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size/2+pos, size/3,-size/2); // Top Left Of The Quad (Back)
glNormal3f(-0.5, 0.5, 0);
- glVertex3f(-size/2+pos, size/3, size/2); // Top Right Of The Quad (Left)
- glVertex3f(-size/2+pos, size/3,-size/2); // Top Left Of The Quad (Left)
- glVertex3f(-size+pos,0,-size); // Bottom Left Of The Quad (Left)
- glVertex3f(-size+pos,0, size); // Bottom Right Of The Quad (Left)
+ glTexCoord2d(1.0, 0.0); glVertex3f(-size/2+pos, size/3, size/2); // Top Right Of The Quad (Left)
+ glTexCoord2d(0.0, 0.0); glVertex3f(-size/2+pos, size/3,-size/2); // Top Left Of The Quad (Left)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size+pos,0,-size); // Bottom Left Of The Quad (Left)
+ glTexCoord2d(1.0, 1.0); glVertex3f(-size+pos,0, size); // Bottom Right Of The Quad (Left)
glNormal3f(0.5, 0.5, 0);
- glVertex3f( size/2+pos, size/3,-size/2l); // Top Right Of The Quad (Right)
- glVertex3f( size/2+pos, size/3, size/2); // Top Left Of The Quad (Right)
- glVertex3f( size+pos,0, size); // Bottom Left Of The Quad (Right)
- glVertex3f( size+pos,0,-size); // Bottom Right Of The Quad (Right)
+ glTexCoord2d(1.0, 0.0); glVertex3f( size/2+pos, size/3,-size/2l); // Top Right Of The Quad (Right)
+ glTexCoord2d(0.0, 0.0); glVertex3f( size/2+pos, size/3, size/2); // Top Left Of The Quad (Right)
+ glTexCoord2d(0.0, 1.0); glVertex3f( size+pos,0, size); // Bottom Left Of The Quad (Right)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size+pos,0,-size); // Bottom Right Of The Quad (Right)
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+ glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0); // Set The Color To White
glNormal3f(0, 1, 0);
glVertex3f( size/2+pos, size/3,-size/2); // Top Right Of The Quad (Top)
void drawLong(double pos, double size, double length, double colorx, double colory, double colorz)
{
double l = length*SECONDSIZE;
+ glEnable(GL_TEXTURE_2D);
+ texturesteel->useTexture();
glBegin(GL_QUADS);
glColor3f(colorx, colory, colorz); // Set The Color
/*
glVertex3f( size+pos,0,-size-l); // Bottom Right Of The Quad (Bottom)
*/
glNormal3f(0, 0.5, 0.5);
- glVertex3f( size/2+pos, size/3, size/2); // Top Right Of The Quad (Front)
- glVertex3f(-size/2+pos, size/3, size/2); // Top Left Of The Quad (Front)
- glVertex3f(-size+pos,0, size); // Bottom Left Of The Quad (Front)
- glVertex3f( size+pos,0, size); // Bottom Right Of The Quad (Front)
+ glTexCoord2d(1.0, 0.0); glVertex3f( size/2+pos, size/3, size/2); // Top Right Of The Quad (Front)
+ glTexCoord2d(0.0, 0.0); glVertex3f(-size/2+pos, size/3, size/2); // Top Left Of The Quad (Front)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size+pos,0, size); // Bottom Left Of The Quad (Front)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size+pos,0, size); // Bottom Right Of The Quad (Front)
glNormal3f(0, 0.5, -0.5);
- glVertex3f( size+pos,0,-size); // Bottom Left Of The Quad (Back)
- glVertex3f(-size+pos,0,-size); // Bottom Right Of The Quad (Back)
- glVertex3f(-size/2+pos, size/3,-size/2-l); // Top Right Of The Quad (Back)
- glVertex3f( size/2+pos, size/3,-size/2-l); // Top Left Of The Quad (Back)
+ glTexCoord2d(1.0, 0.0); glVertex3f( size+pos,0,-size); // Bottom Left Of The Quad (Back)
+ glTexCoord2d(0.0, 0.0); glVertex3f(-size+pos,0,-size); // Bottom Right Of The Quad (Back)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size/2+pos, size/3,-size/2-l); // Top Right Of The Quad (Back)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size/2+pos, size/3,-size/2-l); // Top Left Of The Quad (Back)
glNormal3f(-0.5, 0.5, 0);
- glVertex3f(-size/2+pos, size/3, size/2); // Top Right Of The Quad (Left)
- glVertex3f(-size/2+pos, size/3,-size/2-l); // Top Left Of The Quad (Left)
- glVertex3f(-size+pos,0,-size-l); // Bottom Left Of The Quad (Left)
- glVertex3f(-size+pos,0, size); // Bottom Right Of The Quad (Left)
+ glTexCoord2d(1.0, 0.0); glVertex3f(-size/2+pos, size/3, size/2); // Top Right Of The Quad (Left)
+ glTexCoord2d(0.0, 0.0); glVertex3f(-size/2+pos, size/3,-size/2-l); // Top Left Of The Quad (Left)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size+pos,0,-size-l); // Bottom Left Of The Quad (Left)
+ glTexCoord2d(1.0, 1.0); glVertex3f(-size+pos,0, size); // Bottom Right Of The Quad (Left)
glNormal3f(0.5, 0.5, 0);
- glVertex3f( size/2+pos, size/3,-size/2-l); // Top Right Of The Quad (Right)
- glVertex3f( size/2+pos, size/3, size/2); // Top Left Of The Quad (Right)
- glVertex3f( size+pos,0, size); // Bottom Left Of The Quad (Right)
- glVertex3f( size+pos,0,-size-l); // Bottom Right Of The Quad (Right)
+ glTexCoord2d(1.0, 0.0); glVertex3f( size/2+pos, size/3,-size/2-l); // Top Right Of The Quad (Right)
+ glTexCoord2d(0.0, 0.0); glVertex3f( size/2+pos, size/3, size/2); // Top Left Of The Quad (Right)
+ glTexCoord2d(0.0, 1.0); glVertex3f( size+pos,0, size); // Bottom Left Of The Quad (Right)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size+pos,0,-size-l); // Bottom Right Of The Quad (Right)
glNormal3f(0, 1, 0);
- glVertex3f( size/2+pos, size/3,-size/2-l); // Top Right Of The Quad (Top)
- glVertex3f(-size/2+pos, size/3,-size/2-l); // Top Left Of The Quad (Top)
- glVertex3f(-size/2+pos, size/3, size/2); // Bottom Left Of The Quad (Top)
- glVertex3f( size/2+pos, size/3, size/2); // Bottom Right Of The Quad (Top)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size/2+pos, size/3,-size/2-l); // Top Right Of The Quad (Top)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size/2+pos, size/3,-size/2-l); // Top Left Of The Quad (Top)
+ glTexCoord2d(0.0, 1.0); glVertex3f(-size/2+pos, size/3, size/2); // Bottom Left Of The Quad (Top)
+ glTexCoord2d(1.0, 1.0); glVertex3f( size/2+pos, size/3, size/2); // Bottom Right Of The Quad (Top)
glEnd(); // Done Drawing The Quad
}
#include "Texture.hpp"
#include "Mixer.hpp"
+
+#include <GL/glew.h>
+
+#ifdef WIN32
+#include <time.h>
+
+#include <SDL.h>
+#include <SDL_mixer.h>
+#include <SDL_image.h>
+#else
#include <sys/time.h>
+
+#include <SDL/SDL.h>
+#include <SDL/SDL_mixer.h>
+#include <SDL/SDL_image.h>
+#endif
+
#include <list>
/*#ifdef __APPLE__
#include <SDL_mixer/SDL_mixer.h>
#include <SDL/SDL_mixer.h>
#endif*/
-#include <GL/glew.h>
-#include <SDL/SDL.h>
-#include <SDL/SDL_mixer.h>
-#include <SDL/SDL_image.h>
extern double SECONDSIZE;
#include "Wiimote.hpp"
-double posx, posy, posz;
-struct timeval start;
-Texture *texturebois, *texturefond;
+double posz=0.0;
+\r
+#ifdef WIN32\r
+ struct { int tv_sec, tv_usec; } start;\r
+ DWORD t;\r
+#else\r
+ struct timeval start;\r
+#endif\r
+
+Texture *texturebois, *texturefond, *texturesteel;
int resolution_x, resolution_y;
Config fromKeyboard;
throw "Error while loading SDL";
//Initialize SDL_mixer
- if (Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 1024 ) == -1 );
-// throw String("Can't initialize sound");
+ if (Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 1024 ) == -1 )
+ throw String("Can't initialize sound");
cout << "get video info" << endl;
info = SDL_GetVideoInfo();
texturebois = new Texture("wood.jpg", true);
texturefond = new Texture("back.jpg");
-
- posx=0.0;
- posy=25.0;
- posz=0.0;
+ texturesteel = new Texture("steel.jpg");
fromKeyboard.setPosition(-1);
fromKeyboard.setEnd(-1);
}
+#define POSITION_HEIGHT 35
#define POSITION_EYE 45
-#define POSITION_CENTER (-80)
-#define VIEWLENGTH 250
+#define POSITION_CENTER (-70)
+#define VIEWLENGTH 250
void draw(Track &t, uint8 diff)
{
- struct timeval now;
- gettimeofday(&now, NULL);
+#ifdef WIN32\r
+ struct { int tv_sec, tv_usec; } now;\r
+ DWORD tim;\r
+#else\r
+ struct timeval now;\r
+#endif\r
+\r
+#ifdef WIN32\r
+ tim = timeGetTime ();\r
+ now.tv_sec = tim / 1000;\r
+ now.tv_usec = (tim % 1000) * 1000;\r
+#else\r
+ gettimeofday(&now, NULL);\r
+#endif
double postime = (now.tv_sec - start.tv_sec) * 1000. + (now.tv_usec - start.tv_usec) / 1000.0;
posz = -SECONDSIZE * postime;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gluPerspective( 45.0f, double(resolution_x) / double(resolution_y), POSITION_EYE+3, VIEWLENGTH );
+ gluPerspective( 45.0f, double(resolution_x) / double(resolution_y), 1/*POSITION_EYE+3*/, VIEWLENGTH );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//cout << "posz=" << posz << endl;
- gluLookAt(posx, posy, posz + POSITION_EYE, 0, 0, posz + POSITION_CENTER, 0.0,1.0,0.0);
+ gluLookAt(0, POSITION_HEIGHT, posz + POSITION_EYE, 0, 0, posz + POSITION_CENTER, 0.0,1.0,0.0);
// gluLookAt(posx-50, posy, posz-POSITION, 0, 0,posz-POSITION, 0.0,1.0,0.0);
GLfloat light_position[] = { 0.0, 10.0 , posz, 1.0 };
glLightfv(GL_LIGHT1, GL_POSITION, light_position);
glEnd();
glDisable(GL_TEXTURE_2D);
- //Draw the position bar
- glMatrixMode(GL_MODELVIEW);
+ glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(0,0,posz);
- glBegin(GL_QUADS);
- glColor3f(0.8, 0.8, 0.8);
- glNormal3f(0, 1, 0);
- glVertex3f( NECKWIDTH,0, 1);
- glVertex3f( NECKWIDTH,0.2, 0);
- glVertex3f(-NECKWIDTH,0.2, 0);
- glVertex3f(-NECKWIDTH,0, 1);
- glVertex3f( NECKWIDTH,0.2, 0);
- glVertex3f( NECKWIDTH,0, -1);
- glVertex3f(-NECKWIDTH,0, -1);
- glVertex3f(-NECKWIDTH,0.2, 0);
- glEnd();
+ //draw the strings
+ for (int i = 0 ; i < 5 ; i++)
+ {
+ glBegin(GL_QUADS);
+ glColor3f(0.2, 0.2, 0.2);
+ glNormal3f(0, 1, 0);
+ glVertex3f(NOTEDIST*(i-2), 0, 1);
+ glVertex3f(NOTEDIST*(i-2)+.1,0.2, 1);
+ glVertex3f(NOTEDIST*(i-2)+.1,0.2,-VIEWLENGTH);
+ glVertex3f(NOTEDIST*(i-2),0, -VIEWLENGTH);
+ glVertex3f(NOTEDIST*(i-2)+.1, 0.2, 1);
+ glVertex3f(NOTEDIST*(i-2)+.2,0, 1);
+ glVertex3f(NOTEDIST*(i-2)+.2,0,-VIEWLENGTH);
+ glVertex3f(NOTEDIST*(i-2)+.1,0.2, -VIEWLENGTH);
+ glEnd();
+ }
+ //Draw the sides
glBegin(GL_QUADS);
glColor3f(0.8, 0.8, 0.8);
glNormal3f(0, 1, 0);
glVertex3f(-NECKWIDTH-.2,0,-VIEWLENGTH);
glVertex3f(-NECKWIDTH-.1,0.2, -VIEWLENGTH);
glEnd();
- fromKeyboard.display();
glPopMatrix();
-
+
//draw the frets
t.drawFrets(postime);
// Draw the notes
t.drawNotes(postime, diff);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslatef(0,0,posz);
+ //Draw the position bar
+ glBegin(GL_QUADS);
+ glColor3f(0.8, 0.8, 0.8);
+ glNormal3f(0, 1, 0);
+ glVertex3f( NECKWIDTH,0.5, 10);
+ glVertex3f( NECKWIDTH,0.5, 0);
+ glVertex3f(-NECKWIDTH,0.5, 0);
+ glVertex3f(-NECKWIDTH,0.5, 10);
+ glVertex3f( NECKWIDTH,0.5, 0);
+ glVertex3f( NECKWIDTH,0, -1);
+ glVertex3f(-NECKWIDTH,0, -1);
+ glVertex3f(-NECKWIDTH,0.5, 0);
+ glEnd();
+ fromKeyboard.display();
+ glPopMatrix();
+
SDL_GL_SwapBuffers();
}
if (fromKeyboard.getPosition() == -1)
return;
- struct timeval now;
- gettimeofday(&now, NULL);
+#ifdef WIN32\r
+ struct { int tv_sec, tv_usec; } now;\r
+ DWORD t;\r
+#else\r
+ struct timeval now;\r
+#endif\r
+\r
+#ifdef WIN32\r
+ t = timeGetTime ();\r
+ now.tv_sec = t / 1000;\r
+ now.tv_usec = (t % 1000) * 1000;\r
+#else\r
+ gettimeofday(&now, NULL);\r
+#endif
+
double postime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000.0;
fromKeyboard.setEnd(postime);
cout << fromKeyboard << endl;
void handleStrokeOn()
{
- struct timeval now;
- gettimeofday(&now, NULL);
+#ifdef WIN32\r
+ struct { int tv_sec, tv_usec; } now;\r
+ DWORD t;\r
+#else\r
+ struct timeval now;\r
+#endif\r
+\r
+#ifdef WIN32\r
+ t = timeGetTime ();\r
+ now.tv_sec = t / 1000;\r
+ now.tv_usec = (t % 1000) * 1000;\r
+#else\r
+ gettimeofday(&now, NULL);\r
+#endif
+
double postime = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000.0;
//cout << postime << endl;
case SDL_KEYDOWN:
keystate = SDL_GetKeyState(NULL);
- handleKeys(keystate[SDLK_a], keystate[SDLK_z], keystate[SDLK_e], keystate[SDLK_r], keystate[SDLK_t]);
+ handleKeys(keystate[SDLK_F1], keystate[SDLK_F2], keystate[SDLK_F3], keystate[SDLK_F4], keystate[SDLK_F5]);
switch(((SDL_KeyboardEvent *)(&event))->keysym.sym)
{
case SDLK_ESCAPE:
case SDLK_DOWN:
SECONDSIZE -=1;
break;
- case SDLK_LEFT:
+/* case SDLK_LEFT:
posy +=1;
break;
case SDLK_RIGHT:
posy -=1;
- break;
+ break;*/
case SDLK_KP_PLUS:
Mixer::getInstance()->setMusicVolume(Mixer::getInstance()->getMusicVolume() + 10);
Mixer::getInstance()->setSoundVolume(Mixer::getInstance()->getSoundVolume() + 10);
case SDL_KEYUP:
switch(((SDL_KeyboardEvent *)(&event))->keysym.sym)
{
- case SDLK_a:
+ case SDLK_F1:
handleKeyOff(KEY0);
break;
- case SDLK_z:
+ case SDLK_F2:
handleKeyOff(KEY1);
break;
- case SDLK_e:
+ case SDLK_F3:
handleKeyOff(KEY2);
break;
- case SDLK_r:
+ case SDLK_F4:
handleKeyOff(KEY3);
break;
- case SDLK_t:
+ case SDLK_F5:
handleKeyOff(KEY4);
break;
case SDLK_SPACE:
break;
}
keystate = SDL_GetKeyState(NULL);
- handleKeys(keystate[SDLK_a], keystate[SDLK_z], keystate[SDLK_e], keystate[SDLK_r], keystate[SDLK_t]);
+ handleKeys(keystate[SDLK_F1], keystate[SDLK_F2], keystate[SDLK_F3], keystate[SDLK_F4], keystate[SDLK_F5]);
break;
default:
// lasteventtype = OTHER;
Mixer::getInstance()->playSound("guitar");
if (rhythm)
Mixer::getInstance()->playSound("rhythm");
- gettimeofday(&start, NULL);
+\r
+#ifdef WIN32\r
+ t = timeGetTime ();\r
+ start.tv_sec = t / 1000;\r
+ start.tv_usec = (t % 1000) * 1000;\r
+#else\r
+ gettimeofday(&start, NULL);\r
+#endif
/*
Sound music;
cout << "Load sounds" << endl;