texture
This commit is contained in:
parent
f2604d01cd
commit
3072248158
19 changed files with 193 additions and 36 deletions
|
|
@ -11,14 +11,15 @@ static void cleanup(int sig){
|
|||
#endif
|
||||
|
||||
int main(){
|
||||
fishbone::Window* wnd;
|
||||
fishbone::Client* client;
|
||||
std::unordered_map<std::string, std::vector<std::string>> 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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,29 @@
|
|||
#ifndef __FISHBONE_CLIENT_H__
|
||||
#define __FISHBONE_CLIENT_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
class Client;
|
||||
};
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/sound.h>
|
||||
#include <fishbone/window.h>
|
||||
#include <fishbone/mixer.h>
|
||||
#include <fishbone/draw.h>
|
||||
|
||||
namespace fishbone {
|
||||
class Client {
|
||||
public:
|
||||
fishbone::SoundDriver sound;
|
||||
fishbone::Window window;
|
||||
Client(std::unordered_map<std::string, std::vector<std::string>> param);
|
||||
~Client();
|
||||
|
||||
bool step();
|
||||
|
||||
fishbone::Window* window;
|
||||
fishbone::SoundDriver* sounddrv;
|
||||
fishbone::Mixer* mixer;
|
||||
fishbone::Renderer* renderer;
|
||||
};
|
||||
}; // namespace fishbone
|
||||
|
||||
|
|
|
|||
43
engine/include/fishbone/draw.h
Normal file
43
engine/include/fishbone/draw.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef __FISHBOWL_DRAW_H__
|
||||
#define __FISHBOWL_DRAW_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
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<struct fishbone::Vector3> vertices, std::vector<struct fishbone::Vector2> texcoords, std::vector<struct fishbone::Vector3> normals);
|
||||
~Mesh();
|
||||
};
|
||||
|
||||
class Renderer {
|
||||
struct Impl;
|
||||
Impl* impl;
|
||||
|
||||
public:
|
||||
Renderer();
|
||||
~Renderer();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
#ifndef __FISHBONE_FILE_H__
|
||||
#define __FISHBONE_FILE_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
class File;
|
||||
};
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
/* no includes */
|
||||
|
||||
namespace fishbone {
|
||||
class File {
|
||||
|
|
|
|||
|
|
@ -8,5 +8,7 @@
|
|||
#include <fishbone/file.h>
|
||||
#include <fishbone/window.h>
|
||||
#include <fishbone/resource.h>
|
||||
#include <fishbone/draw.h>
|
||||
#include <fishbone/time.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#ifndef __FISHBONE_MIXER_H__
|
||||
#define __FISHBONE_MIXER_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
class Mixer;
|
||||
};
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/sound.h>
|
||||
#include <fishbone/thread.h>
|
||||
|
||||
|
|
|
|||
7
engine/include/fishbone/pre.h
Normal file
7
engine/include/fishbone/pre.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef __FISHBONE_PRE_H__
|
||||
#define __FISHBONE_PRE_H__
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/types.h>
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
#ifndef __FISHBONE_THREAD_H__
|
||||
#define __FISHBONE_THREAD_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
class Resource;
|
||||
}; // namespace fishbone
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/file.h>
|
||||
|
||||
namespace fishbone {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __FISHBONE_SOUND_H__
|
||||
#define __FISHBONE_SOUND_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
#define FB_SOUND_DECL(prefix) \
|
||||
class prefix##SoundLoader; \
|
||||
class prefix##Sound
|
||||
|
|
@ -37,7 +39,6 @@ namespace fishbone {
|
|||
#undef LOADER
|
||||
}; // namespace fishbone
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/mixer.h>
|
||||
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
#ifndef __FISHBONE_THREAD_H__
|
||||
#define __FISHBONE_THREAD_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
class Thread;
|
||||
class Mutex;
|
||||
}; // namespace fishbone
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
/* no includes */
|
||||
|
||||
namespace fishbone {
|
||||
class Thread {
|
||||
|
|
|
|||
18
engine/include/fishbone/time.h
Normal file
18
engine/include/fishbone/time.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef __FISHBONE_TIME_H__
|
||||
#define __FISHBONE_TIME_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
using AccurateClock = std::chrono::time_point<std::chrono::high_resolution_clock, std::chrono::high_resolution_clock::duration>;
|
||||
|
||||
fishbone::AccurateClock accurateTime();
|
||||
};
|
||||
|
||||
/* no includes */
|
||||
|
||||
namespace fishbone {
|
||||
fishbone::AccurateClock accurateTime();
|
||||
};
|
||||
|
||||
#endif
|
||||
19
engine/include/fishbone/types.h
Normal file
19
engine/include/fishbone/types.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef __FISHBOWL_TYPES_H__
|
||||
#define __FISHBOWL_TYPES_H__
|
||||
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
struct Vector3 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -5,7 +5,7 @@ namespace fishbone {
|
|||
class Window;
|
||||
}; // namespace fishbone
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/pre.h>
|
||||
|
||||
namespace fishbone {
|
||||
class Window {
|
||||
|
|
@ -15,6 +15,8 @@ namespace fishbone {
|
|||
public:
|
||||
Window(std::string title, int width, int height);
|
||||
~Window();
|
||||
|
||||
void poll();
|
||||
};
|
||||
}; // namespace fishbone
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1,18 @@
|
|||
#include <fishbone/client.h>
|
||||
#include <fishbone/foundation.h>
|
||||
|
||||
fishbone::Client::Client(std::unordered_map<std::string, std::vector<std::string>> 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;
|
||||
}
|
||||
|
|
|
|||
34
engine/src/draw/opengl.cc
Normal file
34
engine/src/draw/opengl.cc
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include <fishbone/foundation.h>
|
||||
|
||||
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<struct fishbone::Vector3> vertices, std::vector<struct fishbone::Vector2> texcoords, std::vector<struct fishbone::Vector3> normals){
|
||||
}
|
||||
|
||||
fishbone::Mesh::~Mesh(){
|
||||
}
|
||||
|
||||
fishbone::Renderer::Renderer(){
|
||||
}
|
||||
|
||||
fishbone::Renderer::~Renderer(){
|
||||
}
|
||||
|
|
@ -1,22 +1,5 @@
|
|||
#include <fishbone/foundation.h>
|
||||
|
||||
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;
|
||||
|
|
|
|||
5
engine/src/time.cc
Normal file
5
engine/src/time.cc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <fishbone/foundation.h>
|
||||
|
||||
fishbone::AccurateClock fishbone::accurateTime(){
|
||||
return std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue