mesh/texture work

This commit is contained in:
Nishi 2026-06-06 01:04:29 +09:00
commit 5ff134abe4
19 changed files with 376 additions and 22 deletions

View file

@ -11,15 +11,25 @@ namespace fishbone {
#include <fishbone/window.h>
#include <fishbone/meshldr.h>
#include <fishbone/textureldr.h>
namespace fishbone {
class Texture {
void init(fishbone::Renderer* renderer, unsigned char* rgba, int width, int height);
struct Impl;
Impl* impl;
public:
Texture(fishbone::Renderer* renderer, unsigned char* rgba, int width, int height);
Texture(fishbone::Renderer* renderer, unsigned char* rgba, int width, int height) {
this->init(renderer, rgba, width, height);
}
Texture(fishbone::Renderer* renderer, fishbone::TextureData* data) {
this->init(renderer, data->rgba, data->width, data->height);
}
~Texture();
void use();
};
class Mesh {
@ -38,6 +48,10 @@ namespace fishbone {
~Mesh();
void draw();
void draw(struct fishbone::Vector3 pos);
void draw(struct fishbone::Vector3 pos, struct fishbone::Vector3 rot);
fishbone::Texture* texture;
};
class Renderer {
@ -47,7 +61,11 @@ namespace fishbone {
public:
Renderer(fishbone::Window* window);
~Renderer();
void prepare();
};
static float maxDistance = 64;
}; // namespace fishbone
#endif

View file

@ -21,9 +21,9 @@ namespace fishbone {
virtual size_t read(void* buffer, size_t size);
virtual size_t write(const void* buffer, size_t size);
bool good();
size_t size;
bool good;
};
}; // namespace fishbone

View file

@ -13,5 +13,7 @@
#include <fishbone/base.h>
#include <fishbone/meshldr.h>
#include <fishbone/log.h>
#include <fishbone/math.h>
#include <fishbone/textureldr.h>
#endif

View file

@ -11,6 +11,7 @@
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <fishbone/config.h>

View file

@ -0,0 +1,18 @@
#ifndef __FISHBONE_MATH_H__
#define __FISHBONE_MATH_H__
#include <fishbone/pre.h>
namespace fishbone {
float cot(float x);
};
/* no includes */
namespace fishbone {
float cot(float x);
static double pi = 3.14159265358979323846;
}; // namespace fishbone
#endif

View file

@ -14,6 +14,8 @@ namespace fishbone {
public:
MeshData(fishbone::File* file);
bool good();
std::vector<struct fishbone::Vector3> vertices;
std::vector<struct fishbone::Vector2> texcoords;
std::vector<struct fishbone::Vector3> normals;

View file

@ -23,10 +23,10 @@ namespace fishbone {
void lock();
void unlock();
static const int rate = 44100;
std::vector<fishbone::SoundLoader*> loaders;
std::vector<fishbone::Sound*> sounds;
float position[3];
static const int rate = 44100;
};
}; // namespace fishbone

View file

@ -0,0 +1,26 @@
#ifndef __FISHBONE_TEXLDR_H__
#define __FISHBONE_TEXLDR_H__
#include <fishbone/pre.h>
namespace fishbone {
class TextureData;
};
#include <fishbone/file.h>
namespace fishbone {
class TextureData {
public:
TextureData(fishbone::File* file);
~TextureData();
bool good();
unsigned char* rgba;
int width;
int height;
};
}; // namespace fishbone
#endif

View file

@ -5,11 +5,24 @@
namespace fishbone {
struct Vector2 {
struct fishbone::Vector2 operator+(struct fishbone::Vector2 v) const;
struct fishbone::Vector2 operator-(struct fishbone::Vector2 v) const;
float length();
struct fishbone::Vector2 normalize();
float x;
float y;
};
struct Vector3 {
struct fishbone::Vector3 operator+(struct fishbone::Vector3 v) const;
struct fishbone::Vector3 operator-(struct fishbone::Vector3 v) const;
struct fishbone::Vector3 operator*(struct fishbone::Vector3 v) const;
float length();
struct fishbone::Vector3 normalize();
float x;
float y;
float z;

View file

@ -18,6 +18,9 @@ namespace fishbone {
void poll();
void swapBuffer();
int width;
int height;
};
}; // namespace fishbone