dos3d

view src/mingl.h @ 17:1e9f0b3616fa

fixed the matrix multiplication order
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 30 Nov 2011 00:04:16 +0200
parents bce78aaafc68
children
line source
1 /*
2 256-color 3D graphics hack for real-mode DOS.
3 Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef MINGL_H_
19 #define MINGL_H_
21 /* enable bitflags */
22 #define MGL_CULL_FACE 1
23 #define MGL_DEPTH_TEST 2
24 #define MGL_SMOOTH 4
25 #define MGL_LIGHTING 8
26 #define MGL_TEXTURE_2D 16
28 /* primitives */
29 #define MGL_POINTS 1
30 #define MGL_LINES 2
31 #define MGL_TRIANGLES 3
32 #define MGL_QUADS 4
34 /* matrices */
35 #define MGL_MODELVIEW 0
36 #define MGL_PROJECTION 1
37 #define MGL_TEXTURE 2
39 #define MGL_FRONT 0
40 #define MGL_BACK 1
42 #define MGL_CCW 0
43 #define MGL_CW 1
45 int mgl_init(int width, int height);
46 void mgl_free(void);
48 unsigned char *mgl_framebuffer(void);
50 void mgl_clear(int cidx);
51 void mgl_clear_depth(void);
53 void mgl_enable(unsigned int bit);
54 void mgl_disable(unsigned int bit);
55 int mgl_isenabled(unsigned int bit);
57 void mgl_front_face(int ff);
58 void mgl_cull_face(int cf);
60 void mgl_color_range(int rng);
61 void mgl_light_intensity(int ltidx, float intens);
62 void mgl_light_position(int ltidx, float x, float y, float z, float w);
64 void mgl_begin(int prim);
65 void mgl_end(void);
67 void mgl_vertex2f(float x, float y);
68 void mgl_vertex3f(float x, float y, float z);
69 void mgl_vertex4f(float x, float y, float z, float w);
70 void mgl_color1f(float energy);
71 void mgl_index(int cidx);
72 void mgl_normal(float x, float y, float z);
73 void mgl_texcoord2f(float x, float y);
75 void mgl_viewport(int x, int y, int width, int height);
77 void mgl_matrix_mode(int mmode);
78 void mgl_push_matrix(void);
79 void mgl_pop_matrix(void);
80 void mgl_load_matrix(float *mat);
81 void mgl_mult_matrix(float *mat);
82 void mgl_load_identity(void);
84 void mgl_translate(float x, float y, float z);
85 void mgl_rotate(float angle, float x, float y, float z);
86 void mgl_scale(float x, float y, float z);
88 void mgl_ortho(float left, float right, float bottom, float top, float nr, float fr);
89 void mgl_frustum(float left, float right, float bottom, float top, float nr, float fr);
90 void mgl_perspective(float vfov, float aspect, float nr, float fr);
92 void mgl_teximage(int width, int height, unsigned char *pixels);
94 void mgl_cube(float sz);
95 void mgl_sphere(float rad, int usub, int vsub);
96 void mgl_sphere_part(float rad, int usub, int vsub, float umax, float vmax);
97 void mgl_torus(float inner, float outer, int usub, int vsub);
98 void mgl_torus_part(float inner, float outer, int usub, int vsub, float umax, float vmin, float vmax);
100 #endif /* MINGL_H_ */