Macros | Functions | Variables
heightmap.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stddef.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
Include dependency graph for heightmap.c:

Go to the source code of this file.

Macros

#define DISPLACEMENT_SIGN_LIMIT   (0.3f)
 
#define MAP_NUM_LINES
 
#define MAP_NUM_TOTAL_VERTICES   (MAP_NUM_VERTICES*MAP_NUM_VERTICES)
 
#define MAP_NUM_VERTICES   (80)
 
#define MAP_SIZE   (10.0f)
 
#define MAX_CIRCLE_SIZE   (5.0f)
 
#define MAX_DISPLACEMENT   (1.0f)
 
#define MAX_ITER   (200)
 
#define NUM_ITER_AT_A_TIME   (1)
 

Functions

static void error_callback (int error, const char *description)
 
static void generate_heightmap__circle (float *center_x, float *center_y, float *size, float *displacement)
 
static void init_map (void)
 
static void key_callback (GLFWwindow *window, int key, int scancode, int action, int mods)
 
int main (int argc, char **argv)
 
static void make_mesh (GLuint program)
 
static GLuint make_shader (GLenum type, const char *text)
 
static GLuint make_shader_program (const char *vs_text, const char *fs_text)
 
static void update_map (int num_iter)
 
static void update_mesh (void)
 

Variables

static GLfloat aspect_ratio = 4.0f/3.0f
 
static const char * fragment_shader_text
 
static GLuint map_line_indices [2 *MAP_NUM_LINES]
 
static GLfloat map_vertices [3][MAP_NUM_TOTAL_VERTICES]
 
static GLuint mesh
 
static GLuint mesh_vbo [4]
 
static GLfloat modelview_matrix [16]
 
static GLfloat projection_matrix [16]
 
static const char * vertex_shader_text
 
static GLfloat view_angle = 45.0f
 
static GLfloat z_far = 100.f
 
static GLfloat z_near = 1.0f
 

Macro Definition Documentation

#define DISPLACEMENT_SIGN_LIMIT   (0.3f)

Definition at line 38 of file heightmap.c.

#define MAP_NUM_LINES
Value:
(3* (MAP_NUM_VERTICES - 1) * (MAP_NUM_VERTICES - 1) + \
2 * (MAP_NUM_VERTICES - 1))
#define MAP_NUM_VERTICES
Definition: heightmap.c:44

Definition at line 46 of file heightmap.c.

#define MAP_NUM_TOTAL_VERTICES   (MAP_NUM_VERTICES*MAP_NUM_VERTICES)

Definition at line 45 of file heightmap.c.

#define MAP_NUM_VERTICES   (80)

Definition at line 44 of file heightmap.c.

#define MAP_SIZE   (10.0f)

Definition at line 43 of file heightmap.c.

#define MAX_CIRCLE_SIZE   (5.0f)

Definition at line 36 of file heightmap.c.

#define MAX_DISPLACEMENT   (1.0f)

Definition at line 37 of file heightmap.c.

#define MAX_ITER   (200)

Definition at line 39 of file heightmap.c.

#define NUM_ITER_AT_A_TIME   (1)

Definition at line 40 of file heightmap.c.

Function Documentation

static void error_callback ( int  error,
const char *  description 
)
static

Definition at line 394 of file heightmap.c.

static void generate_heightmap__circle ( float *  center_x,
float *  center_y,
float *  size,
float *  displacement 
)
static

Definition at line 289 of file heightmap.c.

static void init_map ( void  )
static

Definition at line 205 of file heightmap.c.

static void key_callback ( GLFWwindow window,
int  key,
int  scancode,
int  action,
int  mods 
)
static

Definition at line 383 of file heightmap.c.

int main ( int  argc,
char **  argv 
)

Definition at line 399 of file heightmap.c.

static void make_mesh ( GLuint  program)
static

Definition at line 341 of file heightmap.c.

static GLuint make_shader ( GLenum  type,
const char *  text 
)
static

Definition at line 122 of file heightmap.c.

static GLuint make_shader_program ( const char *  vs_text,
const char *  fs_text 
)
static

Definition at line 149 of file heightmap.c.

static void update_map ( int  num_iter)
static

Definition at line 305 of file heightmap.c.

static void update_mesh ( void  )
static

Definition at line 374 of file heightmap.c.

Variable Documentation

GLfloat aspect_ratio = 4.0f/3.0f
static

Definition at line 81 of file heightmap.c.

const char* fragment_shader_text
static
Initial value:
=
"#version 150\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
" color = vec4(0.2, 1.0, 0.2, 1.0); \n"
"}\n"

Definition at line 67 of file heightmap.c.

GLuint map_line_indices[2 *MAP_NUM_LINES]
static

Definition at line 106 of file heightmap.c.

GLfloat map_vertices[3][MAP_NUM_TOTAL_VERTICES]
static

Definition at line 105 of file heightmap.c.

GLuint mesh
static

Definition at line 113 of file heightmap.c.

GLuint mesh_vbo[4]
static

Definition at line 114 of file heightmap.c.

GLfloat modelview_matrix[16]
static
Initial value:
= {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
}

Definition at line 94 of file heightmap.c.

GLfloat projection_matrix[16]
static
Initial value:
= {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
}

Definition at line 86 of file heightmap.c.

const char* vertex_shader_text
static
Initial value:
=
"#version 150\n"
"uniform mat4 project;\n"
"uniform mat4 modelview;\n"
"in float x;\n"
"in float y;\n"
"in float z;\n"
"\n"
"void main()\n"
"{\n"
" gl_Position = project * modelview * vec4(x, y, z, 1.0);\n"
"}\n"

Definition at line 54 of file heightmap.c.

GLfloat view_angle = 45.0f
static

Definition at line 80 of file heightmap.c.

GLfloat z_far = 100.f
static

Definition at line 83 of file heightmap.c.

GLfloat z_near = 1.0f
static

Definition at line 82 of file heightmap.c.



librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:26