Replacing Vector_2d with glm:vec2

Replacing Vector_2d with glm:vec2
This commit is contained in:
Alister
2021-11-13 15:15:38 +00:00
parent 7d40c7afd6
commit 8f9faaf6f3
26 changed files with 85 additions and 162 deletions

View File

@@ -98,6 +98,14 @@ namespace math
{
return radians {std::atan2 (y, x)};
}
inline void rotate(float x0, float y0, float* x, float* y, radians angle)
{
const float xa(*x - x0);
const float ya(*y - y0);
*x = xa * cos(angle) - ya * sin(angle) + x0;
*y = xa * sin(angle) + ya * cos(angle) + y0;
}
}
inline math::degrees operator"" _deg (long double v)

View File

@@ -1,15 +0,0 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <math/vector_2d.hpp>
#include <math/trig.hpp>
namespace math
{
void rotate (float x0, float y0, float* x, float* y, radians angle)
{
const float xa (*x - x0);
const float ya (*y - y0);
*x = xa * cos (angle) - ya * sin (angle) + x0;
*y = xa * sin (angle) + ya * cos (angle) + y0;
}
}

View File

@@ -1,64 +0,0 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#pragma once
#include <math/trig.hpp>
#include <ostream>
#include <tuple>
namespace math
{
struct vector_2d
{
union
{
float _data[2];
struct
{
float x;
float y;
};
};
vector_2d() : vector_2d (0.f, 0.f) {}
vector_2d (float x_, float y_)
: x (x_)
, y (y_)
{}
inline operator float*()
{
return _data;
}
inline operator float const*() const
{
return _data;
}
vector_2d operator* (float factor) const
{
return {x * factor, y * factor};
}
vector_2d operator+ (vector_2d const& other) const
{
return {x + other.x, y + other.y};
}
bool operator== (vector_2d const& rhs) const
{
return std::tie (x, y) == std::tie (rhs.x, rhs.y);
}
friend std::ostream& operator<< (std::ostream& os, vector_2d const& x)
{
return os << x.x << ", " << x.y;
}
};
void rotate (float x0, float y0, float* x, float* y, radians);
inline vector_2d rotate (vector_2d const& around, vector_2d point, radians angle)
{
rotate (around.x, around.y, &point.x, &point.y, angle);
return point;
}
}

View File

@@ -10,7 +10,6 @@
#include <algorithm>
#include <external/tsl/robin_map.h>
#include <boost/optional.hpp>
#include <math/vector_2d.hpp>
#include <noggit/TextureManager.h>
#include <noggit/texture_set.hpp>
#include <noggit/SceneObject.hpp>
@@ -18,7 +17,6 @@
#include <noggit/ChunkWater.hpp>
#include <QObject>
class MapView;
class MapChunk;

View File

@@ -5,6 +5,7 @@
#include <opengl/context.inl>
#include <noggit/DBC.h>
#include <boost/format.hpp>
#include <glm/vec2.hpp>
LiquidTextureManager::LiquidTextureManager(noggit::NoggitRenderContext context)
@@ -22,7 +23,7 @@ void LiquidTextureManager::upload()
const DBCFile::Record record = gLiquidTypeDB.getRecord(i);
unsigned liquid_type_id = record.getInt(LiquidTypeDB::ID);
int type = record.getInt(LiquidTypeDB::Type);
math::vector_2d anim = {record.getFloat(LiquidTypeDB::AnimationX), record.getFloat(LiquidTypeDB::AnimationY)};
glm::vec2 anim = {record.getFloat(LiquidTypeDB::AnimationX), record.getFloat(LiquidTypeDB::AnimationY)};
int shader_type = record.getInt(LiquidTypeDB::ShaderType);
std::string filename;
@@ -32,7 +33,7 @@ void LiquidTextureManager::upload()
{
filename = "XTextures\\river\\lake_a.%d.blp";
// default param for water
anim = math::vector_2d(1.f, 0.f);
anim = glm::vec2(1.f, 0.f);
}
else
[[likely]]

