OpenCores
URL https://opencores.org/ocsvn/orsoc_graphics_accelerator/orsoc_graphics_accelerator/trunk

Subversion Repositories orsoc_graphics_accelerator

[/] [orsoc_graphics_accelerator/] [trunk/] [sw/] [drivers/] [gfx/] [bare/] [orgfx_3d.h] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 maiden
/*
2
Bare metal OpenCores GFX IP driver for Wishbone bus.
3
 
4
Anton Fosselius, Per Lenander 2012
5
  */
6
 
7
#ifndef ORGFX_3D_H
8
#define ORGFX_3D_H
9
 
10
#include "orgfx.h"
11
 
12
typedef struct orgfx_face
13
{
14
        unsigned int p1, p2, p3;
15
    unsigned int uv1, uv2, uv3;
16
    unsigned int color1, color2, color3;
17
} orgfx_face;
18
 
19
typedef struct orgfx_matrix
20
{
21
  float aa, ab, ac, tx;
22
  float ba, bb, bc, ty;
23
  float ca, cb, cc, tz;
24
} orgfx_matrix;
25
 
26
orgfx_matrix orgfx3d_identity(void);
27
orgfx_matrix orgfx3d_rotateX(orgfx_matrix mat, float rad);
28
orgfx_matrix orgfx3d_rotateY(orgfx_matrix mat, float rad);
29
orgfx_matrix orgfx3d_rotateZ(orgfx_matrix mat, float rad);
30
orgfx_matrix orgfx3d_scale(orgfx_matrix mat, orgfx_point3 s);
31
orgfx_matrix orgfx3d_translate(orgfx_matrix mat, orgfx_point3 t);
32
 
33
inline void orgfx3d_set_matrix(orgfx_matrix mat);
34
 
35
typedef struct orgfx_mesh
36
{
37
    orgfx_point3 translation;
38
    orgfx_point3 rotation;
39
    orgfx_point3 scale;
40
 
41
        unsigned int numVerts;
42
    orgfx_point3 *verts;
43
    unsigned int numUvs;
44
    orgfx_point2 *uvs;
45
        unsigned int numFaces;
46
    orgfx_face *faces;
47
} orgfx_mesh;
48
 
49
orgfx_mesh orgfx3d_make_mesh(orgfx_face* faces,
50
                             unsigned int nFaces,
51
                             orgfx_point3* verts,
52
                             unsigned int nVerts,
53
                             orgfx_point2* uvs,
54
                             unsigned int nUvs);
55
 
56
// This function converts the texture coordinates in a mesh from texture space (0..1) into
57
// image coordinates (0..image_size).
58
// Warning! This function should only be called ONCE for each mesh, as it will
59
// modify the base mesh.
60
void orgfx3d_mesh_texture_size(orgfx_mesh* mesh,
61
                               unsigned int width,
62
                               unsigned int height);
63
 
64
void orgfx3d_draw_mesh(orgfx_mesh* mesh,
65
                       int filled, int textured);
66
 
67
#endif // orgfx_3D_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.