32 #define _USE_MATH_DEFINES 39 #include <glad/glad.h> 62 #define STEP_LONGITUDE 22.5f 63 #define STEP_LATITUDE 22.5f 65 #define DIST_BALL (RADIUS * 2.f + RADIUS * 0.1f) 67 #define VIEW_SCENE_DIST (DIST_BALL * 3.f + 200.f) 68 #define GRID_SIZE (RADIUS * 4.5f) 69 #define BOUNCE_HEIGHT (RADIUS * 2.1f) 70 #define BOUNCE_WIDTH (RADIUS * 2.1f) 72 #define SHADOW_OFFSET_X -20.f 73 #define SHADOW_OFFSET_Y 10.f 74 #define SHADOW_OFFSET_Z 0.f 76 #define WALL_L_OFFSET 0.f 77 #define WALL_R_OFFSET 5.f 80 #define ANIMATION_SPEED 50.f 83 #define MAX_DELTA_T 0.02f 110 #define RAND_MAX 4095 120 return (deg - 360.
f);
131 return deg / 360 * (2 * M_PI);
168 n->
x = u2 * v3 - v2 *
v3;
169 n->
y = u3 * v1 - v3 *
u1;
170 n->
z = u1 * v2 - v1 *
u2;
174 #define BOING_DEBUG 0 223 2.
f * (
float) atan2(
RADIUS, 200.
f ),
231 vec3 center = { 0.f, 0.f, 0.f };
232 vec3 up = { 0.f, -1.f, 0.f };
310 double dt_total, dt2;
322 while( dt_total > 0.0 )
421 if (
ball_y_inc < 0 ) sign = -1.0;
else sign = 1.0;
424 if ( deg > 80 ) deg = 80;
425 if ( deg < 10 ) deg = 10;
446 static int colorToggle = 0;
464 if ( lat_deg >= 180 )
470 colorToggle = ! colorToggle;
515 printf(
"----------------------------------------------------------- \n" );
516 printf(
"lat = %f long_lo = %f long_hi = %f \n", lat_deg, long_lo, long_hi );
517 printf(
"vert_ne x = %.8f y = %.8f z = %.8f \n", vert_ne.
x, vert_ne.
y, vert_ne.
z );
518 printf(
"vert_nw x = %.8f y = %.8f z = %.8f \n", vert_nw.
x, vert_nw.
y, vert_nw.
z );
519 printf(
"vert_se x = %.8f y = %.8f z = %.8f \n", vert_se.
x, vert_se.
y, vert_se.
z );
520 printf(
"vert_sw x = %.8f y = %.8f z = %.8f \n", vert_sw.
x, vert_sw.
y, vert_sw.
z );
528 colorToggle = ! colorToggle;
544 const int rowTotal = 12;
545 const int colTotal = rowTotal;
548 const GLfloat z_offset = -40.0;
563 for ( col = 0; col <= colTotal; col++ )
589 for ( row = 0; row <= rowTotal; row++ )
628 exit( EXIT_FAILURE );
634 exit( EXIT_FAILURE );
676 exit( EXIT_SUCCESS );
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow *window, int numer, int denom)
Sets the aspect ratio of the specified window.
double sin_deg(double deg)
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
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
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *monitor)
Returns the current mode of the specified monitor.
struct GLFWmonitor GLFWmonitor
void mouse_button_callback(GLFWwindow *window, int button, int action, int mods)
GLdouble GLdouble GLdouble w
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow *window, GLFWframebuffersizefun cbfun)
Sets the framebuffer resize callback for the specified window.
void BounceBall(double dt)
static void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float n, float f)
double deg2rad(double deg)
void reshape(GLFWwindow *window, int w, int h)
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
void DrawBoingBallBand(GLfloat long_lo, GLfloat long_hi)
GLboolean GLboolean GLboolean GLboolean a
#define GL_COLOR_BUFFER_BIT
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
GLint GLsizei GLsizei height
DRAW_BALL_ENUM drawBallHow
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.
static void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
void key(GLFWwindow *window, int k, int s, int action, int mods)
GLfloat GLfloat GLfloat GLfloat v3
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
GLAPI int gladLoadGLLoader(GLADloadproc)
GLFWAPI GLFWmonitor * glfwGetWindowMonitor(GLFWwindow *window)
Returns the monitor that the window uses for full screen mode.
#define GL_DEPTH_BUFFER_BIT
static const textual_icon exit
double cos_deg(double deg)
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
static void set_ball_pos(GLfloat x, GLfloat y)
GLboolean GLboolean GLboolean b
GLFWAPI void glfwSetWindowMonitor(GLFWwindow *window, GLFWmonitor *monitor, int xpos, int ypos, int width, int height, int refreshRate)
Sets the mode, monitor, video mode and placement of a window.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
GLdouble GLdouble GLint GLint GLdouble v1
GLFWAPI void glfwGetWindowPos(GLFWwindow *window, int *xpos, int *ypos)
Retrieves the position of the client area of the specified window.
GLenum GLenum GLsizei void * row
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
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.
GLfloat TruncateDeg(GLfloat deg)
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
struct GLFWwindow GLFWwindow
void CrossProduct(vertex_t a, vertex_t b, vertex_t c, vertex_t *n)
void cursor_position_callback(GLFWwindow *window, double x, double y)
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.