Inital commit v1.0
This commit is contained in:
34
include/GPData.h
Normal file
34
include/GPData.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
namespace gpgui {
|
||||
namespace data {
|
||||
|
||||
typedef std::vector<float> VertexData;
|
||||
|
||||
struct Color {
|
||||
std::uint8_t red, green, blue, alpha = 255;
|
||||
};
|
||||
|
||||
struct DrawData {
|
||||
std::uint32_t vao, vbo;
|
||||
std::size_t vertexCount;
|
||||
};
|
||||
|
||||
static const std::uint8_t EMPTY_TAB = 0xF;
|
||||
static const std::uint8_t EMPTY_NOTE = 0xFF;
|
||||
|
||||
VertexData GetCircleData(float centerX, float centerY, float radius, float color, int precision);
|
||||
VertexData GetRectData(float x, float y, float dx, float dy, float color);
|
||||
|
||||
DrawData GetDrawData(const VertexData& vertexData);
|
||||
void UpdateData(DrawData& buffer, const VertexData& newData);
|
||||
|
||||
void DrawVertexData(const DrawData& vertexData);
|
||||
|
||||
float GetIntColor(const Color& color);
|
||||
|
||||
} // namespace data
|
||||
} // namespace gpgui
|
||||
10
include/GPGui.h
Normal file
10
include/GPGui.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace gpgui {
|
||||
namespace gui {
|
||||
|
||||
void Render();
|
||||
void Init();
|
||||
|
||||
} // namespace gui
|
||||
} // namespace gpgui
|
||||
68
include/GPMusic.h
Normal file
68
include/GPMusic.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace gpgui {
|
||||
|
||||
namespace save {
|
||||
|
||||
struct ChordSave;
|
||||
|
||||
} // namespace save
|
||||
|
||||
namespace music {
|
||||
|
||||
enum Note : std::uint8_t {
|
||||
A = 0,
|
||||
Bb,
|
||||
B,
|
||||
C,
|
||||
Db,
|
||||
D,
|
||||
Eb,
|
||||
E,
|
||||
F,
|
||||
Gb,
|
||||
G,
|
||||
Ab,
|
||||
|
||||
TOTAL
|
||||
};
|
||||
|
||||
enum class ChordType : std::uint8_t {
|
||||
Major = 0,
|
||||
Minor,
|
||||
Dim,
|
||||
Major7,
|
||||
Minor7,
|
||||
Sus,
|
||||
|
||||
COUNT
|
||||
};
|
||||
|
||||
typedef std::array<int, 6> Tab;
|
||||
typedef std::array<Note, 4> Chord;
|
||||
typedef std::array<std::uint8_t, 4> ChordOffsets;
|
||||
|
||||
Note GetNote(std::uint8_t touche);
|
||||
std::uint8_t GetOctave(std::uint8_t touche);
|
||||
|
||||
std::string ToString(Note note);
|
||||
std::string ToString(ChordType chord);
|
||||
std::string ToString(const Tab& tab);
|
||||
std::string ToString(const save::ChordSave& tab);
|
||||
|
||||
int GetStringOffset(int string);
|
||||
|
||||
Tab FindChord(const Chord& chord, int capo);
|
||||
Tab FindFakeChord(const Chord& chord, int capo, int pCorde = 0);
|
||||
|
||||
Tab FindPianoChord(const ChordOffsets& notes, int capo = 0, int fretThreshold = 5);
|
||||
|
||||
ChordOffsets GetChordOffsets(Note note, ChordType type);
|
||||
Chord GetChord(Note note, ChordType type);
|
||||
|
||||
} // namespace music
|
||||
} // namespace gpgui
|
||||
23
include/GPRenderer.h
Normal file
23
include/GPRenderer.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
namespace gpgui {
|
||||
namespace renderer {
|
||||
|
||||
void InitRendering();
|
||||
|
||||
void DrawWidgets();
|
||||
void DrawStrings();
|
||||
|
||||
bool IsKeyHighlited(int key);
|
||||
void SetKeyHighlight(int key, bool highlight);
|
||||
void ClearKeyboard();
|
||||
|
||||
void UpdateBuffers();
|
||||
|
||||
void ClearTab();
|
||||
void SetTab(int tab, int fret);
|
||||
|
||||
void SetCapoPos(int capo);
|
||||
|
||||
} // namespace renderer
|
||||
} // namespace gpgui
|
||||
33
include/GPSave.h
Normal file
33
include/GPSave.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "GPMusic.h"
|
||||
|
||||
namespace gpgui {
|
||||
namespace save {
|
||||
|
||||
typedef std::uint8_t CapoPosType;
|
||||
|
||||
struct ChordSave {
|
||||
music::Note note : 4;
|
||||
music::ChordType type : 3;
|
||||
bool guitaroPiano : 1;
|
||||
std::uint8_t octave : 2;
|
||||
std::uint8_t inversion : 2;
|
||||
std::uint8_t fretMax : 4;
|
||||
|
||||
ChordSave() : note(music::Note::TOTAL) {}
|
||||
};
|
||||
|
||||
struct Song {
|
||||
std::string title;
|
||||
CapoPosType capo;
|
||||
std::vector<ChordSave> chords;
|
||||
|
||||
Song(const std::string& songTitle, CapoPosType songCapo) : title(songTitle), capo(songCapo) {}
|
||||
};
|
||||
|
||||
void SaveSongToFile(const Song& save, const std::string& fileName);
|
||||
Song LoadSongFromFile(const std::string& filePath);
|
||||
|
||||
} // namespace save
|
||||
} // namespace gpgui
|
||||
32
include/ShaderProgram.h
Executable file
32
include/ShaderProgram.h
Executable file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace gpgui {
|
||||
|
||||
class ShaderProgram {
|
||||
public:
|
||||
ShaderProgram();
|
||||
virtual ~ShaderProgram();
|
||||
|
||||
void Start() const;
|
||||
void Stop() const;
|
||||
|
||||
void LoadProgramFile(const std::string& vertexFile, const std::string& fragmentFile);
|
||||
void LoadProgram(const std::string& vertexSource, const std::string& fragmentSource);
|
||||
|
||||
protected:
|
||||
virtual void GetAllUniformLocation() = 0;
|
||||
|
||||
void CleanUp() const;
|
||||
|
||||
private:
|
||||
unsigned int m_ProgramID;
|
||||
unsigned int m_VertexShaderID;
|
||||
unsigned int m_FragmentShaderID;
|
||||
|
||||
unsigned int LoadShaderFromFile(const std::string& file, unsigned int type);
|
||||
unsigned int LoadShader(const std::string& source, unsigned type);
|
||||
};
|
||||
|
||||
} // namespace gpgui
|
||||
Reference in New Issue
Block a user