View File

@@ -5,12 +5,10 @@
#include <noggit/TextureManager.h>
#include <noggit/ContextObject.hpp>
#include <math/vector_2d.hpp>
#include <opengl/context.hpp>
#include <opengl/scoped.hpp>
#include <external/tsl/robin_map.h>
#include <tuple>
#include <glm/vec2.hpp>
class LiquidTextureManager
{
@@ -22,13 +20,13 @@ public:
void upload();
void unload();
tsl::robin_map<unsigned, std::tuple<GLuint, math::vector_2d, int, unsigned>> const& getTextureFrames() { return _texture_frames_map; };
tsl::robin_map<unsigned, std::tuple<GLuint, glm::vec2, int, unsigned>> const& getTextureFrames() { return _texture_frames_map; };
private:
bool _uploaded = false;
// liquidTypeRecID : (array, (animation_x, animation_y), liquid_type)
tsl::robin_map<unsigned, std::tuple<GLuint, math::vector_2d, int, unsigned>> _texture_frames_map;
tsl::robin_map<unsigned, std::tuple<GLuint, glm::vec2, int, unsigned>> _texture_frames_map;
noggit::NoggitRenderContext _context;
};

View File

@@ -837,11 +837,11 @@ std::vector<MapChunk*> MapTile::chunks_in_rect (math::vector_3d const& pos, floa
for (size_t tx (0); tx < 16; ++tx)
{
MapChunk* chunk = mChunks[ty][tx].get();
math::vector_2d l_rect{pos.x - radius, pos.z - radius};
math::vector_2d r_rect{pos.x + radius, pos.z + radius};
glm::vec2 l_rect{pos.x - radius, pos.z - radius};
glm::vec2 r_rect{pos.x + radius, pos.z + radius};
math::vector_2d l_chunk{chunk->xbase, chunk->zbase};
math::vector_2d r_chunk{chunk->xbase + CHUNKSIZE, chunk->zbase + CHUNKSIZE};
glm::vec2 l_chunk{chunk->xbase, chunk->zbase};
glm::vec2 r_chunk{chunk->xbase + CHUNKSIZE, chunk->zbase + CHUNKSIZE};
if ((l_rect.x < r_chunk.x) && (r_rect.x >= l_chunk.x) && (l_rect.y < r_chunk.y) && (r_rect.y >= l_chunk.y))
{

View File

@@ -1505,7 +1505,7 @@ void Model::draw( math::matrix_4x4 const& model_view
m2_shader.attrib("bones_indices", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 4));
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) + 8));
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) * 2 + 8));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) * 2 + 8 + sizeof(::math::vector_2d)));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) * 2 + 8 + sizeof(glm::vec2)));
}
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
@@ -1808,7 +1808,7 @@ void Model::setupVAO(opengl::scoped::use_program& m2_shader)
m2_shader.attribi("bones_indices",4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 4));
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 8));
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) * 2 + 8));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) * 2 + 8 + sizeof(::math::vector_2d)));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) * 2 + 8 + sizeof(glm::vec2)));
}
{

View File

@@ -1,11 +1,10 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#pragma once
#include <math/vector_2d.hpp>
#include <math/vector_3d.hpp>
#include <cstdint>
#include <glm/vec2.hpp>
#pragma pack(push,1)
@@ -160,7 +159,7 @@ struct ModelVertex {
uint8_t weights[4];
uint8_t bones[4];
math::vector_3d normal;
math::vector_2d texcoords[2];
glm::vec2 texcoords[2];
};
struct ModelView {

View File

@@ -38,8 +38,8 @@ public:
explicit ModelInstance(std::string const& filename, ENTRY_MDDF const*d, noggit::NoggitRenderContext context);
ModelInstance(ModelInstance const& other) = delete;
ModelInstance& operator= (ModelInstance const& other) = delete;
ModelInstance(ModelInstance const& other) = default;
ModelInstance& operator= (ModelInstance const& other) = default;
ModelInstance (ModelInstance&& other)
: SceneObject(other._type, other._context, other._filename)

View File

@@ -160,10 +160,10 @@ ParticleSystem::ParticleSystem(ParticleSystem&& other)
}
void ParticleSystem::initTile(math::vector_2d *tc, int num)
void ParticleSystem::initTile(glm::vec2 *tc, int num)
{
math::vector_2d otc[4];
math::vector_2d a, b;
glm::vec2 otc[4];
glm::vec2 a, b;
int x = num % cols;
int y = num / cols;
a.x = x * (1.0f / cols);
@@ -319,7 +319,7 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
std::vector<math::vector_3d> vertices;
std::vector<math::vector_3d> offsets;
std::vector<math::vector_4d> colors_data;
std::vector<math::vector_2d> texcoords;
std::vector<glm::vec2> texcoords;
std::uint16_t indice = 0;
@@ -460,7 +460,7 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, math::vector_4d>(_colors_vbo, colors_data, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STREAM_DRAW);
shader.uniform("alpha_test", alpha_test);
@@ -916,7 +916,7 @@ void RibbonEmitter::draw( opengl::scoped::use_program& shader
std::vector<std::uint16_t> indices;
std::vector<math::vector_3d> vertices;
std::vector<math::vector_2d> texcoords;
std::vector<glm::vec2> texcoords;
//model->_textures[_texture_ids[0]]->bind();
@@ -965,7 +965,7 @@ void RibbonEmitter::draw( opengl::scoped::use_program& shader
}
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STREAM_DRAW);
opengl::scoped::vao_binder const _(_vao);

View File

@@ -48,7 +48,7 @@ public:
};
struct TexCoordSet {
math::vector_2d tc[4];
glm::vec2 tc[4];
};
class ParticleSystem
@@ -69,7 +69,7 @@ class ParticleSystem
int manimtime;
int rows, cols;
std::vector<TexCoordSet> tiles;
void initTile(math::vector_2d *tc, int num);
void initTile(glm::vec2 *tc, int num);
bool billboard;
float rem;

View File

@@ -661,6 +661,7 @@ void main()
for (int i = 0; i < cnum; ++i)
{
basepos1[i] = basepos2[i] = math::vector_3d(math::cos(angles[i])*rad, math::sin(angles[i])*rad, 0);
math::rotate(0, 0, &basepos1[i].x, &basepos1[i].z, math::radians(math::constants::pi*2.0f / hseg * h));
math::rotate(0, 0, &basepos2[i].x, &basepos2[i].z, math::radians(math::constants::pi*2.0f / hseg * (h + 1)));
}

View File

@@ -1,6 +1,4 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <math/vector_2d.hpp>
#include <noggit/TextureManager.h>
#include <noggit/Log.h> // LogDebug
@@ -8,6 +6,7 @@
#include <QtGui/QPixmap>
#include <algorithm>
#include <glm/vec2.hpp>
decltype (TextureManager::_) TextureManager::_;
decltype (TextureManager::_tex_arrays) TextureManager::_tex_arrays;
@@ -479,14 +478,14 @@ namespace noggit
GLuint const& vertices_vbo = _buffers[1];
GLuint const& texcoords_vbo = _buffers[2];
std::vector<math::vector_2d> vertices =
std::vector<glm::vec2> vertices =
{
{-1.0f, -1.0f}
,{-1.0f, 1.0f}
,{ 1.0f, 1.0f}
,{ 1.0f, -1.0f}
};
std::vector<math::vector_2d> texcoords =
std::vector<glm::vec2> texcoords =
{
{0.f, 0.f}
,{0.f, 1.0f}
@@ -495,8 +494,8 @@ namespace noggit
};
std::vector<std::uint16_t> indices = {0,1,2, 2,3,0};
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(vertices_vbo, vertices, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(texcoords_vbo, texcoords, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER,glm::vec2>(vertices_vbo, vertices, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER,glm::vec2>(texcoords_vbo, texcoords, GL_STATIC_DRAW);
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(indices_vbo, indices, GL_STATIC_DRAW);

View File

@@ -211,7 +211,7 @@ int TileWater::getType(size_t layer)
void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
{
tsl::robin_map<unsigned, std::tuple<GLuint, math::vector_2d, int, unsigned>> const& tex_frames = tex_manager->getTextureFrames();
tsl::robin_map<unsigned, std::tuple<GLuint, glm::vec2, int, unsigned>> const& tex_frames = tex_manager->getTextureFrames();
// create opengl resources if needed
if (_need_buffer_update)
@@ -256,7 +256,7 @@ void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
auto& layer_params = _render_layers[layer_counter];
// fill per-chunk data
std::tuple<GLuint, math::vector_2d, int, unsigned> const& tex_profile = tex_frames.at(layer.liquidID());
std::tuple<GLuint, glm::vec2, int, unsigned> const& tex_profile = tex_frames.at(layer.liquidID());
opengl::LiquidChunkInstanceDataUniformBlock& params_data = layer_params.chunk_data[n_chunks];
params_data.xbase = layer.getChunk()->xbase;
@@ -281,7 +281,7 @@ void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
params_data.type = std::get<2>(tex_profile);
params_data.n_texture_frames = std::get<3>(tex_profile);
math::vector_2d anim = std::get<1>(tex_profile);
glm::vec2 anim = std::get<1>(tex_profile);
params_data.anim_u = anim.x;
params_data.anim_v = anim.y;
@@ -300,7 +300,7 @@ void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
for (int x_v = 0; x_v < 9; ++x_v)
{
const unsigned v_index = z_v * 9 + x_v;
math::vector_2d& tex_coord = tex_coords[v_index];
glm::vec2& tex_coord = tex_coords[v_index];
layer_params.vertex_data[n_chunks][v_index] = math::vector_4d(vertices[v_index].y, depth[v_index], tex_coord.x, tex_coord.y);
}
}

View File

@@ -799,7 +799,7 @@ void WMOGroup::upload()
if (header.flags.has_two_motv)
{
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d> ( _texcoords_buffer_2
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2> ( _texcoords_buffer_2
, _texcoords_2
, GL_STATIC_DRAW
);
@@ -977,7 +977,7 @@ void WMOGroup::load()
assert (fourcc == 'MOTV');
_texcoords.resize (size / sizeof (::math::vector_2d));
_texcoords.resize (size / sizeof (glm::vec2));
f.read (_texcoords.data (), size);
@@ -1271,7 +1271,7 @@ void WMOGroup::load()
}
else
{
_texcoords_2.resize(size / sizeof(::math::vector_2d));
_texcoords_2.resize(size / sizeof(glm::vec2));
f.read(_texcoords_2.data(), size);
}

View File

@@ -201,8 +201,8 @@ private:
std::vector<::math::vector_3d> _vertices;
std::vector<::math::vector_3d> _normals;
std::vector<::math::vector_2d> _texcoords;
std::vector<::math::vector_2d> _texcoords_2;
std::vector<glm::vec2> _texcoords;
std::vector<glm::vec2> _texcoords_2;
std::vector<::math::vector_4d> _vertex_colors;
std::vector<unsigned> _render_batch_mapping;
std::vector<uint16_t> _indices;

View File

@@ -4534,8 +4534,8 @@ void World::setupChunkBuffers()
// vertices
math::vector_2d vertices[mapbufsize];
math::vector_2d *ttv = vertices;
glm::vec2 vertices[mapbufsize];
glm::vec2 *ttv = vertices;
for (int j = 0; j < 17; ++j)
{
@@ -4551,7 +4551,7 @@ void World::setupChunkBuffers()
xpos += UNITSIZE*0.5f;
}
math::vector_2d v = math::vector_2d(xpos, zpos);
auto v = glm::vec2(xpos, zpos);
*ttv++ = v;
}
}
@@ -4656,7 +4656,7 @@ void World::setupChunkBuffers()
}
// tex coords
math::vector_2d temp[mapbufsize], *vt;
glm::vec2 temp[mapbufsize], *vt;
float tx, ty;
// init texture coordinates for detail map:
@@ -4674,7 +4674,7 @@ void World::setupChunkBuffers()
if (is_lod)
tx += detail_half;
*vt++ = math::vector_2d(tx, ty);
*vt++ = glm::vec2(tx, ty);
}
}
@@ -4698,22 +4698,22 @@ void World::setupLiquidChunkBuffers()
ZoneScoped;
// vertices
math::vector_2d vertices[768 / 2];
math::vector_2d* vt = vertices;
glm::vec2 vertices[768 / 2];
glm::vec2* vt = vertices;
for (int z = 0; z < 8; ++z)
{
for (int x = 0; x < 8; ++x)
{
// first triangle
*vt++ = math::vector_2d(UNITSIZE * x, UNITSIZE * z);
*vt++ = math::vector_2d(UNITSIZE * x, UNITSIZE * (z + 1));
*vt++ = math::vector_2d(UNITSIZE * (x + 1), UNITSIZE * z);
*vt++ = glm::vec2(UNITSIZE * x, UNITSIZE * z);
*vt++ = glm::vec2(UNITSIZE * x, UNITSIZE * (z + 1));
*vt++ = glm::vec2(UNITSIZE * (x + 1), UNITSIZE * z);
// second triangle
*vt++ = math::vector_2d(UNITSIZE * (x + 1), UNITSIZE * z);
*vt++ = math::vector_2d(UNITSIZE * x, UNITSIZE * (z + 1));
*vt++ = math::vector_2d(UNITSIZE * (x + 1), UNITSIZE * (z + 1));
*vt++ = glm::vec2(UNITSIZE * (x + 1), UNITSIZE * z);
*vt++ = glm::vec2(UNITSIZE * x, UNITSIZE * (z + 1));
*vt++ = glm::vec2(UNITSIZE * (x + 1), UNITSIZE * (z + 1));
}
}

