2022-08-28 04:23:13 +02:00
|
|
|
// Copyright (C) 2022 RozK
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef _RK_ENGINE_RENDER_OPENGLES_H
|
|
|
|
#define _RK_ENGINE_RENDER_OPENGLES_H
|
|
|
|
|
|
|
|
#include "../render.hpp"
|
|
|
|
#include "render_context.hpp"
|
|
|
|
#include <GLES3/gl32.h>
|
|
|
|
#include <GLES3/gl3ext.h>
|
|
|
|
#include <GLES3/gl3platform.h>
|
|
|
|
|
|
|
|
enum : rk_uint {
|
|
|
|
RK_VERTICES_BINDING = 0,
|
|
|
|
RK_PARAMS_BINDING = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_shader {
|
|
|
|
GLuint vertex;
|
|
|
|
GLuint fragment;
|
|
|
|
GLuint program;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_texture {
|
|
|
|
rk_uint nlevels;
|
|
|
|
GLuint texture;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_triangles {
|
|
|
|
rk_uint size;
|
|
|
|
GLuint array;
|
|
|
|
GLuint vertices;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_vertices {
|
|
|
|
rk_uint vertex_size;
|
|
|
|
rk_uint layout;
|
|
|
|
GLuint array;
|
|
|
|
GLuint vertices;
|
|
|
|
GLuint indices;
|
|
|
|
};
|
|
|
|
|
2022-12-20 06:33:31 +01:00
|
|
|
struct rk_vec3s {
|
|
|
|
rk_short x;
|
|
|
|
rk_short y;
|
|
|
|
rk_short z;
|
|
|
|
rk_short pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
union rk_pack_src {
|
|
|
|
rk_ubyte const * __restrict ptr;
|
|
|
|
rk_vec3 const * __restrict vec3_ptr;
|
|
|
|
|
|
|
|
inline rk_pack_src() {}
|
|
|
|
inline rk_pack_src(rk_ubyte const * const __restrict src) : ptr(src) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
union rk_pack_dst {
|
|
|
|
rk_ubyte * __restrict ptr;
|
|
|
|
rk_vec3 * __restrict vec3_ptr;
|
|
|
|
rk_vec3s * __restrict vec3s_ptr;
|
|
|
|
rk_int * __restrict int_ptr;
|
|
|
|
|
|
|
|
inline rk_pack_dst() {}
|
|
|
|
inline rk_pack_dst(rk_ubyte * const __restrict dst) : ptr(dst) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (*rk_packer_fn)(rk_pack_dst, rk_pack_src);
|
2022-12-17 16:50:41 +01:00
|
|
|
|
|
|
|
struct rk_packer {
|
|
|
|
rk_packer_fn pack;
|
|
|
|
rk_uint dst_incr;
|
|
|
|
rk_uint src_incr;
|
|
|
|
};
|
2022-12-17 04:58:19 +01:00
|
|
|
|
2022-08-28 04:23:13 +02:00
|
|
|
struct rk_command {
|
2022-12-17 16:50:41 +01:00
|
|
|
GLuint nvertices;
|
2022-08-28 04:23:13 +02:00
|
|
|
GLuint ninstances;
|
|
|
|
GLuint base_index;
|
|
|
|
GLint base_vertex;
|
|
|
|
GLuint base_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_batch {
|
|
|
|
rk_uint size;
|
2022-12-17 04:58:19 +01:00
|
|
|
rk_uint nparams;
|
2022-08-28 04:23:13 +02:00
|
|
|
rk_uint params_size;
|
2022-12-17 16:50:41 +01:00
|
|
|
rk_uint packed_size;
|
2022-08-28 04:23:13 +02:00
|
|
|
rk_ushort * indices;
|
|
|
|
rk_command * commands;
|
2022-12-17 16:50:41 +01:00
|
|
|
rk_packer * packers;
|
2022-12-17 04:58:19 +01:00
|
|
|
rk_ubyte * params;
|
2022-08-28 04:23:13 +02:00
|
|
|
GLuint params_buffer;
|
|
|
|
GLuint commands_buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _RK_ENGINE_RENDER_OPENGLES_H
|