## System Requirements
Dragonblocks Alpha targets PCs only. Non x86-64 platforms may work, however there is no guarantee whatsoever.
You need a POSIX system conforming to the ISO C and POSIX 2008 standards. However, so far only GNU/Linux systems, in particular Ubuntu and Debian, have been tested.
-The minimum OpenGL version is 4.2.0. Dragonblocks has been tested on Intel Integrated and NVIDIA GPUs, however other graphics cards should work as well.
+The minimum OpenGL version is 3.3 core. Dragonblocks has been tested on Intel Integrated and NVIDIA GPUs, however other graphics cards should work as well.
A PC with at least 4 CPU cores is recommended, but not necessarily required.
+Note: The game can work with OpenGL 3.3, but to use texture batching, you need at least OpenGL 4.0. If your machine doesn't that version, disable texture batching by adding the line "texture_batching off" to your client.conf file.
+
## Current Features
- Multiplayer, Animated player model, Nametags
- Mountains, snow, temperature and humidity, dynamic grass color, oceans and beaches, vulcanos, boulders
uniform vec3 fogColor;
uniform vec3 cameraPos;
-uniform sampler2D textures[MAX_TEXTURE_UNITS];
+
+#if TEXURE_BATCH_UNITS > 1
+uniform sampler2D textures[8];
+#else
+uniform sampler2D texture0;
+#endif
void main()
{
- outColor = texture(textures[int(fragmentTextureIndex + 0.5)], fragmentTextureCoordinates) * vec4(fragmentColor, 1.0);
+#if TEXURE_BATCH_UNITS > 1
+ vec4 texel = texture(textures[int(fragmentTextureIndex + 0.5)], fragmentTextureCoordinates);
+#else
+ vec4 texel = texture(texture0, fragmentTextureCoordinates);
+#endif
+
+ outColor = texel * vec4(fragmentColor, 1.0);
outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
if (outColor.a == 0.0)
"
echo "$COMMON
-break gl_error
+break opengl_error
run \"[::1]:4000\" < $DEBUG_DIR/name
" > $DEBUG_DIR/client_script
client/font.c
client/frustum.c
client/game.c
- client/gl_debug.c
client/gui.c
client/input.c
client/interact.c
client/light.c
client/mesh.c
client/model.c
+ client/opengl.c
client/raycast.c
client/screenshot.c
client/shader.c
.vsync = true,
.meshgen_threads = 4,
.swap_mouse_buttons = true,
+ .texture_batching = true,
};
static ConfigEntry config_entries[] = {
.key = "swap_mouse_buttons",
.value = &client_config.meshgen_threads,
},
+ {
+ .type = CONFIG_BOOL,
+ .key = "texture_batching",
+ .value = &client_config.texture_batching,
+ },
};
__attribute__((constructor)) static void client_config_init()
bool vsync;
unsigned int meshgen_threads;
bool swap_mouse_buttons;
+ bool texture_batching;
} client_config;
#endif
#include "client/client_entity.h"
#include "client/client_player.h"
#include "client/frustum.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/light.h"
#include "client/shader.h"
#include "client/window.h"
#include "client/client_config.h"
#include "client/client_inventory.h"
#include "client/client_item.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/frustum.h"
#include "client/light.h"
#include "client/shader.h"
#include "client/client_terrain.h"
#include "client/debug_menu.h"
#include "client/game.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/gui.h"
#include "client/interact.h"
#include "client/window.h"
#include FT_FREETYPE_H
#include "client/client.h"
#include "client/font.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/texture.h"
#define NUM_CHARS 128
#include "client/font.h"
#include "client/frustum.h"
#include "client/game.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/gui.h"
#include "client/input.h"
#include "client/interact.h"
+++ /dev/null
-#include <GL/glew.h>
-#include <GL/gl.h>
-#include <stdio.h>
-#include "client/gl_debug.h"
-
-// put this into seperate function to make it easy to trace stack using external debugger
-static void gl_error(GLenum err, const char *file, int line)
-{
- switch (err) {
- case GL_INVALID_ENUM: fprintf(stderr, "[warning] OpenGL error: INVALID_ENUM %s:%d\n", file, line); break;
- case GL_INVALID_VALUE: fprintf(stderr, "[warning] OpenGL error: INVALID_VALUE %s:%d\n", file, line); break;
- case GL_INVALID_OPERATION: fprintf(stderr, "[warning] OpenGL error: INVALID_OPERATION %s:%d\n", file, line); break;
- case GL_STACK_OVERFLOW: fprintf(stderr, "[warning] OpenGL error: STACK_OVERFLOW %s:%d\n", file, line); break;
- case GL_STACK_UNDERFLOW: fprintf(stderr, "[warning] OpenGL error: STACK_UNDERFLOW %s:%d\n", file, line); break;
- case GL_OUT_OF_MEMORY: fprintf(stderr, "[warning] OpenGL error: OUT_OF_MEMORY %s:%d\n", file, line); break;
- case GL_INVALID_FRAMEBUFFER_OPERATION: fprintf(stderr, "[warning] OpenGL error: INVALID_FRAMEBUFFER_OPERATION %s:%d\n", file, line); break;
- default: break;
- }
-}
-void gl_debug(const char *file, int line)
-{
- GLenum err = glGetError();
-
- if (err != GL_NO_ERROR)
- gl_error(err, file, line);
-}
+++ /dev/null
-#ifndef _GL_DEBUG_H_
-#define _GL_DEBUG_H_
-
-#ifdef ENABLE_GL_DEBUG
-#define GL_DEBUG gl_debug(__FILE__, __LINE__);
-#else
-#define GL_DEBUG
-#endif
-
-void gl_debug(const char *file, int line);
-
-#endif
#include <string.h>
#include "client/client.h"
#include "client/cube.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/gui.h"
#include "client/mesh.h"
#include "client/shader.h"
#include "client/cube.h"
#include "client/debug_menu.h"
#include "client/frustum.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/gui.h"
#include "client/interact.h"
#include "client/mesh.h"
#include <linmath.h>
#include "client/camera.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/light.h"
#include "common/day.h"
#include <stdio.h>
#include <stdlib.h>
#include "client/cube.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/mesh.h"
typedef struct {
#include "client/camera.h"
#include "client/client_config.h"
#include "client/frustum.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/model.h"
typedef struct {
list_ini(&scene_new);
pthread_mutex_init(&lock_scene_new, NULL);
- glGetIntegerv(GL_MAX_TEXTURE_UNITS, &units); GL_DEBUG
+ units = opengl_texture_batch_units();
}
// ded
--- /dev/null
+#include <stdio.h>
+#include "client/client_config.h"
+#include "client/opengl.h"
+
+// put this into seperate function to make it easy to trace stack using external debugger
+static void opengl_error(GLenum err, const char *file, int line)
+{
+ switch (err) {
+ case GL_INVALID_ENUM: fprintf(stderr, "[warning] OpenGL error: INVALID_ENUM %s:%d\n", file, line); break;
+ case GL_INVALID_VALUE: fprintf(stderr, "[warning] OpenGL error: INVALID_VALUE %s:%d\n", file, line); break;
+ case GL_INVALID_OPERATION: fprintf(stderr, "[warning] OpenGL error: INVALID_OPERATION %s:%d\n", file, line); break;
+ case GL_STACK_OVERFLOW: fprintf(stderr, "[warning] OpenGL error: STACK_OVERFLOW %s:%d\n", file, line); break;
+ case GL_STACK_UNDERFLOW: fprintf(stderr, "[warning] OpenGL error: STACK_UNDERFLOW %s:%d\n", file, line); break;
+ case GL_OUT_OF_MEMORY: fprintf(stderr, "[warning] OpenGL error: OUT_OF_MEMORY %s:%d\n", file, line); break;
+ case GL_INVALID_FRAMEBUFFER_OPERATION: fprintf(stderr, "[warning] OpenGL error: INVALID_FRAMEBUFFER_OPERATION %s:%d\n", file, line); break;
+ default: break;
+ }
+}
+void opengl_debug(const char *file, int line)
+{
+ GLenum err = glGetError();
+
+ if (err != GL_NO_ERROR)
+ opengl_error(err, file, line);
+}
+
+GLint opengl_texture_batch_units()
+{
+ if (!client_config.texture_batching)
+ return 1;
+
+ GLint units;
+ glGetIntegerv(GL_MAX_TEXTURE_UNITS, &units); GL_DEBUG
+
+ return units;
+}
--- /dev/null
+#ifndef _OPENGL_H_
+#define _OPENGL_H_
+
+#ifdef ENABLE_GL_DEBUG
+#define GL_DEBUG opengl_debug(__FILE__, __LINE__);
+#else
+#define GL_DEBUG
+#endif
+
+#include <GL/glew.h>
+#include <GL/gl.h>
+
+void opengl_debug(const char *file, int line);
+GLint opengl_texture_batch_units();
+
+#endif
#include <string.h>
#include <time.h>
#include "client/game.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/window.h"
char *screenshot()
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "client/gl_debug.h"
+#include "client/client_config.h"
+#include "client/opengl.h"
#include "client/shader.h"
static GLuint compile_shader(GLenum type, const char *path, const char *name, GLuint program, const char *def)
GLuint id = glCreateShader(type); GL_DEBUG
- // Minimum OpenGL version is 4.2.0 (idk some shader feature from that version is required)
- const char *version = "#version 420 core\n"; // 420 blaze it
+ const char *version = client_config.texture_batching
+ ? "#version 400 core\n"
+ : "#version 330 core\n";
const char *code_list[3] = {
version,
#include "client/camera.h"
#include "client/client.h"
#include "client/cube.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/mesh.h"
#include "client/shader.h"
#include "client/sky.h"
#include "client/client_terrain.h"
#include "client/cube.h"
#include "client/frustum.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/light.h"
#include "client/shader.h"
#include "client/terrain_gfx.h"
void terrain_gfx_init()
{
- GLint texture_units;
- glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_units); GL_DEBUG
+ GLint texture_batch_units = opengl_texture_batch_units();
char *shader_def;
asprintf(&shader_def,
- "#define MAX_TEXTURE_UNITS %d\n"
+ "#define TEXURE_BATCH_UNITS %d\n"
"#define VIEW_DISTANCE %lf\n",
- texture_units,
+ texture_batch_units,
client_config.view_distance
);
+
shader_prog = shader_program_create(ASSET_PATH "shaders/3d/terrain", shader_def);
free(shader_def);
loc_VP = glGetUniformLocation(shader_prog, "VP"); GL_DEBUG
- GLint texture_indices[texture_units];
- for (GLint i = 0; i < texture_units; i++)
- texture_indices[i] = i;
+ if (texture_batch_units > 1) {
+ GLint texture_indices[texture_batch_units];
+ for (GLint i = 0; i < texture_batch_units; i++)
+ texture_indices[i] = i;
- glProgramUniform1iv(shader_prog, glGetUniformLocation(shader_prog, "textures"), texture_units, texture_indices); GL_DEBUG
+ glProgramUniform1iv(shader_prog, glGetUniformLocation(shader_prog, "textures"),
+ texture_batch_units, texture_indices); GL_DEBUG
+ }
model_shader.prog = shader_prog;
model_shader.loc_transform = glGetUniformLocation(shader_prog, "model"); GL_DEBUG
#include <stdbool.h>
#include <dragonstd/tree.h>
#include "client/client_config.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/texture.h"
static Tree textures;
#include "client/client_config.h"
#include "client/debug_menu.h"
#include "client/game.h"
-#include "client/gl_debug.h"
+#include "client/opengl.h"
#include "client/gui.h"
#include "client/input.h"
#include "client/window.h"