switch shader variation from runtime-with-tags to dynamic with #ifdefs;
support making all definitions static so you can have multiple copies of file (with different #ifdefs); move all tables to end of file (this will have to be undone later because IIRC it's not compatible with C++ or with some compilers or something, but it'll make my life easier in the interim);
This commit is contained in:
parent
3a2c54d4a0
commit
c588d29e95
2746
stb_voxel_render.h
2746
stb_voxel_render.h
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,14 @@
|
|||||||
//#define VHEIGHT_TEST
|
//#define VHEIGHT_TEST
|
||||||
//#define STBVOX_OPTIMIZED_VHEIGHT
|
//#define STBVOX_OPTIMIZED_VHEIGHT
|
||||||
|
|
||||||
|
#define STBVOX_ICONFIG_OPENGL_3_1_COMPATIBILITY
|
||||||
|
#define STBVOX_CONFIG_OPENGL_MODELVIEW
|
||||||
|
#define STBVOX_ICONFIG_TEXTURED
|
||||||
|
#define STBVOX_ICONFIG_GLSL
|
||||||
|
#define STBVOX_CONFIG_PREFER_TEXBUFFER
|
||||||
|
//#define STBVOX_CONFIG_LIGHTING_SIMPLE
|
||||||
|
#define STBVOX_CONFIG_FOG_SMOOTHSTEP
|
||||||
|
|
||||||
#define STBVOX_ROTATION_IN_LIGHTING
|
#define STBVOX_ROTATION_IN_LIGHTING
|
||||||
#define STB_VOXEL_RENDER_IMPLEMENTATION
|
#define STB_VOXEL_RENDER_IMPLEMENTATION
|
||||||
#include "stb_voxel_render.h"
|
#include "stb_voxel_render.h"
|
||||||
@ -606,7 +614,6 @@ void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh
|
|||||||
map->block_tex1_face = minecraft_tex1_for_blocktype;
|
map->block_tex1_face = minecraft_tex1_for_blocktype;
|
||||||
map->block_color_face = minecraft_color_for_blocktype;
|
map->block_color_face = minecraft_color_for_blocktype;
|
||||||
map->block_geometry = minecraft_geom_for_blocktype;
|
map->block_geometry = minecraft_geom_for_blocktype;
|
||||||
stbvox_config_set_z_precision(&rm->mm, 1);
|
|
||||||
|
|
||||||
// we're going to build 4 meshes in parallel, each covering 2x2 chunks
|
// we're going to build 4 meshes in parallel, each covering 2x2 chunks
|
||||||
stbvox_reset_buffers(&rm->mm);
|
stbvox_reset_buffers(&rm->mm);
|
||||||
|
@ -191,7 +191,8 @@ void setup_uniforms(float pos[3])
|
|||||||
int i,j;
|
int i,j;
|
||||||
step += 1.0f/60.0f;
|
step += 1.0f/60.0f;
|
||||||
for (i=0; i < STBVOX_UNIFORM_count; ++i) {
|
for (i=0; i < STBVOX_UNIFORM_count; ++i) {
|
||||||
stbvox_uniform_info *ui = stbvox_get_uniform_info(&g_mesh_maker, i);
|
stbvox_uniform_info raw, *ui=&raw;
|
||||||
|
stbvox_get_uniform_info(&raw, i);
|
||||||
uniform_loc[i] = -1;
|
uniform_loc[i] = -1;
|
||||||
|
|
||||||
if (i == STBVOX_UNIFORM_texscale || i == STBVOX_UNIFORM_texgen || i == STBVOX_UNIFORM_color_table)
|
if (i == STBVOX_UNIFORM_texscale || i == STBVOX_UNIFORM_texgen || i == STBVOX_UNIFORM_color_table)
|
||||||
@ -231,7 +232,8 @@ void setup_uniforms(float pos[3])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STBVOX_UNIFORM_ambient: {
|
case STBVOX_UNIFORM_ambient: {
|
||||||
float bright = 0.75;
|
float bright = 1.0;
|
||||||
|
//float bright = 0.75;
|
||||||
float amb[3][3];
|
float amb[3][3];
|
||||||
|
|
||||||
// ambient direction is sky-colored upwards
|
// ambient direction is sky-colored upwards
|
||||||
@ -278,8 +280,11 @@ GLuint unitex[64], unibuf[64];
|
|||||||
void make_texture_buffer_for_uniform(int uniform, int slot)
|
void make_texture_buffer_for_uniform(int uniform, int slot)
|
||||||
{
|
{
|
||||||
GLenum type;
|
GLenum type;
|
||||||
stbvox_uniform_info *ui = stbvox_get_uniform_info(&g_mesh_maker, uniform);
|
stbvox_uniform_info raw, *ui=&raw;
|
||||||
GLint uloc = stbgl_find_uniform(main_prog, ui->name);
|
GLint uloc;
|
||||||
|
|
||||||
|
stbvox_get_uniform_info(ui, uniform);
|
||||||
|
uloc = stbgl_find_uniform(main_prog, ui->name);
|
||||||
|
|
||||||
if (uniform == STBVOX_UNIFORM_color_table)
|
if (uniform == STBVOX_UNIFORM_color_table)
|
||||||
((float *)ui->default_value)[63*4+3] = 1.0f; // emissive
|
((float *)ui->default_value)[63*4+3] = 1.0f; // emissive
|
||||||
@ -355,35 +360,19 @@ void render_init(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *binds[] = { "attr_vertex", "attr_face", NULL };
|
char *binds[] = { "attr_vertex", "attr_face", NULL };
|
||||||
char vertex[5000];
|
char *vertex;
|
||||||
int vertex_len;
|
char *fragment;
|
||||||
char fragment[5000];
|
|
||||||
int fragment_len;
|
|
||||||
int w=0,h=0;
|
int w=0,h=0;
|
||||||
|
|
||||||
unsigned char *texdata = stbi_load("terrain.png", &w, &h, NULL, 4);
|
unsigned char *texdata = stbi_load("terrain.png", &w, &h, NULL, 4);
|
||||||
|
|
||||||
stbvox_init_mesh_maker(&g_mesh_maker);
|
stbvox_init_mesh_maker(&g_mesh_maker);
|
||||||
stbvox_config_use_gl(&g_mesh_maker, 1, 1);
|
|
||||||
for (i=0; i < num_mesh_workers; ++i) {
|
for (i=0; i < num_mesh_workers; ++i) {
|
||||||
stbvox_init_mesh_maker(&mesh_data[i].rm.mm);
|
stbvox_init_mesh_maker(&mesh_data[i].rm.mm);
|
||||||
stbvox_config_use_gl(&mesh_data[i].rm.mm, 1,1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vertex_len = stbvox_get_vertex_shader(&g_mesh_maker, vertex, sizeof(vertex));
|
vertex = stbvox_get_vertex_shader();
|
||||||
fragment_len = stbvox_get_fragment_shader(&g_mesh_maker, fragment, sizeof(fragment));
|
fragment = stbvox_get_fragment_shader();
|
||||||
|
|
||||||
if (vertex_len < 0) {
|
|
||||||
ods("Vertex shader was too long!\n");
|
|
||||||
assert(0);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (fragment_len < 0) {
|
|
||||||
ods("fragment shader was too long!\n");
|
|
||||||
assert(0);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
ods("Shader lengths: %d %d\n", vertex_len, fragment_len);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
char error_buffer[1024];
|
char error_buffer[1024];
|
||||||
|
Loading…
Reference in New Issue
Block a user