rk_engine/cpp/render/render_opengles.hpp

114 lines
2.3 KiB
C++
Raw Normal View History

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 "../types.hpp"
2022-08-28 04:23:13 +02:00
#include <GLES3/gl32.h>
#include <GLES3/gl3ext.h>
#include <GLES3/gl3platform.h>
2022-12-20 07:01:58 +01:00
enum : GLuint {
2022-08-28 04:23:13 +02:00
RK_VERTICES_BINDING = 0,
2022-12-30 10:50:56 +01:00
RK_PARAMS_BINDING_BASE = 1
2022-08-28 04:23:13 +02:00
};
struct rk_shader {
GLuint vertex;
GLuint fragment;
GLuint program;
};
struct rk_texture {
2022-12-20 07:01:58 +01:00
unsigned nlevels;
2022-08-28 04:23:13 +02:00
GLuint texture;
};
struct rk_triangles {
2022-12-20 07:01:58 +01:00
unsigned size;
2022-08-28 04:23:13 +02:00
GLuint array;
GLuint vertices;
};
struct rk_vertices {
2022-12-20 07:01:58 +01:00
unsigned vertex_size;
unsigned layout;
2022-08-28 04:23:13 +02:00
GLuint array;
GLuint vertices;
GLuint indices;
};
2022-12-30 10:50:56 +01:00
struct rk_command {
GLuint nvertices;
GLuint ninstances;
GLuint base_index;
GLint base_vertex;
GLuint base_instance;
};
2022-12-26 14:05:06 +01:00
struct rk_vec3_float {
float x;
float y;
float z;
};
struct rk_vec3_short {
2022-12-20 06:33:31 +01:00
rk_short x;
rk_short y;
rk_short z;
rk_short pad;
};
2022-12-26 14:05:06 +01:00
typedef rk_int rk_vec3_int10;
typedef rk_uint rk_vec3_uint10;
2022-12-26 14:05:06 +01:00
struct rk_mat3_float {
rk_vec3_float x;
rk_vec3_float y;
rk_vec3_float z;
};
struct rk_mat3_int10 {
rk_vec3_int10 x;
rk_vec3_int10 y;
rk_vec3_int10 z;
};
2022-12-30 10:50:56 +01:00
typedef void (*rk_packer)(
unsigned const, // count
rk_ushort const * const, // indices
rk_ubyte *, // dst
rk_ubyte const * const); // src
2022-12-17 04:58:19 +01:00
2022-12-30 10:50:56 +01:00
struct rk_parameter {
unsigned offset;
unsigned size;
rk_packer packer;
2022-08-28 04:23:13 +02:00
};
struct rk_batch {
2022-12-30 10:50:56 +01:00
unsigned max_size;
2022-12-20 07:01:58 +01:00
unsigned nparams;
2022-08-28 04:23:13 +02:00
rk_ushort * indices;
rk_command * commands;
2022-12-30 10:50:56 +01:00
rk_parameter * params;
rk_ubyte * packed_params;
GLuint indirect_buffer;
GLuint params_array;
2022-08-28 04:23:13 +02:00
};
#endif // _RK_ENGINE_RENDER_OPENGLES_H