1 /*---------------------------------------------------------------------------*
2 Project: Dolphin GD demo
3 File: gd-indtex-host.c
4
5 Copyright 2003 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Log: gd-indtex-host.c,v $
14 Revision 1.2 02/20/2006 04:13:09 mitu
15 changed include path from dolphin/ to revolution/.
16
17 Revision 1.1 02/08/2006 11:19:43 mitu
18 1st version.
19
20
21 2 03/03/05 14:29 Hirose
22 More updates.
23
24 1 03/02/21 12:12 Hirose
25 Initial ver.
26
27 $NoKeywords: $
28 *---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*
30 gd-indtex
31 Displaylist demo with indirect texture commands
32 [Host program for creating off-line display list file]
33 *---------------------------------------------------------------------------*/
34
35
36 /*---------------------------------------------------------------------------*
37 Header file includes
38 *---------------------------------------------------------------------------*/
39 #include <windows.h>
40
41 #include <revolution/gd.h>
42
43 #include <assert.h>
44 #include <stdarg.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47
48 #include "gd-indtex.h"
49
50 /*---------------------------------------------------------------------------*
51 Macro definitions
52 *---------------------------------------------------------------------------*/
53 #define RoundUp32B(x) (((u32)(x) + 31) & ~31)
54
55
56 /*---------------------------------------------------------------------------*
57 Forward references
58 *---------------------------------------------------------------------------*/
59 // defined in gd-win32-ui.c
60 extern void GDReport (char* msg, ...);
61
62 void main ( void );
63
64 /*---------------------------------------------------------------------------*
65 Application name
66 *---------------------------------------------------------------------------*/
67 char* AppName = "gd-indtex-host";
68
69 /*---------------------------------------------------------------------------*
70 Global variables
71 *---------------------------------------------------------------------------*/
72 static u32(*CreateEffectDLFunc[NUM_EFFECTS])() =
73 {
74 CreateEffectDL0, CreateEffectDL1, CreateEffectDL2, CreateEffectDL3
75 };
76
77 /*---------------------------------------------------------------------------*
78 Application main loop
79 *---------------------------------------------------------------------------*/
80 // Function WinMain() is defined in gd-win32-ui.c
main(void)81 void main ( void )
82 {
83 GDGList dlists[NUM_DLS]; // keeps track of all display lists
84 u32 size;
85 void* buffer;
86 u8* ptr;
87 u32 i;
88 u32 index;
89
90 // Allocate entire work memory first
91 size = EFFECTDL_SIZE_MAX * NUM_DLS + 32;
92 buffer = malloc(size);
93 assert(buffer);
94
95 index = 0;
96
97 // Make sure 32Bytes alignment
98 ptr = (u8*)RoundUp32B(buffer);
99
100
101 // Create multi-texturing shader display lists
102 for ( i = 0 ; i < NUM_DLS ; ++i )
103 {
104 dlists[index].ptr = (void*)ptr;
105 ptr += EFFECTDL_SIZE_MAX;
106
107 dlists[index].byteLength = (*CreateEffectDLFunc[i])(dlists[index].ptr);
108
109 index++;
110 }
111
112 GDWriteDLFile("gdIndTex.gdl", NUM_DLS, NUM_PLS, dlists, NULL /* No PLs*/);
113
114 free(buffer);
115
116 GDReport("Created file \"gdIndTex.gdl\" successfully.");
117 }
118
119 /*============================================================================*/
120