Remove unneeded headers from common.h, improve error handling
This commit is contained in:
parent
05e2f21d27
commit
d521cc0e83
3 changed files with 17 additions and 18 deletions
6
common.c
6
common.c
|
@ -36,9 +36,9 @@
|
|||
char *filename;
|
||||
float current_time = 0;
|
||||
|
||||
GLint param0 = 0;
|
||||
GLint param1 = 0;
|
||||
GLint param2 = 0;
|
||||
int param0 = 0;
|
||||
int param1 = 0;
|
||||
int param2 = 0;
|
||||
|
||||
|
||||
static GLint time_loc;
|
||||
|
|
11
common.h
11
common.h
|
@ -25,18 +25,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
|
||||
|
||||
extern char *filename;
|
||||
extern float current_time;
|
||||
|
||||
extern GLint param0;
|
||||
extern GLint param1;
|
||||
extern GLint param2;
|
||||
extern int param0;
|
||||
extern int param1;
|
||||
extern int param2;
|
||||
|
||||
|
||||
void load(void);
|
||||
|
|
18
glslview.c
18
glslview.c
|
@ -25,14 +25,20 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
|
||||
#ifdef USE_INOTIFY
|
||||
# include <sys/inotify.h>
|
||||
# include <sys/stat.h>
|
||||
|
@ -53,22 +59,20 @@ static int inotify_watch = -1;
|
|||
static void reset_watch(void) {
|
||||
if (inotify_watch >= 0) {
|
||||
if (inotify_rm_watch(inotify_fd, inotify_watch)) {
|
||||
fprintf(stderr, "unable to remove watch\n");
|
||||
fprintf(stderr, "unable to remove watch: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
inotify_watch = inotify_add_watch(inotify_fd, filename, IN_CLOSE_WRITE);
|
||||
if (inotify_watch < 0) {
|
||||
fprintf(stderr, "unable to watch '%s' for changes\n", filename);
|
||||
return;
|
||||
}
|
||||
if (inotify_watch < 0)
|
||||
fprintf(stderr, "unable to watch '%s' for changes: %s\n", filename, strerror(errno));
|
||||
}
|
||||
|
||||
static void init_watch(void) {
|
||||
inotify_fd = inotify_init();
|
||||
if (inotify_fd < 0) {
|
||||
fprintf(stderr, "unable to initialize inotify\n");
|
||||
fprintf(stderr, "unable to initialize inotify: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue