summaryrefslogtreecommitdiffstats
path: root/libs/rs/java/Film/res/raw/filmstrip.c
blob: 1687a312106856bff4e96d18b67df62bfac2faa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Fountain test script

#pragma version(1)
#pragma stateVertex(PV)
#pragma stateFragment(PFBackground)
#pragma stateFragmentStore(PFSBackground)

/*
typedef struct FilmScriptUserEnvRec {
    RsAllocation tex[13];
    int32_t triangleOffsets[64];
    float triangleOffsetsTex[64];
    int32_t triangleOffsetsCount;
} FilmScriptUserEnv; 
*/ 

// The script enviroment has 3 env allocations.
// bank0: (r) The enviroment structure
// bank1: (r) The position information
// bank2: (rw) The temporary texture state

int main(int index) 
{
    int f1,f2,f3,f4, f5,f6,f7,f8, f9,f10,f11,f12, f13,f14,f15,f16;
    int g1,g2,g3,g4, g5,g6,g7,g8, g9,g10,g11,g12, g13,g14,g15,g16;
    int float_1;
    int float_0;
    int float_2;
    int float_90;
    int float_0_5;
    int trans;  // float
    int rot;   // float
    int x;
    float focusPos;  // float
    int focusID;
    int lastFocusID;
    int imgCount;

    float_2 = intToFloat(2);
    float_1 = intToFloat(1);
    float_0 = intToFloat(0);
    float_90= intToFloat(90);
    float_0_5 = fixedtoFloat(0x8000);

    trans = loadF(1, 0);
    rot = loadF(1, 1);

    matrixLoadScale(&f16, float_2, float_2, float_2);
    matrixTranslate(&f16, 0, 0, trans);
    matrixRotate(&f16, float_90, 0, 0, float_1);
    matrixRotate(&f16, rot, float_1, 0, 0);
    storeEnvMatrix(3, 0, &f16);

    //materialDiffuse(con, 0.0f, 0.0f, 0.0f, 1.0f);
    //materialSpecular(con, 0.5f, 0.5f, 0.5f, 0.5f);
    //materialShininess(intToFloat(20));
    //lightPosition(con, 0.2f, -0.2f, -2.0f, 0.0f);
    //enable(con, GL_LIGHTING);
    renderTriangleMesh(NAMED_mesh);



    //int imgId = 0;

    contextBindProgramFragmentStore(NAMED_PFImages);
    contextBindProgramFragment(NAMED_PFSImages);

    //focusPos = loadF(1, 2);
    //focusID = 0;
    //lastFocusID = loadI32(2, 0);
    //imgCount = 13;

    /*
    disable(GL_LIGHTING);


    if (trans > (-.3)) {
        focusID = -1.0 - focusPos;
        if (focusID >= imgCount) {
            focusID = -1;
        }
    } else {
        focusID = -1;
    }

    if (focusID != lastFocusID) {
        if (lastFocusID >= 0) {
            uploadToTexture(con, env->tex[lastFocusID], 1);
        }
        if (focusID >= 0) {
            uploadToTexture(con, env->tex[focusID], 0);
        }
    }
    storeEnvI32(con, 2, 0, focusID);


    for (imgId=1; imgId <= imgCount; imgId++) {
        float pos = focusPos + imgId + .4f;
        int offset = (int)floor(pos*2);
        pos -= 0.75;
    
        offset += env->triangleOffsetsCount / 2;
    
        if ((offset < 0) || (offset >= env->triangleOffsetsCount)) {
            continue;
        }
    
        int start = offset -2;
        int end = offset + 2;
    
        if (start < 0) {
            start = 0;
        }
        if (end > env->triangleOffsetsCount) {
            end = env->triangleOffsetsCount;
        }
    
        programFragmentBindTexture(con, env->fpImages, 0, env->tex[imgId - 1]);
        matrixLoadTranslate(con, &m, -pos - env->triangleOffsetsTex[env->triangleOffsetsCount / 2], 0, 0); 
        storeEnvMatrix(con, 3, RS_PROGRAM_VERTEX_TEXTURE_OFFSET, &m);
        renderTriangleMeshRange(con, env->mesh, env->triangleOffsets[start], env->triangleOffsets[end] - env->triangleOffsets[start]);
    } 
*/
    return 0;
}