comparison libvo/vo_gl2.c @ 12448:180c2fb327d3

removing useless code, improving readability
author reimar
date Sat, 08 May 2004 23:53:20 +0000
parents 59cd81e2e1ef
children bd90b887fb13
comparison
equal deleted inserted replaced
12447:fde132f084ce 12448:180c2fb327d3
79 79
80 static int int_pause; 80 static int int_pause;
81 81
82 static uint32_t texture_width; 82 static uint32_t texture_width;
83 static uint32_t texture_height; 83 static uint32_t texture_height;
84 static int texnumx, texnumy, memory_x_len, memory_x_start_offset, raw_line_len; 84 static int texnumx, texnumy, raw_line_len;
85 static GLfloat texpercx, texpercy; 85 static GLfloat texpercx, texpercy;
86 static struct TexSquare * texgrid; 86 static struct TexSquare * texgrid;
87 static GLint gl_internal_format; 87 static GLint gl_internal_format;
88 static char * gl_internal_format_s; 88 static char * gl_internal_format_s;
89 static int rgb_sz, r_sz, g_sz, b_sz, a_sz; 89 static int rgb_sz, r_sz, g_sz, b_sz, a_sz;
112 GLfloat xcov, ycov; 112 GLfloat xcov, ycov;
113 int isDirty; 113 int isDirty;
114 int dirtyXoff, dirtyYoff, dirtyWidth, dirtyHeight; 114 int dirtyXoff, dirtyYoff, dirtyWidth, dirtyHeight;
115 }; 115 };
116 116
117 static void resetTexturePointers(unsigned char *imageSource);
118
117 static void CalcFlatPoint(int x,int y,GLfloat *px,GLfloat *py) 119 static void CalcFlatPoint(int x,int y,GLfloat *px,GLfloat *py)
118 { 120 {
119 *px=(float)x*texpercx; 121 *px=(float)x*texpercx;
120 if(*px>1.0) *px=1.0; 122 if(*px>1.0) *px=1.0;
121 *py=(float)y*texpercy; 123 *py=(float)y*texpercy;
122 if(*py>1.0) *py=1.0; 124 if(*py>1.0) *py=1.0;
123 } 125 }
124 126
125 static int initTextures() 127 static int initTextures()
126 { 128 {
127 unsigned char *line_1=0, *line_2=0, *mem_start=0;
128 struct TexSquare *tsq=0; 129 struct TexSquare *tsq=0;
129 int e_x, e_y, s, i=0; 130 int e_x, e_y, s, i=0;
130 int x=0, y=0; 131 int x=0, y=0;
131 GLint format=0; 132 GLint format=0;
132 GLenum err; 133 GLenum err;
207 texpercy = 1.0; 208 texpercy = 1.0;
208 209
209 texgrid = (struct TexSquare *) 210 texgrid = (struct TexSquare *)
210 calloc (texnumx * texnumy, sizeof (struct TexSquare)); 211 calloc (texnumx * texnumy, sizeof (struct TexSquare));
211 212
212 line_1 = (unsigned char *) ImageData; 213 raw_line_len = image_width * image_bytes;
213 line_2 = (unsigned char *) ImageData+(image_width*image_bytes);
214
215 mem_start = (unsigned char *) ImageData;
216
217 raw_line_len = line_2 - line_1;
218
219 memory_x_len = raw_line_len / image_bytes;
220 214
221 mp_msg (MSGT_VO, MSGL_DBG2, "[gl2] texture-usage %d*width=%d, %d*height=%d\n", 215 mp_msg (MSGT_VO, MSGL_DBG2, "[gl2] texture-usage %d*width=%d, %d*height=%d\n",
222 (int) texnumx, (int) texture_width, (int) texnumy, 216 (int) texnumx, (int) texture_width, (int) texnumy,
223 (int) texture_height); 217 (int) texture_height);
224 218
242 236
243 CalcFlatPoint (x, y, &(tsq->fx1), &(tsq->fy1)); 237 CalcFlatPoint (x, y, &(tsq->fx1), &(tsq->fy1));
244 CalcFlatPoint (x + 1, y, &(tsq->fx2), &(tsq->fy2)); 238 CalcFlatPoint (x + 1, y, &(tsq->fx2), &(tsq->fy2));
245 CalcFlatPoint (x + 1, y + 1, &(tsq->fx3), &(tsq->fy3)); 239 CalcFlatPoint (x + 1, y + 1, &(tsq->fx3), &(tsq->fy3));
246 CalcFlatPoint (x, y + 1, &(tsq->fx4), &(tsq->fy4)); 240 CalcFlatPoint (x, y + 1, &(tsq->fx4), &(tsq->fy4));
247
248 /* calculate the pixel store data,
249 to use the machine-bitmap for our texture
250 */
251 memory_x_start_offset = 0 * image_bytes +
252 x * texture_width * image_bytes;
253
254 tsq->texture = line_1 +
255 y * texture_height * raw_line_len +
256 memory_x_start_offset;
257 241
258 tsq->isDirty=GL_TRUE; 242 tsq->isDirty=GL_TRUE;
259 tsq->isTexture=GL_FALSE; 243 tsq->isTexture=GL_FALSE;
260 tsq->texobj=0; 244 tsq->texobj=0;
261 tsq->dirtyXoff=0; tsq->dirtyYoff=0; tsq->dirtyWidth=-1; tsq->dirtyHeight=-1; 245 tsq->dirtyXoff=0; tsq->dirtyYoff=0; tsq->dirtyWidth=-1; tsq->dirtyHeight=-1;
292 276
293 glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 277 glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
294 278
295 } /* for all texnumx */ 279 } /* for all texnumx */
296 } /* for all texnumy */ 280 } /* for all texnumy */
281 resetTexturePointers (ImageData);
297 282
298 return 0; 283 return 0;
299 } 284 }
300 285
301 static void resetTexturePointers(unsigned char *imageSource) 286 static void resetTexturePointers(unsigned char *imageSource)
302 { 287 {
303 unsigned char *line_1=0, *line_2=0, *mem_start=0; 288 unsigned char *texdata_start, *line_start;
304 struct TexSquare *tsq=0; 289 struct TexSquare *tsq = texgrid;
305 int x=0, y=0; 290 int x=0, y=0;
306 291
307 line_1 = (unsigned char *) imageSource; 292 line_start = (unsigned char *) imageSource;
308 line_2 = (unsigned char *) imageSource+(image_width*image_bytes);
309
310 mem_start = (unsigned char *) imageSource;
311 293
312 for (y = 0; y < texnumy; y++) 294 for (y = 0; y < texnumy; y++)
313 { 295 {
296 texdata_start = line_start;
314 for (x = 0; x < texnumx; x++) 297 for (x = 0; x < texnumx; x++)
315 { 298 {
316 tsq = texgrid + y * texnumx + x; 299 tsq->texture = texdata_start;
317 300 texdata_start += texture_width * image_bytes;
318 /* calculate the pixel store data, 301 tsq++;
319 to use the machine-bitmap for our texture
320 */
321 memory_x_start_offset = 0 * image_bytes +
322 x * texture_width * image_bytes;
323
324 tsq->texture = line_1 +
325 y * texture_height * raw_line_len +
326 memory_x_start_offset;
327
328 } /* for all texnumx */ 302 } /* for all texnumx */
303 line_start += texture_height * raw_line_len;
329 } /* for all texnumy */ 304 } /* for all texnumy */
330 } 305 }
331 306
332 static void setupTextureDirtyArea(int x, int y, int w,int h) 307 static void setupTextureDirtyArea(int x, int y, int w,int h)
333 { 308 {
821 glDisable(GL_BLEND); 796 glDisable(GL_BLEND);
822 glDisable(GL_DEPTH_TEST); 797 glDisable(GL_DEPTH_TEST);
823 glDepthMask(GL_FALSE); 798 glDepthMask(GL_FALSE);
824 glDisable(GL_CULL_FACE); 799 glDisable(GL_CULL_FACE);
825 800
826 glPixelStorei (GL_UNPACK_ROW_LENGTH, memory_x_len); 801 glPixelStorei (GL_UNPACK_ROW_LENGTH, image_width);
827 802
828 /** 803 /**
829 * may give a little speed up for a kinda burst read .. 804 * may give a little speed up for a kinda burst read ..
830 */ 805 */
831 if( (image_width*image_bpp)%8 == 0 ) 806 if( (image_width*image_bpp)%8 == 0 )