24 #include "primitives.h"
90 string res =
"/data/data/com.arm.malideveloper.openglessdk.computeparticles/files/";
139 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width, height);
140 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
141 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
142 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
143 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
144 glBindTexture(GL_TEXTURE_2D, 0);
148 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
shadow_map_tex, 0);
150 GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
151 ASSERT(status == GL_FRAMEBUFFER_COMPLETE,
"Framebuffer not complete\n");
152 glBindFramebuffer(GL_FRAMEBUFFER, 0);
163 p.
x = 0.3f * (-1.0f + 2.0f *
frand());
164 p.
y = 0.3f * (-1.0f + 2.0f *
frand());
165 p.
z = 0.3f * (-1.0f + 2.0f *
frand());
169 data[i] =
vec4(p, lifetime);
234 const uint32 WORK_GROUP_SIZE = 64;
241 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0,
buffer_spawn);
243 glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
254 glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
255 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
256 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
267 glClearColor(0.0
f, 0.0
f, 0.0
f, 0.0
f);
268 glClear(GL_COLOR_BUFFER_BIT);
279 glBindFramebuffer(GL_FRAMEBUFFER, 0);
311 cull(
true, GL_CW, GL_BACK);
340 blend_mode(
true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD);
354 glBindBuffer(GL_ARRAY_BUFFER, 0);
355 glBindTexture(GL_TEXTURE_2D, 0);
360 glEnable(GL_DEPTH_TEST);
361 glDepthMask(GL_TRUE);
362 glDepthRangef(0.0
f, 1.0
f);
363 glDepthFunc(GL_LEQUAL);
365 glClearColor(0.0
f, 0.0
f, 0.0
f, 0.0
f);
366 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
372 glDepthMask(GL_FALSE);
388 float t = -origin.
y / dir.
y;
389 vec3 p = origin + dir * t;
391 if (p.
x < -2.0f || p.
x > 2.0f || p.
z < -2.0f || p.
z > 2.0f ||
dragging)
void on_pointer_down(float x, float y)
#define attribfv(prog, name, n, offset)
mat4 mat_projection_light
const uint32 NUM_PARTICLES
bool load_compute_from_file(string cs_path)
Shader shader_draw_particle
Mesh gen_unit_sphere(int t_samples, int s_samples)
GLint GLsizei GLsizei height
void radix_sort(GLuint buf_input, vec3 axis, float z_min, float z_max)
bool load_from_file(const string *paths, GLenum *types, int count)
float clamp(float x, float min, float max)
void del_buffer(GLuint buffer)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
static mat4 rotateY(float rad)
static mat4 orthographic(float left, float right, float bottom, float top, float near, float far)
static mat4 inverse(const mat4 &op)
void on_pointer_up(float x, float y)
static vec3 normalize(const vec3 &v)
static mat4 rotateX(float rad)
void init_app(int width, int height)
void cull(bool enabled, GLenum front, GLenum mode)
GLuint gen_buffer(GLenum target, GLenum usage, GLsizei size, const void *data)
void uniform(string name, const mat4 &v)
GLint GLint GLint GLint GLint x
void use_shader(Shader shader)
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
double get_elapsed_time()
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
static mat4 translate(float x, float y, float z)
void render_app(float dt)
void init_shadowmap(int width, int height)
void update_app(float dt)
void blend_mode(bool enabled, GLenum src, GLenum dest, GLenum func)