graphics

experiments with opengl3.2/ogles3.3 on linux and win7
git clone http://frotz.net/git/graphics.git
Log | Files | Refs

util.h (1801B)


      1 /* Copyright 2013 Brian Swetland <swetland@frotz.net>
      2  *
      3  * Licensed under the Apache License, Version 2.0 (the "License");
      4  * you may not use this file except in compliance with the License.
      5  * You may obtain a copy of the License at
      6  *
      7  *     http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software
     10  * distributed under the License is distributed on an "AS IS" BASIS,
     11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12  * See the License for the specific language governing permissions and
     13  * limitations under the License.
     14  */
     15 
     16 #ifndef _UTIL_H_
     17 #define _UTIL_H_
     18 
     19 #include "types.h"
     20 
     21 /* file io helpers */
     22 #define OPT_PNG_INVERTY 0x0001
     23 #define OPT_PNG_GRAY    0x0002
     24 
     25 void *load_png_rgba(const char *fn, unsigned *width, unsigned *height, int options);
     26 void *load_png_gray(const char *fn, unsigned *width, unsigned *height, int options);
     27 void *load_file(const char *fn, unsigned *sz);
     28 int file_get_mtime(const char *fn);
     29 
     30 int save_png_rgba(const char *fn, void *data, unsigned width, unsigned height);
     31 int save_png_gray(const char *fn, void *data, unsigned width, unsigned height);
     32 
     33 /* model helpers */
     34 
     35 struct model {
     36 	float *vdata; /* { vertex[3], normal[3], texcoord[2] } * vcount */
     37 	unsigned short *idx;
     38 	unsigned vcount;
     39 	unsigned icount;
     40 };
     41 
     42 struct model *load_wavefront_obj(const char *fn);
     43 void delete_wavefront_obj(struct model *m);
     44 
     45 /* simplex noise */
     46 float snoise(float x);
     47 float snoise(float x, float y);
     48 float snoise(float x, float y, float z);
     49 float snoise(float x, float y, float z, float w);
     50 
     51 #ifdef _WIN32
     52 #define snprintf _snprintf
     53 #endif
     54 
     55 void printx(const char *fmt, ...);
     56 void printmtx(float *m, const char *name);
     57 int error(const char *fmt, ...);
     58 void die(const char *fmt, ...);
     59 
     60 #endif
     61