21 #ifndef ASTC_TEXTURES_H
22 #define ASTC_TEXTURES_H
24 #include <android/log.h>
25 #include <GLES3/gl3.h>
27 #define LOG_TAG "libNative"
28 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
29 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
30 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
31 #define LOGF(...) __android_log_print(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__)
33 #define MALLOC_CHECK(ptr_type, ptr, size) \
35 ptr = (ptr_type) malloc(size); \
38 LOGF("Memory allocation error FILE: %s LINE: %i\n", __FILE__, __LINE__); \
43 #define REALLOC_CHECK(ptr_type, ptr, size) \
45 ptr = (ptr_type) realloc(ptr, size); \
48 LOGF("Memory allocation error FILE: %s LINE: %i\n", __FILE__, __LINE__); \
53 #define FREE_CHECK(ptr) \
62 GLenum glError = glGetError(); \
63 if(glError != GL_NO_ERROR) \
65 LOGE("glGetError() = %i (%#.8x) at %s:%i\n", glError, glError, __FILE__, __LINE__); \
71 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR (0x93B0)
72 #define GL_COMPRESSED_RGBA_ASTC_5x4_KHR (0x93B1)
73 #define GL_COMPRESSED_RGBA_ASTC_5x5_KHR (0x93B2)
74 #define GL_COMPRESSED_RGBA_ASTC_6x5_KHR (0x93B3)
75 #define GL_COMPRESSED_RGBA_ASTC_6x6_KHR (0x93B4)
76 #define GL_COMPRESSED_RGBA_ASTC_8x5_KHR (0x93B5)
77 #define GL_COMPRESSED_RGBA_ASTC_8x6_KHR (0x93B6)
78 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR (0x93B7)
79 #define GL_COMPRESSED_RGBA_ASTC_10x5_KHR (0x93B8)
80 #define GL_COMPRESSED_RGBA_ASTC_10x6_KHR (0x93B9)
81 #define GL_COMPRESSED_RGBA_ASTC_10x8_KHR (0x93BA)
82 #define GL_COMPRESSED_RGBA_ASTC_10x10_KHR (0x93BB)
83 #define GL_COMPRESSED_RGBA_ASTC_12x10_KHR (0x93BC)
84 #define GL_COMPRESSED_RGBA_ASTC_12x12_KHR (0x93BD)
85 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR (0x93D0)
86 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR (0x93D1)
87 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR (0x93D2)
88 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR (0x93D3)
89 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR (0x93D4)
90 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR (0x93D5)
91 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR (0x93D6)
92 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR (0x93D7)
93 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR (0x93D8)
94 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR (0x93D9)
95 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR (0x93DA)
96 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR (0x93DB)
97 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR (0x93DC)
98 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR (0x93DD)
101 #define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT (0x8F69)
104 #define ASTC_TEXTURE_SWITCH_INTERVAL (5)
107 #define X_ROTATION_SPEED (5)
108 #define Y_ROTATION_SPEED (4)
109 #define Z_ROTATION_SPEED (3)
115 "in vec4 av4position;\n"
116 "in vec3 vv3normal;\n"
117 "in vec2 vv3tex2dcoord;\n"
119 "uniform mat4 mvp;\n"
120 "out vec2 tex2dcoord;\n"
125 " vec3 light_position = vec3(15.0, 0.0, 0.0);\n"
126 " vec4 P = mv * av4position;\n"
127 " normal = mat3(mv) * vv3normal;\n"
128 " light = light_position - P.xyz;\n"
130 " tex2dcoord = vv3tex2dcoord;\n"
131 " gl_Position = mvp * av4position;\n"
139 "precision mediump float;\n"
140 "uniform sampler2D cloud_texture;\n"
141 "uniform sampler2D daytime_texture;\n"
142 "uniform sampler2D nighttime_texture;\n"
143 "in vec2 tex2dcoord;\n"
149 " vec3 diffuse_albedo = vec3(2.0, 2.0, 3.0);\n"
150 " vec3 specular_albedo = vec3(0.1);\n"
151 " float specular_power = 16.0;\n"
152 " vec3 Normal = normalize(normal);\n"
153 " vec3 Light = normalize(light);\n"
154 " vec3 View = normalize(view);\n"
155 " vec3 reflected_light = reflect(-Light, Normal);\n"
156 " vec3 diffuse = max(dot(Normal, Light), 0.0) * diffuse_albedo;\n"
157 " vec3 specular = pow(max(dot(reflected_light, View), 0.0), specular_power) * specular_albedo;\n"
158 " vec2 clouds = texture(cloud_texture, tex2dcoord).rg;\n"
159 " vec3 daytime = (texture(daytime_texture, tex2dcoord).rgb * diffuse + specular * clouds.g) * (1.0 - clouds.r) + clouds.r * diffuse;\n"
160 " vec3 nighttime = texture(nighttime_texture, tex2dcoord).rgb * (1.0 - clouds.r) * 2.0;\n"
161 " color = vec4(mix(nighttime, daytime, 0.5), 1.0);\n"
187 unsigned char magic[4];
188 unsigned char blockdim_x;
189 unsigned char blockdim_y;
190 unsigned char blockdim_z;
191 unsigned char xsize[3];
192 unsigned char ysize[3];
193 unsigned char zsize[3];
GLuint create_program(const char *vertex_source, const char *fragment_source)
Create program object, attach vertex and fragment shader to it. Link program object and check whether...
const GLenum earth_color_decode_format
const char * cloud_and_gloss_texture_file_path
const char earth_fragment_shader_source[]
struct texture_set_info texture_set_info
GLint get_and_check_attrib_location(GLuint program, const GLchar *attrib_name)
Invoke glGetAttribLocation(), if it has returned a positive value. Otherwise, print a message and exi...
GLuint load_shader(GLenum shader_type, const char *shader_source)
Create shader object and compile its source code.
GLuint earth_night_texture_id
GLuint earth_color_texture_id
const char * earth_color_texture_file_path
struct texture_set texture_set
const char * earth_night_texture_file_path
const char * compressed_texture_format_name
const GLenum earth_night_decode_format
const GLenum cloud_and_gloss_decode_format
const GLenum compressed_data_internal_format
const char earth_vertex_shader_source[]
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
GLint get_and_check_uniform_location(GLuint program, const GLchar *uniform_name)
Invoke glGetUniformLocation, if it has returned a positive value. Otherwise, print a message and exit...
GLuint cloud_and_gloss_texture_id