annotate TOOLS/gltest.c @ 22740:9128aa26244a

Add return 0 to fix the following warning: bmovl-test.c:118: warning: control reaches end of non-void function
author diego
date Tue, 20 Mar 2007 01:15:28 +0000
parents 2852487b2f8d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22737
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
1 // OpenGL glTexSubImage() test/benchmark prg (C) 2001. by A'rpi/ESP-team
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
2
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
3 #include <GL/glut.h>
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
4 #include <stdio.h>
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
5 #include <stdlib.h>
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
6 #include <math.h>
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
7 #include <inttypes.h>
22738
2852487b2f8d Add #include <string.h> to fix the following warning:
diego
parents: 22737
diff changeset
8 #include <string.h>
22737
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
9
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
10 // pixel size: 3 or 4
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
11 #define BYTES_PP 3
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
12
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
13 // blit by lines (defined) or frames (not defined)
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
14 #define FAST_BLIT
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
15
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
16 static uint32_t image_width=720; // DVD size
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
17 static uint32_t image_height=576;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
18
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
19 static uint32_t image_format;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
20 static uint32_t image_bpp;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
21 static uint32_t image_bytes;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
22
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
23 static uint32_t texture_width=512;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
24 static uint32_t texture_height=512;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
25
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
26 static unsigned char *ImageData=NULL;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
27
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
28 static GLvoid resize(int x,int y){
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
29 printf("Resize: %dx%d\n",x,y);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
30 glViewport( 0, 0, x, y );
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
31
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
32 glMatrixMode(GL_PROJECTION);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
33 glLoadIdentity();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
34 glOrtho(0, image_width, image_height, 0, -1,1);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
35
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
36 glMatrixMode(GL_MODELVIEW);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
37 glLoadIdentity();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
38 }
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
39
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
40 float akarmi=0;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
41
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
42 int counter=0;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
43 float gen_time=0;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
44 float up_time=0;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
45 float render_time=0;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
46
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
47 unsigned char sintable[4096];
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
48
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
49 extern float GetRelativeTime();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
50
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
51 static void redraw(void)
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
52 {
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
53 // glClear(GL_COLOR_BUFFER_BIT);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
54 int x,y,i;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
55 unsigned char *d=ImageData;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
56 int dstride=BYTES_PP*image_width;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
57
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
58 GetRelativeTime();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
59
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
60 // generate some image:
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
61 for(y=0;y<image_height;y++){
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
62 int y1=2048*sin(akarmi*0.36725+y*0.0165);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
63 int y2=2048*sin(akarmi*0.45621+y*0.02753);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
64 int y3=2048*sin(akarmi*0.15643+y*0.03732);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
65 for(x=0;x<image_width;x++){
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
66 d[0]=sintable[(y1+x*135)&4095];
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
67 d[1]=sintable[(y2+x*62)&4095];
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
68 d[2]=sintable[(y3+x*23)&4095];
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
69 d+=BYTES_PP;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
70 }
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
71 }
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
72
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
73 gen_time+=GetRelativeTime();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
74
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
75 #ifdef FAST_BLIT
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
76 // upload texture:
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
77 for(i=0;i<image_height;i++){
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
78 glTexSubImage2D( GL_TEXTURE_2D, // target
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
79 0, // level
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
80 0, // x offset
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
81 i, // y offset
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
82 image_width, // width
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
83 1, // height
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
84 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
85 GL_UNSIGNED_BYTE, // type
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
86 ImageData+i*dstride ); // *pixels
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
87 }
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
88 #else
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
89 glTexSubImage2D( GL_TEXTURE_2D, // target
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
90 0, // level
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
91 0, // x offset
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
92 0, // y offset
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
93 image_width, // width
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
94 image_height, // height
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
95 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
96 GL_UNSIGNED_BYTE, // type
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
97 ImageData ); // *pixels
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
98 #endif
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
99
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
100 up_time+=GetRelativeTime();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
101
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
102 glColor3f(1,1,1);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
103 glBegin(GL_QUADS);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
104 glTexCoord2f(0,0);glVertex2i(0,0);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
105 glTexCoord2f(0,1);glVertex2i(0,texture_height);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
106 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
107 glTexCoord2f(1,0);glVertex2i(texture_width,0);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
108 glEnd();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
109
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
110 glFinish();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
111 glutSwapBuffers();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
112
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
113 render_time+=GetRelativeTime();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
114
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
115 ++counter;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
116 { float total=gen_time+up_time+render_time;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
117 if(total>2.0){
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
118 printf("%8.3f fps (gen: %2d%% upload: %2d%% render: %2d%%)\n",
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
119 (float)counter/total,
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
120 (int)(100.0*gen_time/total),
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
121 (int)(100.0*up_time/total),
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
122 (int)(100.0*render_time/total)
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
123 );
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
124 gen_time=up_time=render_time=0;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
125 counter=0;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
126 } }
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
127
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
128 }
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
129
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
130 static GLvoid IdleFunc(){
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
131 akarmi+=0.1;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
132 glutPostRedisplay();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
133 }
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
134
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
135 int
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
136 main(int argc, char **argv)
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
137 {
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
138 int i;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
139
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
140 glutInit(&argc, argv);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
141 glutInitWindowSize(640, 480);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
142 glutInitDisplayMode(GLUT_DOUBLE);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
143 (void) glutCreateWindow("csg");
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
144
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
145 glutDisplayFunc(redraw);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
146 glutReshapeFunc(resize);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
147 glutIdleFunc(IdleFunc);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
148
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
149 texture_width=32;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
150 while(texture_width<image_width) texture_width*=2;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
151 while(texture_width<image_height) texture_width*=2;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
152 texture_height=texture_width;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
153
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
154 image_bpp=8*BYTES_PP;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
155 image_bytes=BYTES_PP;
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
156
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
157 ImageData=malloc(texture_width*texture_height*image_bytes);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
158 memset(ImageData,128,texture_width*texture_height*image_bytes);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
159
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
160 glDisable(GL_BLEND);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
161 glDisable(GL_DEPTH_TEST);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
162 glDepthMask(GL_FALSE);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
163 glDisable(GL_CULL_FACE);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
164
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
165 glEnable(GL_TEXTURE_2D);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
166
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
167 printf("Creating %dx%d texture...\n",texture_width,texture_height);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
168
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
169 #if 1
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
170 // glBindTexture(GL_TEXTURE_2D, texture_id);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
171 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
172 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
173 #ifdef TEXTUREFORMAT_32BPP
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
174 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture_width, texture_height, 0,
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
175 #else
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
176 glTexImage2D(GL_TEXTURE_2D, 0, BYTES_PP, texture_width, texture_height, 0,
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
177 #endif
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
178 (image_bytes==4)?GL_RGBA:GL_BGR, GL_UNSIGNED_BYTE, ImageData);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
179 #endif
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
180
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
181 resize(640,480);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
182
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
183 glClearColor( 1.0f,0.0f,1.0f,0.0f );
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
184 glClear( GL_COLOR_BUFFER_BIT );
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
185
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
186 for(i=0;i<4096;i++) sintable[i]=128+127*sin(2.0*3.14159265*i/4096.0);
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
187
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
188 glutMainLoop();
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
189 return 0; /* ANSI C requires main to return int. */
6ce48e36dc01 Move gltest and bmovl-test into the main TOOLS directory, subdirectories
diego
parents:
diff changeset
190 }