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/] [ocgfx3d.c] - Blame information for rev 5

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 <math.h>
4
 
5
int main(void)
6
{
7
        int i;
8
 
9
        // Initialize screen, no double buffering
10
    int screen = orgfxplus_init(640, 480, 16, 1);
11
 
12
        /*
13
                    a
14
                   b c
15
                  d e f
16
          */
17
 
18
    orgfx_point a = {0, -75, 100};
19
    orgfx_point b = {-50, -25, 0};
20
    orgfx_point c = {50, -25, 0};
21
    orgfx_point d = {-100, 25, 100};
22
    orgfx_point e = {0, 25, 0};
23
    orgfx_point f = {100, 25, 100};
24
 
25
        float rad = 0;
26
        int t = 0;
27
 
28
    orgfx_point offset = {350, 300, 0};
29
 
30
        while(1)
31
        {
32
        orgfx_point scale = {1.0, 1.0, 1.0}; // + sin(t / 1000.f);
33
 
34
                // Clear screen
35
        orgfxplus_fill(0,0,640,480,0xffff);
36
                for(i = 0; i < 2000000; ++i);
37
 
38
        orgfx_point a_ = orgfx3d_translate(orgfx3d_scale(orgfx3d_rotateY(a, rad), scale), offset);
39
        orgfx_point b_ = orgfx3d_translate(orgfx3d_scale(orgfx3d_rotateY(b, rad), scale), offset);
40
        orgfx_point c_ = orgfx3d_translate(orgfx3d_scale(orgfx3d_rotateY(c, rad), scale), offset);
41
        orgfx_point d_ = orgfx3d_translate(orgfx3d_scale(orgfx3d_rotateY(d, rad), scale), offset);
42
        orgfx_point e_ = orgfx3d_translate(orgfx3d_scale(orgfx3d_rotateY(e, rad), scale), offset);
43
        orgfx_point f_ = orgfx3d_translate(orgfx3d_scale(orgfx3d_rotateY(f, rad), scale), offset);
44
 
45
        orgfx_triangle(a_, c_, b_, 0xf800, 1);
46
                for(i = 0; i < 100000; ++i);
47
 
48
        orgfx_triangle(b_, e_, d_, 0xf800, 1);
49
                for(i = 0; i < 100000; ++i);
50
 
51
        orgfx_triangle(c_, f_, e_, 0xf800, 1);
52
                for(i = 0; i < 100000; ++i);
53
 
54
                t += 1;
55
                rad += 0.1;
56
                if(rad >= M_PI*2) rad -= M_PI*2;
57
 
58
                // Swap buffers
59
        orgfxplus_flip();
60
        }
61
}

powered by: WebSVN 2.1.0

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