static Texture *terrain_tex;
static Material terrain_mat;
static Renderer *terrain_rend;
static Texture *terrain_tex;
static Material terrain_mat;
static Renderer *terrain_rend;
if(strcmp(argv[i], "-opengl") == 0) {
api = GFX_GL;
printf("Backend: OpenGL.\n");
if(strcmp(argv[i], "-opengl") == 0) {
api = GFX_GL;
printf("Backend: OpenGL.\n");
glfwSetKeyCallback(win, clbk_key);
glfwSetCursorPosCallback(win, clbk_motion);
glfwSetMouseButtonCallback(win, clbk_mouse);
glfwSetKeyCallback(win, clbk_key);
glfwSetCursorPosCallback(win, clbk_motion);
glfwSetMouseButtonCallback(win, clbk_mouse);
if(!terrain_rend->create()) {
fprintf(stderr, "terrain fail\n");
return false;
if(!terrain_rend->create()) {
fprintf(stderr, "terrain fail\n");
return false;
goto cowgen_end;
Vec2 pos = cow_pos.back();
float y = terrain.get_height(Vec3(pos.x, 1, pos.y));
goto cowgen_end;
Vec2 pos = cow_pos.back();
float y = terrain.get_height(Vec3(pos.x, 1, pos.y));
static void clbk_mouse(GLFWwindow *win, int bn, int action, int mods)
{
static void clbk_mouse(GLFWwindow *win, int bn, int action, int mods)
{
float angle = (float)rand() / (float)RAND_MAX * 2 * M_PI;
float r = sqrt((float)rand() / (float)RAND_MAX) * radius;
float angle = (float)rand() / (float)RAND_MAX * 2 * M_PI;
float r = sqrt((float)rand() / (float)RAND_MAX) * radius;