Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 1965:a788656ca29a
SDL constants are all uppercase.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 05 Aug 2006 17:09:42 +0000 |
parents | 420716272158 |
children | db3ba6c0d0df |
comparison
equal
deleted
inserted
replaced
1964:071b6598d48f | 1965:a788656ca29a |
---|---|
63 | 63 |
64 SDL_RenderDriver GL_RenderDriver = { | 64 SDL_RenderDriver GL_RenderDriver = { |
65 GL_CreateRenderer, | 65 GL_CreateRenderer, |
66 { | 66 { |
67 "opengl", | 67 "opengl", |
68 (SDL_Renderer_PresentDiscard | SDL_Renderer_PresentVSync | | 68 (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | |
69 SDL_Renderer_Accelerated), | 69 SDL_RENDERER_ACCELERATED), |
70 (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask | | 70 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK | |
71 SDL_TextureBlendMode_Blend | SDL_TextureBlendMode_Add | | 71 SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | |
72 SDL_TextureBlendMode_Mod), | 72 SDL_TEXTUREBLENDMODE_MOD), |
73 (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast | | 73 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST | |
74 SDL_TextureScaleMode_Slow), | 74 SDL_TEXTURESCALEMODE_SLOW), |
75 16, | 75 16, |
76 { | 76 { |
77 SDL_PixelFormat_Index1LSB, | 77 SDL_PIXELFORMAT_INDEX1LSB, |
78 SDL_PixelFormat_Index1MSB, | 78 SDL_PIXELFORMAT_INDEX1MSB, |
79 SDL_PixelFormat_Index8, | 79 SDL_PIXELFORMAT_INDEX8, |
80 SDL_PixelFormat_RGB332, | 80 SDL_PIXELFORMAT_RGB332, |
81 SDL_PixelFormat_RGB444, | 81 SDL_PIXELFORMAT_RGB444, |
82 SDL_PixelFormat_RGB555, | 82 SDL_PIXELFORMAT_RGB555, |
83 SDL_PixelFormat_ARGB4444, | 83 SDL_PIXELFORMAT_ARGB4444, |
84 SDL_PixelFormat_ARGB1555, | 84 SDL_PIXELFORMAT_ARGB1555, |
85 SDL_PixelFormat_RGB565, | 85 SDL_PIXELFORMAT_RGB565, |
86 SDL_PixelFormat_RGB24, | 86 SDL_PIXELFORMAT_RGB24, |
87 SDL_PixelFormat_BGR24, | 87 SDL_PIXELFORMAT_BGR24, |
88 SDL_PixelFormat_RGB888, | 88 SDL_PIXELFORMAT_RGB888, |
89 SDL_PixelFormat_BGR888, | 89 SDL_PIXELFORMAT_BGR888, |
90 SDL_PixelFormat_ARGB8888, | 90 SDL_PIXELFORMAT_ARGB8888, |
91 SDL_PixelFormat_ABGR8888, | 91 SDL_PIXELFORMAT_ABGR8888, |
92 SDL_PixelFormat_ARGB2101010}, | 92 SDL_PIXELFORMAT_ARGB2101010}, |
93 0, | 93 0, |
94 0} | 94 0} |
95 }; | 95 }; |
96 | 96 |
97 typedef struct | 97 typedef struct |
234 renderer->info = GL_RenderDriver.info; | 234 renderer->info = GL_RenderDriver.info; |
235 renderer->window = window->id; | 235 renderer->window = window->id; |
236 renderer->driverdata = data; | 236 renderer->driverdata = data; |
237 | 237 |
238 renderer->info.flags = | 238 renderer->info.flags = |
239 (SDL_Renderer_PresentDiscard | SDL_Renderer_Accelerated); | 239 (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED); |
240 | 240 |
241 if (GL_LoadFunctions(data) < 0) { | 241 if (GL_LoadFunctions(data) < 0) { |
242 GL_DestroyRenderer(renderer); | 242 GL_DestroyRenderer(renderer); |
243 return NULL; | 243 return NULL; |
244 } | 244 } |
251 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { | 251 if (SDL_GL_MakeCurrent(window->id, data->context) < 0) { |
252 GL_DestroyRenderer(renderer); | 252 GL_DestroyRenderer(renderer); |
253 return NULL; | 253 return NULL; |
254 } | 254 } |
255 | 255 |
256 if (flags & SDL_Renderer_PresentVSync) { | 256 if (flags & SDL_RENDERER_PRESENTVSYNC) { |
257 SDL_GL_SetSwapInterval(1); | 257 SDL_GL_SetSwapInterval(1); |
258 } else { | 258 } else { |
259 SDL_GL_SetSwapInterval(0); | 259 SDL_GL_SetSwapInterval(0); |
260 } | 260 } |
261 if (SDL_GL_GetSwapInterval() > 0) { | 261 if (SDL_GL_GetSwapInterval() > 0) { |
262 renderer->info.flags |= SDL_Renderer_PresentVSync; | 262 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; |
263 } | 263 } |
264 | 264 |
265 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); | 265 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); |
266 renderer->info.max_texture_width = value; | 266 renderer->info.max_texture_width = value; |
267 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); | 267 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); |
323 GLenum format, type; | 323 GLenum format, type; |
324 int texture_w, texture_h; | 324 int texture_w, texture_h; |
325 GLenum result; | 325 GLenum result; |
326 | 326 |
327 switch (texture->format) { | 327 switch (texture->format) { |
328 case SDL_PixelFormat_Index1LSB: | 328 case SDL_PIXELFORMAT_INDEX1LSB: |
329 case SDL_PixelFormat_Index1MSB: | 329 case SDL_PIXELFORMAT_INDEX1MSB: |
330 internalFormat = GL_RGB; | 330 internalFormat = GL_RGB; |
331 format = GL_COLOR_INDEX; | 331 format = GL_COLOR_INDEX; |
332 type = GL_BITMAP; | 332 type = GL_BITMAP; |
333 break; | 333 break; |
334 case SDL_PixelFormat_Index8: | 334 case SDL_PIXELFORMAT_INDEX8: |
335 internalFormat = GL_RGB; | 335 internalFormat = GL_RGB; |
336 format = GL_COLOR_INDEX; | 336 format = GL_COLOR_INDEX; |
337 type = GL_UNSIGNED_BYTE; | 337 type = GL_UNSIGNED_BYTE; |
338 break; | 338 break; |
339 case SDL_PixelFormat_RGB332: | 339 case SDL_PIXELFORMAT_RGB332: |
340 internalFormat = GL_R3_G3_B2; | 340 internalFormat = GL_R3_G3_B2; |
341 format = GL_RGB; | 341 format = GL_RGB; |
342 type = GL_UNSIGNED_BYTE_3_3_2; | 342 type = GL_UNSIGNED_BYTE_3_3_2; |
343 break; | 343 break; |
344 case SDL_PixelFormat_RGB444: | 344 case SDL_PIXELFORMAT_RGB444: |
345 internalFormat = GL_RGB4; | 345 internalFormat = GL_RGB4; |
346 format = GL_RGB; | 346 format = GL_RGB; |
347 type = GL_UNSIGNED_SHORT_4_4_4_4; | 347 type = GL_UNSIGNED_SHORT_4_4_4_4; |
348 break; | 348 break; |
349 case SDL_PixelFormat_RGB555: | 349 case SDL_PIXELFORMAT_RGB555: |
350 internalFormat = GL_RGB5; | 350 internalFormat = GL_RGB5; |
351 format = GL_RGB; | 351 format = GL_RGB; |
352 type = GL_UNSIGNED_SHORT_5_5_5_1; | 352 type = GL_UNSIGNED_SHORT_5_5_5_1; |
353 break; | 353 break; |
354 case SDL_PixelFormat_ARGB4444: | 354 case SDL_PIXELFORMAT_ARGB4444: |
355 internalFormat = GL_RGBA4; | 355 internalFormat = GL_RGBA4; |
356 format = GL_BGRA; | 356 format = GL_BGRA; |
357 type = GL_UNSIGNED_SHORT_4_4_4_4_REV; | 357 type = GL_UNSIGNED_SHORT_4_4_4_4_REV; |
358 break; | 358 break; |
359 case SDL_PixelFormat_ARGB1555: | 359 case SDL_PIXELFORMAT_ARGB1555: |
360 internalFormat = GL_RGB5_A1; | 360 internalFormat = GL_RGB5_A1; |
361 format = GL_BGRA; | 361 format = GL_BGRA; |
362 type = GL_UNSIGNED_SHORT_1_5_5_5_REV; | 362 type = GL_UNSIGNED_SHORT_1_5_5_5_REV; |
363 break; | 363 break; |
364 case SDL_PixelFormat_RGB565: | 364 case SDL_PIXELFORMAT_RGB565: |
365 internalFormat = GL_RGB8; | 365 internalFormat = GL_RGB8; |
366 format = GL_RGB; | 366 format = GL_RGB; |
367 type = GL_UNSIGNED_SHORT_5_6_5; | 367 type = GL_UNSIGNED_SHORT_5_6_5; |
368 break; | 368 break; |
369 case SDL_PixelFormat_RGB24: | 369 case SDL_PIXELFORMAT_RGB24: |
370 internalFormat = GL_RGB8; | 370 internalFormat = GL_RGB8; |
371 format = GL_RGB; | 371 format = GL_RGB; |
372 type = GL_UNSIGNED_BYTE; | 372 type = GL_UNSIGNED_BYTE; |
373 break; | 373 break; |
374 case SDL_PixelFormat_RGB888: | 374 case SDL_PIXELFORMAT_RGB888: |
375 internalFormat = GL_RGB8; | 375 internalFormat = GL_RGB8; |
376 format = GL_BGRA; | 376 format = GL_BGRA; |
377 type = GL_UNSIGNED_BYTE; | 377 type = GL_UNSIGNED_BYTE; |
378 break; | 378 break; |
379 case SDL_PixelFormat_BGR24: | 379 case SDL_PIXELFORMAT_BGR24: |
380 internalFormat = GL_RGB8; | 380 internalFormat = GL_RGB8; |
381 format = GL_BGR; | 381 format = GL_BGR; |
382 type = GL_UNSIGNED_BYTE; | 382 type = GL_UNSIGNED_BYTE; |
383 break; | 383 break; |
384 case SDL_PixelFormat_BGR888: | 384 case SDL_PIXELFORMAT_BGR888: |
385 internalFormat = GL_RGB8; | 385 internalFormat = GL_RGB8; |
386 format = GL_RGBA; | 386 format = GL_RGBA; |
387 type = GL_UNSIGNED_BYTE; | 387 type = GL_UNSIGNED_BYTE; |
388 break; | 388 break; |
389 case SDL_PixelFormat_ARGB8888: | 389 case SDL_PIXELFORMAT_ARGB8888: |
390 internalFormat = GL_RGBA8; | 390 internalFormat = GL_RGBA8; |
391 format = GL_BGRA; | 391 format = GL_BGRA; |
392 type = GL_UNSIGNED_BYTE; | 392 type = GL_UNSIGNED_BYTE; |
393 break; | 393 break; |
394 case SDL_PixelFormat_ABGR8888: | 394 case SDL_PIXELFORMAT_ABGR8888: |
395 internalFormat = GL_RGBA8; | 395 internalFormat = GL_RGBA8; |
396 format = GL_RGBA; | 396 format = GL_RGBA; |
397 type = GL_UNSIGNED_BYTE; | 397 type = GL_UNSIGNED_BYTE; |
398 break; | 398 break; |
399 case SDL_PixelFormat_ARGB2101010: | 399 case SDL_PIXELFORMAT_ARGB2101010: |
400 internalFormat = GL_RGB10_A2; | 400 internalFormat = GL_RGB10_A2; |
401 format = GL_BGRA; | 401 format = GL_BGRA; |
402 type = GL_UNSIGNED_INT_2_10_10_10_REV; | 402 type = GL_UNSIGNED_INT_2_10_10_10_REV; |
403 break; | 403 break; |
404 default: | 404 default: |
463 | 463 |
464 static void | 464 static void |
465 SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture, | 465 SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture, |
466 int pitch) | 466 int pitch) |
467 { | 467 { |
468 if (texture->format == SDL_PixelFormat_Index1LSB) { | 468 if (texture->format == SDL_PIXELFORMAT_INDEX1LSB) { |
469 renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 1); | 469 renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 1); |
470 } else if (texture->format == SDL_PixelFormat_Index1MSB) { | 470 } else if (texture->format == SDL_PIXELFORMAT_INDEX1MSB) { |
471 renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 0); | 471 renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 0); |
472 } | 472 } |
473 renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | 473 renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
474 renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, | 474 renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, |
475 pitch / SDL_BYTESPERPIXEL(texture->format)); | 475 pitch / SDL_BYTESPERPIXEL(texture->format)); |
606 | 606 |
607 data->glBindTexture(texturedata->type, texturedata->texture); | 607 data->glBindTexture(texturedata->type, texturedata->texture); |
608 | 608 |
609 if (blendMode != data->blendMode) { | 609 if (blendMode != data->blendMode) { |
610 switch (blendMode) { | 610 switch (blendMode) { |
611 case SDL_TextureBlendMode_None: | 611 case SDL_TEXTUREBLENDMODE_NONE: |
612 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); | 612 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); |
613 data->glDisable(GL_BLEND); | 613 data->glDisable(GL_BLEND); |
614 break; | 614 break; |
615 case SDL_TextureBlendMode_Mask: | 615 case SDL_TEXTUREBLENDMODE_MASK: |
616 case SDL_TextureBlendMode_Blend: | 616 case SDL_TEXTUREBLENDMODE_BLEND: |
617 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 617 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
618 data->glEnable(GL_BLEND); | 618 data->glEnable(GL_BLEND); |
619 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 619 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
620 break; | 620 break; |
621 case SDL_TextureBlendMode_Add: | 621 case SDL_TEXTUREBLENDMODE_ADD: |
622 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 622 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
623 data->glEnable(GL_BLEND); | 623 data->glEnable(GL_BLEND); |
624 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); | 624 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); |
625 break; | 625 break; |
626 case SDL_TextureBlendMode_Mod: | 626 case SDL_TEXTUREBLENDMODE_MOD: |
627 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 627 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
628 data->glEnable(GL_BLEND); | 628 data->glEnable(GL_BLEND); |
629 data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); | 629 data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); |
630 break; | 630 break; |
631 } | 631 } |
632 data->blendMode = blendMode; | 632 data->blendMode = blendMode; |
633 } | 633 } |
634 | 634 |
635 if (scaleMode != data->scaleMode) { | 635 if (scaleMode != data->scaleMode) { |
636 switch (scaleMode) { | 636 switch (scaleMode) { |
637 case SDL_TextureScaleMode_None: | 637 case SDL_TEXTURESCALEMODE_NONE: |
638 case SDL_TextureScaleMode_Fast: | 638 case SDL_TEXTURESCALEMODE_FAST: |
639 data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, | 639 data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, |
640 GL_NEAREST); | 640 GL_NEAREST); |
641 data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, | 641 data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, |
642 GL_NEAREST); | 642 GL_NEAREST); |
643 break; | 643 break; |
644 case SDL_TextureScaleMode_Slow: | 644 case SDL_TEXTURESCALEMODE_SLOW: |
645 case SDL_TextureScaleMode_Best: | 645 case SDL_TEXTURESCALEMODE_BEST: |
646 data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, | 646 data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, |
647 GL_LINEAR); | 647 GL_LINEAR); |
648 data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, | 648 data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, |
649 GL_LINEAR); | 649 GL_LINEAR); |
650 break; | 650 break; |