13 #define _USE_MATH_DEFINES 20 #include <glad/glad.h> 26 #define MAX_DELTA_T 0.01 29 #define ANIMATION_SPEED 10.0 45 #define VERTEXNUM (GRIDW*GRIDH) 47 #define QUADW (GRIDW - 1) 48 #define QUADH (GRIDH - 1) 49 #define QUADNUM (QUADW*QUADH) 74 for (y = 0; y <
GRIDH; y++)
76 for (x = 0; x <
GRIDW; x++)
84 if ((x % 4 < 2) ^ (y % 4 < 2))
94 for (y = 0; y <
QUADH; y++)
96 for (x = 0; x <
QUADW; x++)
98 p = 4 * (y * QUADW +
x);
122 for (y = 0; y <
GRIDH; y++)
124 for (x = 0; x <
GRIDW; x++)
126 dx = (double) (x - GRIDW / 2);
127 dy = (double) (y - GRIDH / 2);
128 d = sqrt(dx * dx + dy * dy);
129 if (d < 0.1 * (
double) (GRIDW / 2))
132 p[
x][
y] = -cos(d * (M_PI / (
double)(GRIDW * 4))) * 100.0;
202 for (y = 0; y <
GRIDH; y++)
204 for (x = 0; x <
GRIDW; x++)
223 for (x = 0; x <
GRIDW; x++)
225 x2 = (x + 1) % GRIDW;
226 for(y = 0; y <
GRIDH; y++)
227 ax[x][y] =
p[x][y] -
p[x2][y];
230 for (y = 0; y <
GRIDH; y++)
232 y2 = (y + 1) % GRIDH;
233 for(x = 0; x <
GRIDW; x++)
234 ay[x][y] =
p[x][y] -
p[x][y2];
238 for (x = 0; x <
GRIDW; x++)
240 for (y = 0; y <
GRIDH; y++)
248 for (x = 1; x <
GRIDW; x++)
251 for (y = 1; y <
GRIDH; y++)
266 fprintf(stderr,
"Error: %s\n", description);
355 zoom += (float) y / 4.
f;
371 ratio = (float) width / (
float)
height;
379 60.
f * (
float) M_PI / 180.
f,
390 int main(
int argc,
char* argv[])
393 double t, dt_total,
t_old;
435 dt_total = t -
t_old;
439 while (dt_total > 0.
f)
#define glEnableClientState
void mouse_button_callback(GLFWwindow *window, int button, int action, int mods)
The header of the GLFW 3 API.
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
void *(* GLADloadproc)(const char *name)
static GLFWwindow * window
GLdouble GLdouble GLdouble y2
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
void draw_scene(GLFWwindow *window)
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
void framebuffer_size_callback(GLFWwindow *window, int width, int height)
struct Vertex vertex[VERTEXNUM]
int main(int argc, char *argv[])
#define GLFW_KEY_PAGE_DOWN
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow *window, GLFWframebuffersizefun cbfun)
Sets the framebuffer resize callback for the specified window.
static void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float n, float f)
#define GLFW_CURSOR_DISABLED
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
GLfloat GLfloat GLfloat alpha
#define GL_COLOR_BUFFER_BIT
#define GLFW_CURSOR_NORMAL
static void error_callback(int error, const char *description)
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
GLint GLsizei GLsizei height
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
GLAPI int gladLoadGLLoader(GLADloadproc)
#define GL_DEPTH_BUFFER_BIT
static const textual_icon exit
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
void scroll_callback(GLFWwindow *window, double x, double y)
void cursor_position_callback(GLFWwindow *window, double x, double y)
struct GLFWwindow GLFWwindow
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.