提交 cd17050c 编写于 作者: S Sean Barrett

split render.c into cave_mesher.c and cave_render.c

上级 2770c921
......@@ -224,6 +224,8 @@
#ifndef INCLUDE_STB_VOXEL_RENDER_H
#define INCLUDE_STB_VOXEL_RENDER_H
#include <stdlib.h>
#ifdef STBVOX_BLOCKTYPE_SHORT
......@@ -287,6 +289,13 @@ extern void stbvox_set_input_stride(stbvox_mesh_maker *mm, int x_stride_in_bytes
extern void stbvox_config_use_gl(stbvox_mesh_maker *mm, int use_tex_buffer, int use_gl_modelview, int use_gl_fragment);
extern void stbvox_config_set_z_precision(stbvox_mesh_maker *mm, int z_fractional_bits);
extern stbvox_input_description *stbvox_get_input_description(stbvox_mesh_maker *mm);
extern int stbvox_get_vertex_shader(stbvox_mesh_maker *mm, char *buffer, size_t buffer_size);
extern int stbvox_get_fragment_shader(stbvox_mesh_maker *mm, char *buffer, size_t buffer_size);
extern void stbvox_set_default_mesh(stbvox_mesh_maker *mm, int mesh);
extern int stbvox_get_quad_count(stbvox_mesh_maker *mm, int mesh);
extern void stbvox_get_transform(stbvox_mesh_maker *mm, float transform[3][3]);
extern void stbvox_get_bounds(stbvox_mesh_maker *mm, float bounds[2][3]);
extern void stbvox_set_mesh_coordinates(stbvox_mesh_maker *mm, int x, int y, int z);
// meshing API
......
此差异已折叠。
......@@ -54,7 +54,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl2.lib opengl32.lib glu32.lib winmm.lib sdl2_mixer.lib advapi32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Release/caveview.exe"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl2.lib opengl32.lib glu32.lib winmm.lib sdl2_mixer.lib advapi32.lib /nologo /subsystem:windows /debug /machine:I386
# SUBTRACT LINK32 /map
!ELSEIF "$(CFG)" == "caveview - Win32 Debug"
......@@ -91,6 +91,10 @@ LINK32=link.exe
# Name "caveview - Win32 Debug"
# Begin Source File
SOURCE=.\cave_mesher.c
# End Source File
# Begin Source File
SOURCE=.\cave_parse.c
# End Source File
# Begin Source File
......@@ -99,6 +103,14 @@ SOURCE=.\cave_parse.h
# End Source File
# Begin Source File
SOURCE=.\cave_render.c
# End Source File
# Begin Source File
SOURCE=.\caveview.h
# End Source File
# Begin Source File
SOURCE=.\game.c
# End Source File
# Begin Source File
......@@ -119,19 +131,15 @@ SOURCE=.\main.c
# End Source File
# Begin Source File
SOURCE=.\render.c
# End Source File
# Begin Source File
SOURCE=.\win32\SDL_windows_main.c
# End Source File
# Begin Source File
SOURCE=.\stb.h
SOURCE=..\..\stb.h
# End Source File
# Begin Source File
SOURCE=.\stb_easy_font.h
SOURCE=..\..\stb_easy_font.h
# End Source File
# Begin Source File
......@@ -143,15 +151,11 @@ SOURCE=.\stb_glprog.h
# End Source File
# Begin Source File
SOURCE=.\stb_image.h
# End Source File
# Begin Source File
SOURCE=.\stb_image_write.h
SOURCE=..\..\stb_image.h
# End Source File
# Begin Source File
SOURCE=.\stb_voxel_render.h
SOURCE=..\..\stb_voxel_render.h
# End Source File
# End Target
# End Project
#ifndef INCLUDE_CAVEVIEW_H
#define INCLUDE_CAVEVIEW_H
#include "stb.h"
#define STBVOX_ROTATION_IN_LIGHTING
#include "stb_voxel_render.h"
typedef struct
{
int cx,cy;
stbvox_mesh_maker mm;
uint8 *build_buffer;
uint8 *face_buffer;
int num_quads;
float transform[3][3];
float bounds[2][3];
uint8 sv_blocktype[34][34][18];
uint8 sv_lighting [34][34][18];
} raw_mesh;
// a 3D checkerboard of empty,solid would be: 32x32x255x6/2 ~= 800000
// an all-leaf qchunk would be: 32 x 32 x 255 x 6 ~= 1,600,000
#define BUILD_QUAD_MAX 800000
#define BUILD_BUFFER_SIZE (4*4*BUILD_QUAD_MAX) // 4 bytes per vertex, 4 vertices per quad
#define FACE_BUFFER_SIZE ( 4*BUILD_QUAD_MAX) // 4 bytes per quad
extern void mesh_init(void);
extern void render_init(void);
extern void world_init(void);
extern void ods(char *fmt, ...); // output debug string
extern void reset_cache_size(int size);
#include "cave_parse.h" // fast_chunk
extern fast_chunk *get_converted_fastchunk(int chunk_x, int chunk_y);
extern void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh *rm);
extern void reset_cache_size(int size);
extern void deref_fastchunk(fast_chunk *fc);
#endif
\ No newline at end of file
......@@ -20,6 +20,8 @@
#define STB_DEFINE
#include "stb.h"
#include "caveview.h"
#define SCALE 2
void error(char *s)
......@@ -336,6 +338,9 @@ int SDL_main(int argc, char **argv)
SDL_GL_SetSwapInterval(0); // only when profiling
render_init();
mesh_init();
world_init();
init_game();
//editor_init();
initialized = 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册