Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include "util.h"
- int file_size(FILE *fp)
- {
- int prev = ftell(fp);
- fseek(fp, 0L, SEEK_END);
- int size = ftell(fp);
- fseek(fp, prev, SEEK_SET); /* go back to where we were */
- return size;
- }
- char *file_contents(const char *name)
- {
- int c;
- FILE *fp = fopen(name, "r");
- if (!fp)
- {
- fputs("Error opening file for reading!\n", stderr);
- return NULL;
- }
- char *ret = malloc(file_size(fp) + 1);
- if (!ret)
- {
- fputs("Error allocating memory for ret!\n", stderr);
- return NULL;
- }
- size_t i = 0;
- while ((c = fgetc(fp)) != EOF)
- {
- ret[i] = c;
- ++i;
- }
- ret[i] = '\0';
- fclose(fp);
- return ret;
- }
- void perspective(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar)
- {
- const GLdouble pi = 3.1415926535897932384626433832795;
- GLdouble fW, fH;
- //fH = tan( (fovY / 2) / 180 * pi ) * zNear;
- fH = tan(fovY / 360 * pi) * zNear;
- fW = fH * aspect;
- glFrustum(-fW, fW, -fH, fH, zNear, zFar);
- }
Add Comment
Please, Sign In to add comment