diff --git a/client/main.cc b/client/main.cc index a37c4e6..f46336b 100644 --- a/client/main.cc +++ b/client/main.cc @@ -11,14 +11,15 @@ static void cleanup(int sig){ #endif int main(){ - fishbone::Window* wnd; + fishbone::Client* client; + std::unordered_map> param; + + client = new fishbone::Client(param); #ifndef _WIN32 signal(SIGINT, cleanup); signal(SIGTERM, cleanup); #endif - wnd = new fishbone::Window("Fishbowl", 800, 600); - - while(!quit); + while(!quit && client->step()); } diff --git a/engine/include/fishbone/client.h b/engine/include/fishbone/client.h index 1d9f160..e29a7cb 100644 --- a/engine/include/fishbone/client.h +++ b/engine/include/fishbone/client.h @@ -1,19 +1,29 @@ #ifndef __FISHBONE_CLIENT_H__ #define __FISHBONE_CLIENT_H__ +#include + namespace fishbone { class Client; }; -#include #include #include +#include +#include namespace fishbone { class Client { public: - fishbone::SoundDriver sound; - fishbone::Window window; + Client(std::unordered_map> param); + ~Client(); + + bool step(); + + fishbone::Window* window; + fishbone::SoundDriver* sounddrv; + fishbone::Mixer* mixer; + fishbone::Renderer* renderer; }; }; // namespace fishbone diff --git a/engine/include/fishbone/draw.h b/engine/include/fishbone/draw.h new file mode 100644 index 0000000..4a60cd5 --- /dev/null +++ b/engine/include/fishbone/draw.h @@ -0,0 +1,43 @@ +#ifndef __FISHBOWL_DRAW_H__ +#define __FISHBOWL_DRAW_H__ + +#include + +namespace fishbone { + class Texture; + class Mesh; + class Renderer; +}; + +/* no includes */ + +namespace fishbone { + class Texture { + struct Impl; + Impl* impl; + + public: + Texture(fishbone::Renderer* renderer, unsigned char* rgba, int width, int height); + ~Texture(); + }; + + class Mesh { + struct Impl; + Impl* impl; + + public: + Mesh(fishbone::Renderer* renderer, std::vector vertices, std::vector texcoords, std::vector normals); + ~Mesh(); + }; + + class Renderer { + struct Impl; + Impl* impl; + + public: + Renderer(); + ~Renderer(); + }; +}; + +#endif diff --git a/engine/include/fishbone/file.h b/engine/include/fishbone/file.h index f7637aa..4dbf9ce 100644 --- a/engine/include/fishbone/file.h +++ b/engine/include/fishbone/file.h @@ -1,11 +1,13 @@ #ifndef __FISHBONE_FILE_H__ #define __FISHBONE_FILE_H__ +#include + namespace fishbone { class File; }; -#include +/* no includes */ namespace fishbone { class File { diff --git a/engine/include/fishbone/foundation.h b/engine/include/fishbone/foundation.h index 374ca7b..85f859e 100644 --- a/engine/include/fishbone/foundation.h +++ b/engine/include/fishbone/foundation.h @@ -8,5 +8,7 @@ #include #include #include +#include +#include #endif diff --git a/engine/include/fishbone/machdep.h b/engine/include/fishbone/machdep.h index 061dd10..666528e 100644 --- a/engine/include/fishbone/machdep.h +++ b/engine/include/fishbone/machdep.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include diff --git a/engine/include/fishbone/mixer.h b/engine/include/fishbone/mixer.h index f7dc895..23330af 100644 --- a/engine/include/fishbone/mixer.h +++ b/engine/include/fishbone/mixer.h @@ -1,11 +1,12 @@ #ifndef __FISHBONE_MIXER_H__ #define __FISHBONE_MIXER_H__ +#include + namespace fishbone { class Mixer; }; -#include #include #include diff --git a/engine/include/fishbone/pre.h b/engine/include/fishbone/pre.h new file mode 100644 index 0000000..396ed54 --- /dev/null +++ b/engine/include/fishbone/pre.h @@ -0,0 +1,7 @@ +#ifndef __FISHBONE_PRE_H__ +#define __FISHBONE_PRE_H__ + +#include +#include + +#endif diff --git a/engine/include/fishbone/resource.h b/engine/include/fishbone/resource.h index 7fd1297..a995f15 100644 --- a/engine/include/fishbone/resource.h +++ b/engine/include/fishbone/resource.h @@ -1,11 +1,12 @@ #ifndef __FISHBONE_THREAD_H__ #define __FISHBONE_THREAD_H__ +#include + namespace fishbone { class Resource; }; // namespace fishbone -#include #include namespace fishbone { diff --git a/engine/include/fishbone/sound.h b/engine/include/fishbone/sound.h index 6e0e873..1277ec5 100644 --- a/engine/include/fishbone/sound.h +++ b/engine/include/fishbone/sound.h @@ -1,6 +1,8 @@ #ifndef __FISHBONE_SOUND_H__ #define __FISHBONE_SOUND_H__ +#include + #define FB_SOUND_DECL(prefix) \ class prefix##SoundLoader; \ class prefix##Sound @@ -37,7 +39,6 @@ namespace fishbone { #undef LOADER }; // namespace fishbone -#include #include namespace fishbone { @@ -54,12 +55,12 @@ namespace fishbone { class SoundLoader { public: - SoundLoader(); - ~SoundLoader(); + SoundLoader(){}; + ~SoundLoader(){}; - virtual Sound* open(Mixer* mixer, void* buffer, size_t size); - virtual int read(Sound* sound, short* buffer, size_t frames); - virtual void seek(Sound* sound, size_t pos); + virtual Sound* open(Mixer* mixer, void* buffer, size_t size){return nullptr;}; + virtual int read(Sound* sound, short* buffer, size_t frames){return 0;}; + virtual void seek(Sound* sound, size_t pos){}; }; class Sound { diff --git a/engine/include/fishbone/thread.h b/engine/include/fishbone/thread.h index 114269c..90b5c10 100644 --- a/engine/include/fishbone/thread.h +++ b/engine/include/fishbone/thread.h @@ -1,12 +1,14 @@ #ifndef __FISHBONE_THREAD_H__ #define __FISHBONE_THREAD_H__ +#include + namespace fishbone { class Thread; class Mutex; }; // namespace fishbone -#include +/* no includes */ namespace fishbone { class Thread { diff --git a/engine/include/fishbone/time.h b/engine/include/fishbone/time.h new file mode 100644 index 0000000..cd7e6a9 --- /dev/null +++ b/engine/include/fishbone/time.h @@ -0,0 +1,18 @@ +#ifndef __FISHBONE_TIME_H__ +#define __FISHBONE_TIME_H__ + +#include + +namespace fishbone { + using AccurateClock = std::chrono::time_point; + + fishbone::AccurateClock accurateTime(); +}; + +/* no includes */ + +namespace fishbone { + fishbone::AccurateClock accurateTime(); +}; + +#endif diff --git a/engine/include/fishbone/types.h b/engine/include/fishbone/types.h new file mode 100644 index 0000000..9d01009 --- /dev/null +++ b/engine/include/fishbone/types.h @@ -0,0 +1,19 @@ +#ifndef __FISHBOWL_TYPES_H__ +#define __FISHBOWL_TYPES_H__ + +#include + +namespace fishbone { + struct Vector2 { + float x; + float y; + }; + + struct Vector3 { + float x; + float y; + float z; + }; +}; + +#endif diff --git a/engine/include/fishbone/window.h b/engine/include/fishbone/window.h index 7af1a18..0846a75 100644 --- a/engine/include/fishbone/window.h +++ b/engine/include/fishbone/window.h @@ -5,7 +5,7 @@ namespace fishbone { class Window; }; // namespace fishbone -#include +#include namespace fishbone { class Window { @@ -15,6 +15,8 @@ namespace fishbone { public: Window(std::string title, int width, int height); ~Window(); + + void poll(); }; }; // namespace fishbone diff --git a/engine/src/client.cc b/engine/src/client.cc index 78bf70c..bc17717 100644 --- a/engine/src/client.cc +++ b/engine/src/client.cc @@ -1 +1,18 @@ -#include +#include + +fishbone::Client::Client(std::unordered_map> param){ + this->window = new fishbone::Window("Fishbone", 800, 600); + this->sounddrv = new fishbone::SoundDriver(); + this->mixer = &this->sounddrv->mixer; + this->renderer = new fishbone::Renderer(); +} + +fishbone::Client::~Client(){ + delete this->renderer; + delete this->sounddrv; + delete this->window; +} + +bool fishbone::Client::step(){ + return true; +} diff --git a/engine/src/draw/opengl.cc b/engine/src/draw/opengl.cc new file mode 100644 index 0000000..557d7a1 --- /dev/null +++ b/engine/src/draw/opengl.cc @@ -0,0 +1,34 @@ +#include + +struct fishbone::Texture::Impl { + GLuint texture; +}; + +fishbone::Texture::Texture(fishbone::Renderer* renderer, unsigned char* rgba, int width, int height){ + this->impl = new struct fishbone::Texture::Impl(); + + glGenTextures(1, &this->impl->texture); + glBindTexture(GL_TEXTURE_2D, this->impl->texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glBindTexture(GL_TEXTURE_2D, 0); +} + +fishbone::Texture::~Texture(){ + glDeleteTextures(1, &this->impl->texture); + + delete this->impl; +} + +fishbone::Mesh::Mesh(fishbone::Renderer* renderer, std::vector vertices, std::vector texcoords, std::vector normals){ +} + +fishbone::Mesh::~Mesh(){ +} + +fishbone::Renderer::Renderer(){ +} + +fishbone::Renderer::~Renderer(){ +} diff --git a/engine/src/sound.cc b/engine/src/sound.cc index dba736a..1e17d35 100644 --- a/engine/src/sound.cc +++ b/engine/src/sound.cc @@ -1,22 +1,5 @@ #include -fishbone::SoundLoader::SoundLoader() { -} - -fishbone::SoundLoader::~SoundLoader() { -} - -fishbone::Sound* fishbone::SoundLoader::open(fishbone::Mixer* mixer, void* buffer, size_t size) { - return nullptr; -} - -int fishbone::SoundLoader::read(fishbone::Sound* sound, short* buffer, size_t frames) { - return 0; -} - -void fishbone::SoundLoader::seek(fishbone::Sound* sound, size_t pos) { -} - fishbone::Sound::Sound(fishbone::Mixer* mixer, fishbone::SoundLoader* loader, struct fishbone::Sound::Impl* impl) { this->mixer = mixer; this->loader = loader; diff --git a/engine/src/time.cc b/engine/src/time.cc new file mode 100644 index 0000000..fdf52c4 --- /dev/null +++ b/engine/src/time.cc @@ -0,0 +1,5 @@ +#include + +fishbone::AccurateClock fishbone::accurateTime(){ + return std::chrono::high_resolution_clock::now(); +} diff --git a/engine/src/window/sdl2.cc b/engine/src/window/sdl2.cc index 9216dcd..dd27855 100644 --- a/engine/src/window/sdl2.cc +++ b/engine/src/window/sdl2.cc @@ -27,4 +27,11 @@ fishbone::Window::~Window() { SDL_DestroyWindow(this->impl->window); delete this->impl; } + +void fishbone::Window::poll(){ + SDL_Event ev; + + while(SDL_PollEvent(&ev)){ + } +} #endif