32 #define GLES_VERSION 3
38 using namespace GLFFT;
50 #define NORMALMAP_FREQ_MOD 7.3f
51 #define AMPLITUDE 1.0f
54 #define WIND_SPEED_X +26.0f
55 #define WIND_SPEED_Z -22.0f
76 vec4 lbn = inv *
vec4(-1, -1, -1, 1);
77 vec4 ltn = inv * vec4(-1, 1, -1, 1);
78 vec4 lbf = inv * vec4(-1, -1, 1, 1);
79 vec4 rbn = inv * vec4( 1, -1, -1, 1);
80 vec4 rtn = inv * vec4( 1, 1, -1, 1);
81 vec4 rbf = inv * vec4( 1, -1, 1, 1);
82 vec4 rtf = inv * vec4( 1, 1, 1, 1);
118 planes[0] = vec4(near_normal, -
vec_dot(near_normal, lbn_pos));
119 planes[1] = vec4(far_normal, -
vec_dot(far_normal, lbf_pos));
120 planes[2] = vec4(left_normal, -
vec_dot(left_normal, lbn_pos));
121 planes[3] = vec4(right_normal, -
vec_dot(right_normal, rbn_pos));
122 planes[4] = vec4(top_normal, -
vec_dot(top_normal, ltn_pos));
123 planes[5] = vec4(bottom_normal, -
vec_dot(bottom_normal, lbn_pos));
134 static const int8_t
quad[] = {
140 GL_CHECK(glBufferData(GL_ARRAY_BUFFER,
sizeof(quad), quad, GL_STATIC_DRAW));
141 GL_CHECK(glEnableVertexAttribArray(0));
142 GL_CHECK(glVertexAttribPointer(0, 2, GL_BYTE, GL_FALSE, 0, 0));
174 cam_pos +=
vec3(delta_time * 20.0f) * cam_dir_right;
190 GL_CHECK(glViewport(0, 0, width, height));
192 GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
200 info.
mvp = proj * view;
218 GL_CHECK(glActiveTexture(GL_TEXTURE0));
222 GL_CHECK(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
253 char method_string[128];
257 GL_CHECK(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
260 text.
addString(20, surface_height - 20,
"Heightmap Method:", 255, 255, 255, 255);
261 sprintf(method_string,
"%s (%4.1f / 10.0 s)", method, current_time);
262 text.
addString(20, surface_height - 40, method_string, 255, 255, 255, 255);
277 catch (
const exception &e)
279 LOGE(
"%s\n", e.what());
283 text =
new Text(
"/data/data/com.arm.malideveloper.openglessdk.ocean/files/", width, height);
288 surface_width =
width;
298 total_time += delta_time;
299 method_timer += delta_time;
302 app_render(surface_width, surface_height, total_time, phase);
304 static const char *methods[] = {
305 "Continuous LOD Morphing Geo-MipMap",
311 if (method_timer > 10.0
f)
325 GL_CHECK(glInvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments));
vec3 vec_rotateX(const vec3 &v, float radians)
float getTime()
Returns the time passed since object creation or since reset() was last called.
GLuint height_displacement
Functions for drawing text in OpenGL ES.
float vec_dot(const T &a, const T &b)
mat4 mat_look_at(const vec3 &eye, const vec3 ¢er, const vec3 &up)
GLint GLsizei GLsizei height
vec3 vec_cross(const vec3 &a, const vec3 &b)
GLuint get_normal() const
GLuint common_compile_shader_from_file(const char *vs_source, const char *fs_source)
const T::data_type * value_ptr(const T &vec)
void generate(unsigned size, vec3 sun_dir)
static unsigned surface_width
Provides a platform independent high resolution timer.
void clear(void)
Removes the current string from the class.
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_ocean_Ocean_step(JNIEnv *, jclass)
static Scattering * scatter
void common_set_basedir(const char *basedir)
static GLuint prog_skydome
static float method_timer
void reset()
Resets the timer to 0.0f.
unsigned displacement_downsample
static void compute_frustum(vec4 *planes, const mat4 &mvp)
static unsigned surface_height
virtual void render(const RenderInfo &info)=0
void addString(int xPosition, int yPosition, const char *string, int red, int green, int blue, int alpha)
Add a std::string to be drawn to the screen.
static void app_render(unsigned width, unsigned height, float total_time, unsigned mesh_index)
GLsizei const GLenum * attachments
unsigned get_displacement_downsample() const
bool common_has_extension(const char *ext)
GLuint get_texture() const
mat4 mat_perspective_fov(float fovy, float aspect, float zn, float zf)
float getInterval()
Returns the time passed since getInterval() was last called.
vec3 vec_rotateY(const vec3 &v, float radians)
GLuint get_gradient_jacobian() const
#define NORMALMAP_FREQ_MOD
GLuint get_height_displacement() const
mat4 mat_inverse(const mat4 &a)
T vec_normalize(const T &vec)
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_ocean_Ocean_uninit(JNIEnv *, jclass)
JNIEXPORT void JNICALL Java_com_arm_malideveloper_openglessdk_ocean_Ocean_init(JNIEnv *, jclass, jint width, jint height)
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
detail::ivec2< uint32_t > uvec2
static void app_update(float delta_time)
vec3 vec_project(const vec4 &vec)
void draw(void)
Draw the text to the screen.
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
static void render_text(Text &text, const char *method, float current_time)