1 | /****************************************************************************** |
---|
2 | * Author : Byungil Jeong |
---|
3 | * |
---|
4 | * Copyright (C) 2004 Electronic Visualization Laboratory, |
---|
5 | * University of Illinois at Chicago |
---|
6 | * |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above |
---|
15 | * copyright notice, this list of conditions and the following disclaimer |
---|
16 | * in the documentation and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the University of Illinois at Chicago nor |
---|
18 | * the names of its contributors may be used to endorse or promote |
---|
19 | * products derived from this software without specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
28 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | * |
---|
33 | * Direct questions, comments etc about SAGE to bijeong@evl.uic.edu or |
---|
34 | * http://www.evl.uic.edu/cavern/forum/ |
---|
35 | * |
---|
36 | *****************************************************************************/ |
---|
37 | |
---|
38 | |
---|
39 | //A simple test program that pushes DXT pixels to SAGE frame buffer |
---|
40 | //written by Luc Renambot |
---|
41 | //Feb 2007 |
---|
42 | |
---|
43 | #include <stdio.h> |
---|
44 | #include <math.h> |
---|
45 | #include <stdlib.h> |
---|
46 | |
---|
47 | // headers for SAGE |
---|
48 | #include "sail.h" |
---|
49 | #include "misc.h" |
---|
50 | |
---|
51 | int main(int argc, char *argv[]) |
---|
52 | { |
---|
53 | sail sageInf; // sail object |
---|
54 | int nodeID; |
---|
55 | char fn[256]; |
---|
56 | FILE *fin; |
---|
57 | |
---|
58 | nodeID = 0; |
---|
59 | |
---|
60 | int resX = atoi(argv[1]); |
---|
61 | int resY = atoi(argv[2]); |
---|
62 | |
---|
63 | GLsizei sz = 8 * (resX / 4) * (resY / 4); |
---|
64 | |
---|
65 | std::cout << std::endl << "ResX = " << resX << " ResY = " << resY << std::endl; |
---|
66 | std::cout << "File = " << argv[3] << std::endl; |
---|
67 | |
---|
68 | sailConfig scfg; |
---|
69 | scfg.init("dxt.conf"); |
---|
70 | scfg.setAppName("dxt"); |
---|
71 | scfg.rank = nodeID; |
---|
72 | |
---|
73 | scfg.resX = resX; |
---|
74 | scfg.resY = resY; |
---|
75 | |
---|
76 | sageRect renderImageMap; |
---|
77 | renderImageMap.left = 0.0; |
---|
78 | renderImageMap.right = 1.0; |
---|
79 | renderImageMap.bottom = 0.0; |
---|
80 | renderImageMap.top = 1.0; |
---|
81 | |
---|
82 | scfg.imageMap = renderImageMap; |
---|
83 | scfg.pixFmt = PIXFMT_DXT; |
---|
84 | scfg.rowOrd = BOTTOM_TO_TOP; |
---|
85 | scfg.master = true; |
---|
86 | scfg.nwID = 1; |
---|
87 | |
---|
88 | sageInf.init(scfg); |
---|
89 | std::cout << "sail initialized " << std::endl; |
---|
90 | |
---|
91 | void *buffer, *pix; |
---|
92 | |
---|
93 | pix = malloc(sz); |
---|
94 | memset(pix, 0, sz); |
---|
95 | int dummy_w, dummy_h; |
---|
96 | fin = fopen(argv[3], "rb"); |
---|
97 | fread(&dummy_w, 1, sizeof(int), fin); |
---|
98 | fread(&dummy_h, 1, sizeof(int), fin); |
---|
99 | fread(pix, 1, sz, fin); |
---|
100 | fclose(fin); |
---|
101 | |
---|
102 | |
---|
103 | while(1) { |
---|
104 | |
---|
105 | buffer = sageInf.getBuffer(); |
---|
106 | memcpy(buffer, pix, sz); |
---|
107 | |
---|
108 | sageInf.swapBuffer(); |
---|
109 | sageMessage msg; |
---|
110 | |
---|
111 | if (sageInf.checkMsg(msg, false) > 0) { |
---|
112 | switch (msg.getCode()) { |
---|
113 | case APP_QUIT : { |
---|
114 | exit(0); |
---|
115 | break; |
---|
116 | } |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | return 0; |
---|
122 | } |
---|