branch | bug235_bringup_0 |
changeset 76 | 24381b61de5c |
parent 55 | 09263774e342 |
75:82d8da1d79c7 | 76:24381b61de5c |
---|---|
31 #include "context.h" |
31 #include "context.h" |
32 #include "half.h" |
32 #include "half.h" |
33 #include "util.h" |
33 #include "util.h" |
34 #include "degl.h" |
34 #include "degl.h" |
35 |
35 |
36 #ifdef __cplusplus |
|
37 extern "C" |
|
38 { |
|
39 GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); |
|
40 } |
|
41 #endif |
|
42 |
|
36 DGLTexture* DGLTexture_create(GLuint name, DGLTextureType type, GLint num_levels) |
43 DGLTexture* DGLTexture_create(GLuint name, DGLTextureType type, GLint num_levels) |
37 { |
44 { |
38 DGLTexture* texture = malloc(sizeof(DGLTexture)); |
45 DGLTexture* texture = (DGLTexture*)malloc(sizeof(DGLTexture)); |
39 if(texture == NULL) |
46 if(texture == NULL) |
40 { |
47 { |
41 return NULL; |
48 return NULL; |
42 } |
49 } |
43 |
50 |
49 { |
56 { |
50 int face; |
57 int face; |
51 for(face = 0; face < 6; face++) |
58 for(face = 0; face < 6; face++) |
52 { |
59 { |
53 texture->num_levels[face] = 0; |
60 texture->num_levels[face] = 0; |
54 texture->levels[face] = malloc(num_levels * sizeof(DGLTextureLevel)); |
61 texture->levels[face] = (DGLTextureLevel*)malloc(num_levels * sizeof(DGLTextureLevel)); |
55 if(texture->levels[face] == NULL) |
62 if(texture->levels[face] == NULL) |
56 { |
63 { |
57 while(face--) |
64 while(face--) |
58 { |
65 { |
59 free(texture->levels[face]); |
66 free(texture->levels[face]); |
116 DGLES2_ASSERT(texture->type == DGLES2_TEXTURE_CUBE_MAP); |
123 DGLES2_ASSERT(texture->type == DGLES2_TEXTURE_CUBE_MAP); |
117 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; |
124 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; |
118 |
125 |
119 default: |
126 default: |
120 DGLES2_ASSERT(GL_FALSE); |
127 DGLES2_ASSERT(GL_FALSE); |
121 return -1; |
128 return (GLenum)-1; |
122 } |
129 } |
123 } |
130 } |
124 } |
131 } |
125 |
132 |
126 void DGLTexture_destroy(DGLTexture *texture) |
133 void DGLTexture_destroy(DGLTexture *texture) |
382 |
389 |
383 static void* dglDecompressETCTexture(int width, int height, const unsigned char* data) |
390 static void* dglDecompressETCTexture(int width, int height, const unsigned char* data) |
384 { |
391 { |
385 int bytes_per_pixel = 3; // RGB888 |
392 int bytes_per_pixel = 3; // RGB888 |
386 |
393 |
387 unsigned char* decompressed = malloc(width * height * bytes_per_pixel); |
394 unsigned char* decompressed = (unsigned char*)malloc(width * height * bytes_per_pixel); |
388 if(decompressed == NULL) |
395 if(decompressed == NULL) |
389 { |
396 { |
390 return NULL; |
397 return NULL; |
391 } |
398 } |
392 |
399 |
580 return 0; |
587 return 0; |
581 } |
588 } |
582 |
589 |
583 static void* dglDecompressPalettedTexture(int level, GLenum format, int width, int height, int imageSize, const void* data) |
590 static void* dglDecompressPalettedTexture(int level, GLenum format, int width, int height, int imageSize, const void* data) |
584 { |
591 { |
585 const unsigned char* palette = data; |
592 const unsigned char* palette = (const unsigned char*)data; |
586 int bits_per_pixel; |
593 int bits_per_pixel; |
587 int palette_entry_size; |
594 int palette_entry_size; |
588 int num_palette_entries; |
595 int num_palette_entries; |
589 const unsigned char* image_data; |
596 const unsigned char* image_data; |
590 int i; |
597 int i; |
664 { |
671 { |
665 DGLES2_ASSERT(base_format == GL_RGBA); |
672 DGLES2_ASSERT(base_format == GL_RGBA); |
666 bytes_per_pixel = 4; |
673 bytes_per_pixel = 4; |
667 } |
674 } |
668 |
675 |
669 decompressed_data = malloc(width * height * bytes_per_pixel); |
676 decompressed_data = (char*)malloc(width * height * bytes_per_pixel); |
670 if(decompressed_data == NULL) |
677 if(decompressed_data == NULL) |
671 { |
678 { |
672 return NULL; |
679 return NULL; |
673 } |
680 } |
674 |
681 |
878 if(imageSize != numblocks * 8) |
885 if(imageSize != numblocks * 8) |
879 { |
886 { |
880 DGLES2_ERROR(GL_INVALID_VALUE); |
887 DGLES2_ERROR(GL_INVALID_VALUE); |
881 } |
888 } |
882 |
889 |
883 decompressed_data = dglDecompressETCTexture(width, height, data); |
890 decompressed_data = dglDecompressETCTexture(width, height, (const unsigned char*)data); |
884 ctx->hgl.TexImage2D(target, level, GL_RGB, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, decompressed_data); |
891 ctx->hgl.TexImage2D(target, level, GL_RGB, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, decompressed_data); |
885 free(decompressed_data); |
892 free(decompressed_data); |
886 if(DGLContext_getHostError(ctx) == GL_NO_ERROR) |
893 if(DGLContext_getHostError(ctx) == GL_NO_ERROR) |
887 { |
894 { |
888 DGLTexture* texture; |
895 DGLTexture* texture; |
1133 |
1140 |
1134 default: |
1141 default: |
1135 DGLES2_ASSERT(GL_FALSE); |
1142 DGLES2_ASSERT(GL_FALSE); |
1136 } |
1143 } |
1137 |
1144 |
1138 conv = malloc(width * height * components * sizeof(GLfloat)); |
1145 conv = (GLfloat*)malloc(width * height * components * sizeof(GLfloat)); |
1139 if(conv == NULL) |
1146 if(conv == NULL) |
1140 { |
1147 { |
1141 return NULL; |
1148 return NULL; |
1142 } |
1149 } |
1143 |
1150 |