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

Subversion Repositories orsoc_graphics_accelerator

[/] [orsoc_graphics_accelerator/] [trunk/] [sw/] [examples/] [bare/] [ocgfxmesh.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 maiden
#include "orgfx_plus.h"
2
#include "orgfx_3d.h"
3
#include "orgfx.h"
4
#include <math.h>
5
 
6 9 maiden
#include "man.obj.h"
7
#include "uv.png.h"
8 5 maiden
 
9
//#include "stdio.h"
10
 
11
int main(void)
12
{
13
    // Initialize screen, no double buffering
14 9 maiden
    int screen = orgfxplus_init(640, 480, 16, 1, 1);
15 5 maiden
 
16 9 maiden
    // Set up texture and mesh
17
    int uv_sprite = init_uv_sprite();
18
    orgfx_mesh man_mesh = init_man_mesh();
19
    orgfx3d_mesh_texture_size(&man_mesh, 128, 128);
20 5 maiden
 
21 9 maiden
    // Bind the texture
22
    orgfxplus_bind_tex0(uv_sprite);
23 5 maiden
 
24
    float rad = 0;
25 9 maiden
    int i;
26 5 maiden
 
27
    while(1)
28
    {
29 9 maiden
        orgfx_point3 translation = {200, 300, 0};
30
        orgfx_point3 rotation = {M_PI,rad,0};
31
        orgfx_point3 scale = {100.0, 100.0, 100.0};
32 5 maiden
 
33
        // Clear screen
34
        orgfxplus_fill(0,0,640*FIXEDW,480*FIXEDW,0xffff);
35
 
36
        for(i = 0; i < 5000000; ++i);
37
 
38 9 maiden
        // Clear the depth buffer
39
        orgfx_clear_zbuffer();
40
        orgfx_enable_zbuffer(1);
41 5 maiden
 
42 9 maiden
        // Draw wireframe
43
        orgfx3d_draw_mesh(&man_mesh, translation, rotation, scale, 0, 0);
44
        translation.x += 150;
45 5 maiden
 
46 9 maiden
        // Draw filled
47
        orgfx3d_draw_mesh(&man_mesh, translation, rotation, scale, 1, 0);
48
        translation.x += 150;
49 5 maiden
 
50 9 maiden
        // Draw textured
51
        orgfx3d_draw_mesh(&man_mesh, translation, rotation, scale, 1, 1);
52
        orgfx_enable_zbuffer(0);
53 5 maiden
 
54 9 maiden
        // Rotate meshes
55 5 maiden
        rad += 0.01;
56
        if(rad >= M_PI*2) rad -= M_PI*2;
57
 
58
        // Swap buffers
59
        orgfxplus_flip();
60
    }
61
}
62
 

powered by: WebSVN 2.1.0

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