View File

@@ -14,7 +14,7 @@
namespace
{
inline math::vector_2d default_uv(int px, int pz)
inline glm::vec2 default_uv(int px, int pz)
{
return {static_cast<float>(px) / 4.f, static_cast<float>(pz) / 4.f};
}
@@ -76,7 +76,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq&
if (_liquid_vertex_format == 1)
{
_depth[v_index] = 1.0f;
_tex_coords[v_index] = math::vector_2d(static_cast<float>(v.magma.x) / 255.f, static_cast<float>(v.magma.y) / 255.f);
_tex_coords[v_index] = glm::vec2(static_cast<float>(v.magma.x) / 255.f, static_cast<float>(v.magma.y) / 255.f);
}
else
{

View File

@@ -7,6 +7,7 @@
#include <noggit/MPQ.h>
#include <opengl/scoped.hpp>
#include <array>
#include <glm/vec2.hpp>
class MapChunk;
class sExtendableArray;
@@ -46,7 +47,7 @@ public:
std::array<math::vector_3d, 9 * 9>& getVertices() { return _vertices; };
std::array<float, 9 * 9>& getDepth() { return _depth; };
std::array<math::vector_2d, 9 * 9>& getTexCoords() { return _tex_coords; };
std::array<glm::vec2, 9 * 9>& getTexCoords() { return _tex_coords; };
float min() const { return _minimum; }
float max() const { return _maximum; }
@@ -91,7 +92,7 @@ private:
std::uint64_t _subchunks;
std::array<math::vector_3d, 9 * 9> _vertices;
std::array<float, 9 * 9> _depth;
std::array<math::vector_2d, 9 * 9> _tex_coords;
std::array<glm::vec2, 9 * 9> _tex_coords;
std::map<int, std::vector<std::uint16_t>> _indices_by_lod;

View File

@@ -153,8 +153,8 @@ public:
auto tiles_in_rect (math::vector_3d const& pos, float radius)
{
math::vector_2d l_chunk{pos.x - radius, pos.z - radius};
math::vector_2d r_chunk{pos.x + radius, pos.z + radius};
glm::vec2 l_chunk{pos.x - radius, pos.z - radius};
glm::vec2 r_chunk{pos.x + radius, pos.z + radius};
return tiles<true>
( [this, pos, radius, l_chunk, r_chunk] (tile_index const& index, MapTile*)
@@ -162,8 +162,8 @@ public:
if (!hasTile(index) || radius == 0.f)
return false;
math::vector_2d l_tile{index.x * TILESIZE, index.z * TILESIZE};
math::vector_2d r_tile{index.x * TILESIZE + TILESIZE, index.z * TILESIZE + TILESIZE};
glm::vec2 l_tile{index.x * TILESIZE, index.z * TILESIZE};
glm::vec2 r_tile{index.x * TILESIZE + TILESIZE, index.z * TILESIZE + TILESIZE};
return ((l_chunk.x < r_tile.x) && (r_chunk.x >= l_tile.x) && (l_chunk.y < r_tile.y) && (r_chunk.y >= l_tile.y));
}

View File

@@ -221,7 +221,7 @@ void wmo_liquid::upload(opengl::scoped::use_program& water_shader)
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_buffer, indices, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_buffer, vertices, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(_tex_coord_buffer, tex_coords, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2>(_tex_coord_buffer, tex_coords, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, float>(_depth_buffer, depths, GL_STATIC_DRAW);
opengl::scoped::index_buffer_manual_binder indices_binder (_indices_buffer);

View File

@@ -1,10 +1,6 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#pragma once
// #define USEBLSFILES
#include <math/vector_2d.hpp>
#include <math/vector_3d.hpp>
#include <noggit/MPQ.h>
#include <noggit/TextureManager.h>
@@ -117,7 +113,7 @@ private:
int _liquid_id;
std::vector<float> depths;
std::vector<math::vector_2d> tex_coords;
std::vector<glm::vec2> tex_coords;
std::vector<math::vector_3d> vertices;
std::vector<std::uint16_t> indices;

View File

@@ -5,7 +5,7 @@
#include <opengl/context.hpp>
#include <noggit/Log.h>
#include <math/vector_2d.hpp>
#include <glm/vec2.hpp>
#include <math/vector_3d.hpp>
#include <math/vector_4d.hpp>
@@ -1070,7 +1070,7 @@ void opengl::context::bufferSubData(GLuint buffer, GLintptr offset, std::vector<
}
template void opengl::context::bufferData<GL_ARRAY_BUFFER, float>(GLuint buffer, std::vector<float> const& data, GLenum usage);
template void opengl::context::bufferData<GL_ARRAY_BUFFER, math::vector_2d>(GLuint buffer, std::vector<math::vector_2d> const& data, GLenum usage);
template void opengl::context::bufferData<GL_ARRAY_BUFFER, glm::vec2>(GLuint buffer, std::vector<glm::vec2> const& data, GLenum usage);
template void opengl::context::bufferData<GL_ARRAY_BUFFER, math::vector_3d>(GLuint buffer, std::vector<math::vector_3d> const& data, GLenum usage);
template void opengl::context::bufferData<GL_ARRAY_BUFFER, math::vector_4d>(GLuint buffer, std::vector<math::vector_4d> const& data, GLenum usage);
template void opengl::context::bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint8_t>(GLuint buffer, std::vector<std::uint8_t> const& data, GLenum usage);
@@ -1078,7 +1078,7 @@ template void opengl::context::bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t
template void opengl::context::bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint32_t>(GLuint buffer, std::vector<std::uint32_t> const& data, GLenum usage);
template void opengl::context::bufferSubData<GL_ARRAY_BUFFER, float>(GLuint buffer, GLintptr offset, std::vector<float> const& data);
template void opengl::context::bufferSubData<GL_ARRAY_BUFFER, math::vector_2d>(GLuint buffer, GLintptr offset, std::vector<math::vector_2d> const& data);
template void opengl::context::bufferSubData<GL_ARRAY_BUFFER, glm::vec2>(GLuint buffer, GLintptr offset, std::vector<glm::vec2> const& data);
template void opengl::context::bufferSubData<GL_ARRAY_BUFFER, math::vector_3d>(GLuint buffer, GLintptr offset, std::vector<math::vector_3d> const& data);
template void opengl::context::bufferSubData<GL_ARRAY_BUFFER, math::vector_4d>(GLuint buffer, GLintptr offset, std::vector<math::vector_4d> const& data);
template void opengl::context::bufferSubData<GL_ARRAY_BUFFER>(GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid const* data);

View File

@@ -1,7 +1,6 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <math/matrix_4x4.hpp>
#include <math/vector_2d.hpp>
#include <math/vector_3d.hpp>
#include <math/vector_4d.hpp>
#include <opengl/scoped.hpp>
@@ -296,17 +295,17 @@ namespace opengl
{
gl.uniform3fv (pos, value.size(), reinterpret_cast<const GLfloat*>(value.data()));
}
void use_program::uniform (std::string const& name, math::vector_2d const& value)
void use_program::uniform (std::string const& name, glm::vec2 const& value)
{
GLuint loc = uniform_location (name);
if (loc < 0)
return;
gl.uniform2fv (loc, 1, value);
gl.uniform2fv(loc, 1, glm::value_ptr(value));
}
void use_program::uniform (GLint pos, math::vector_2d const& value)
void use_program::uniform (GLint pos, glm::vec2 const& value)
{
gl.uniform2fv (pos, 1, value);
gl.uniform2fv (pos, 1, glm::value_ptr(value));
}
void use_program::uniform (std::string const& name, math::vector_3d const& value)
{
@@ -359,7 +358,7 @@ namespace opengl
_enabled_vertex_attrib_arrays.emplace (location);
gl.vertexAttribPointer (location, 1, GL_FLOAT, GL_FALSE, 0, data.data());
}
void use_program::attrib (std::string const& name, std::vector<math::vector_2d> const& data)
void use_program::attrib (std::string const& name, std::vector<glm::vec2> const& data)
{
GLuint const location (attrib_location (name));
gl.enableVertexAttribArray (location);

View File

@@ -16,6 +16,8 @@
#include <cstdint>
#include <unordered_map>
#include <external/tsl/robin_map.h>
#include <glm/vec2.hpp>
#include <glm/gtc/type_ptr.hpp>
namespace math
{
@@ -104,8 +106,8 @@ namespace opengl
void uniform (GLint pos, bool);
void uniform (std::string const& name, std::vector<math::vector_3d> const& value);
void uniform (GLint pos, std::vector<math::vector_3d> const& value);
void uniform (std::string const& name, math::vector_2d const&);
void uniform (GLint pos, math::vector_2d const&);
void uniform (std::string const& name, glm::vec2 const&);
void uniform (GLint pos, glm::vec2 const&);
void uniform (std::string const& name, math::vector_3d const&);
void uniform (GLint pos, math::vector_3d const&);
void uniform (std::string const& name, math::vector_4d const&);
@@ -123,7 +125,7 @@ namespace opengl
void sampler (std::string const& name, GLenum texture_slot, texture*);
void attrib (std::string const& name, std::vector<float> const&);
void attrib (std::string const& name, std::vector<math::vector_2d> const&);
void attrib (std::string const& name, std::vector<glm::vec2> const&);
void attrib (std::string const& name, std::vector<math::vector_3d> const&);
void attrib (std::string const& name, math::vector_3d const*);
void attrib (std::string const& name, math::matrix_4x4 const*, GLuint divisor = 0);