~ubuntu-branches/ubuntu/jaunty/mesa/jaunty

« back to all changes in this revision

Viewing changes to progs/glsl/multitex.c

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2009-04-03 12:42:06 UTC
  • mfrom: (1.2.16 upstream) (3.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20090403124206-0oo9dl0tcmd0qr38
Tags: 7.4-0ubuntu1
* New upstream release, merge from debian-experimental
  (LP: #330476, #347171, #349127)
* Drop 103_rs600_support.patch, included in this version.
* Drop 104_swrast_fbconfigs.patch, included in this version.
* Add 103_bump_965_texture_limit.diff. (LP: #146298)
* Add 104_fix_dri2_ext_tfp.diff. (LP: #324854)

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
static GLuint Program;
49
49
 
50
 
static GLfloat Xrot = -90.0, Yrot = .0, Zrot = 0.0;
 
50
static GLfloat Xrot = 0.0, Yrot = .0, Zrot = 0.0;
51
51
static GLfloat EyeDist = 10;
52
52
static GLboolean Anim = GL_TRUE;
 
53
static GLboolean UseArrays = GL_TRUE;
 
54
 
 
55
static GLint VertCoord_attr = -1, TexCoord0_attr = -1, TexCoord1_attr = -1;
53
56
 
54
57
 
55
58
/* value[0] = tex unit */
60
63
};
61
64
 
62
65
 
63
 
static void
64
 
DrawPolygon(GLfloat size)
65
 
{
66
 
   glPushMatrix();
67
 
   glRotatef(90, 1, 0, 0);
68
 
   glNormal3f(0, 0, 1);
69
 
   glBegin(GL_POLYGON);
70
 
 
71
 
   glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
72
 
   glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
73
 
   glVertex2f(-size, -size);
74
 
 
75
 
   glMultiTexCoord2f(GL_TEXTURE0, 2, 0);
76
 
   glMultiTexCoord2f(GL_TEXTURE1, 1, 0);
77
 
   glVertex2f( size, -size);
78
 
 
79
 
   glMultiTexCoord2f(GL_TEXTURE0, 2, 2);
80
 
   glMultiTexCoord2f(GL_TEXTURE1, 1, 1);
81
 
   glVertex2f( size,  size);
82
 
 
83
 
   glMultiTexCoord2f(GL_TEXTURE0, 0, 2);
84
 
   glMultiTexCoord2f(GL_TEXTURE1, 0, 1);
85
 
   glVertex2f(-size,  size);
 
66
static const GLfloat Tex0Coords[4][2] = {
 
67
   { 0.0, 0.0 }, { 2.0, 0.0 }, { 2.0, 2.0 }, { 0.0, 2.0 }
 
68
};
 
69
 
 
70
static const GLfloat Tex1Coords[4][2] = {
 
71
   { 0.0, 0.0 }, { 1.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 1.0 }
 
72
};
 
73
 
 
74
static const GLfloat VertCoords[4][2] = {
 
75
   { -3.0, -3.0 }, { 3.0, -3.0 }, { 3.0, 3.0 }, { -3.0, 3.0 }
 
76
};
 
77
 
 
78
 
 
79
static void
 
80
DrawPolygonArray(void)
 
81
{
 
82
   if (VertCoord_attr >= 0) {
 
83
      glVertexAttribPointer_func(VertCoord_attr, 2, GL_FLOAT, GL_FALSE,
 
84
                                 0, VertCoords);
 
85
      glEnableVertexAttribArray_func(VertCoord_attr);
 
86
   }
 
87
   else {
 
88
      glVertexPointer(2, GL_FLOAT, 0, VertCoords);
 
89
      glEnable(GL_VERTEX_ARRAY);
 
90
   }
 
91
 
 
92
   glVertexAttribPointer_func(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE,
 
93
                              0, Tex0Coords);
 
94
   glEnableVertexAttribArray_func(TexCoord0_attr);
 
95
 
 
96
   glVertexAttribPointer_func(TexCoord1_attr, 2, GL_FLOAT, GL_FALSE,
 
97
                              0, Tex1Coords);
 
98
   glEnableVertexAttribArray_func(TexCoord1_attr);
 
99
 
 
100
   glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
101
}
 
102
 
 
103
 
 
104
static void
 
105
DrawPolygonVert(void)
 
106
{
 
107
   GLuint i;
 
108
 
 
109
   glBegin(GL_TRIANGLE_FAN);
 
110
 
 
111
   for (i = 0; i < 4; i++) {
 
112
      glVertexAttrib2fv_func(TexCoord0_attr, Tex0Coords[i]);
 
113
      glVertexAttrib2fv_func(TexCoord1_attr, Tex1Coords[i]);
 
114
 
 
115
      if (VertCoord_attr >= 0)
 
116
         glVertexAttrib2fv_func(VertCoord_attr, VertCoords[i]);
 
117
      else
 
118
         glVertex2fv(VertCoords[i]);
 
119
   }
86
120
 
87
121
   glEnd();
88
 
   glPopMatrix();
89
122
}
90
123
 
91
124
 
100
133
      glRotatef(Yrot, 0, 1, 0);
101
134
      glRotatef(Xrot, 1, 0, 0);
102
135
 
103
 
      DrawPolygon(3.0);
 
136
      if (UseArrays)
 
137
         DrawPolygonArray();
 
138
      else
 
139
         DrawPolygonVert();
104
140
 
105
141
   glPopMatrix();
106
142
 
123
159
   (void) x;
124
160
   (void) y;
125
161
   switch (k) {
 
162
   case 'a':
 
163
      UseArrays = !UseArrays;
 
164
      printf("Arrays: %d\n", UseArrays);
 
165
      break;
126
166
   case ' ':
127
 
   case 'a':
128
167
      Anim = !Anim;
129
168
      if (Anim)
130
169
         glutIdleFunc(idle);
232
271
 
233
272
   InitUniforms(program, uniforms);
234
273
 
 
274
   TexCoord0_attr = glGetAttribLocation_func(program, "TexCoord0");
 
275
   TexCoord1_attr = glGetAttribLocation_func(program, "TexCoord1");
 
276
   VertCoord_attr = glGetAttribLocation_func(program, "VertCoord");
 
277
   printf("TexCoord0_attr = %d\n", TexCoord0_attr);
 
278
   printf("TexCoord1_attr = %d\n", TexCoord1_attr);
 
279
   printf("VertCoord_attr = %d\n", VertCoord_attr);
 
280
 
235
281
   return program;
236
282
}
237
283