[GB.OPENGL]
* BUG: Correctly specify the number of color components when using an Image in an OpenGL function: glTexImage1D, glTexImage2D, gluBuild2DMipmaps... git-svn-id: svn://localhost/gambas/trunk@3958 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
e22b4f390b
commit
492779760f
@ -34,7 +34,7 @@ BEGIN_METHOD(GLUBUILD1DMIPMAPS, GB_OBJECT Image)
|
|||||||
if (IMAGE_get(ARG(Image), &image, &format))
|
if (IMAGE_get(ARG(Image), &image, &format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
status = gluBuild1DMipmaps(GL_TEXTURE_1D, 4, image->width, format, GL_UNSIGNED_BYTE, image->data);
|
status = gluBuild1DMipmaps(GL_TEXTURE_1D, IMAGE_get_ncolors(format), image->width, format, GL_UNSIGNED_BYTE, image->data);
|
||||||
|
|
||||||
GB.ReturnInteger(status);
|
GB.ReturnInteger(status);
|
||||||
|
|
||||||
@ -42,11 +42,13 @@ END_METHOD
|
|||||||
|
|
||||||
BEGIN_METHOD(GLUBUILD2DMIPMAPS, GB_OBJECT Image)
|
BEGIN_METHOD(GLUBUILD2DMIPMAPS, GB_OBJECT Image)
|
||||||
|
|
||||||
GB_IMG *image = VARG(Image);
|
GB_IMG *image;
|
||||||
int status = 0;
|
int status;
|
||||||
|
|
||||||
status = gluBuild2DMipmaps(GL_TEXTURE_2D, 4, image->width, image->height, IMAGE_get_pixel_format(image), GL_UNSIGNED_BYTE,
|
if (IMAGE_get(ARG(Image), &image, &format))
|
||||||
image->data);
|
return;
|
||||||
|
|
||||||
|
status = gluBuild2DMipmaps(GL_TEXTURE_2D, IMAGE_get_ncolors(format), image->width, image->height, format, GL_UNSIGNED_BYTE, image->data);
|
||||||
|
|
||||||
GB.ReturnInteger(status);
|
GB.ReturnInteger(status);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ BEGIN_METHOD(GLTEXIMAGE1D, GB_OBJECT Image; GB_INTEGER Level; GB_INTEGER Border)
|
|||||||
if (IMAGE_get(ARG(Image), &image, &format))
|
if (IMAGE_get(ARG(Image), &image, &format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glTexImage1D(GL_TEXTURE_1D, VARGOPT(Level, 0), 4, image->width, VARGOPT(Border, 0),
|
glTexImage1D(GL_TEXTURE_1D, VARGOPT(Level, 0), IMAGE_get_ncolors(format), image->width, VARGOPT(Border, 0),
|
||||||
format, GL_UNSIGNED_BYTE, image->data);
|
format, GL_UNSIGNED_BYTE, image->data);
|
||||||
|
|
||||||
END_METHOD
|
END_METHOD
|
||||||
@ -235,7 +235,7 @@ BEGIN_METHOD(GLTEXIMAGE2D, GB_OBJECT Image; GB_INTEGER Level; GB_INTEGER Border)
|
|||||||
if (IMAGE_get(ARG(Image), &image, &format))
|
if (IMAGE_get(ARG(Image), &image, &format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, VARGOPT(Level, 0), 3, image->width, image->height,
|
glTexImage2D(GL_TEXTURE_2D, VARGOPT(Level, 0), IMAGE_get_ncolors(format), image->width, image->height,
|
||||||
VARGOPT(Border, 0), format, GL_UNSIGNED_BYTE, image->data);
|
VARGOPT(Border, 0), format, GL_UNSIGNED_BYTE, image->data);
|
||||||
|
|
||||||
END_METHOD
|
END_METHOD
|
||||||
|
@ -40,5 +40,8 @@ extern IMAGE_INTERFACE IMAGE;
|
|||||||
int IMAGE_get_pixel_format(GB_IMG *image);
|
int IMAGE_get_pixel_format(GB_IMG *image);
|
||||||
bool IMAGE_get(GB_OBJECT *arg, GB_IMG **img, int *format);
|
bool IMAGE_get(GB_OBJECT *arg, GB_IMG **img, int *format);
|
||||||
|
|
||||||
|
#define IMAGE_get_ncolors(_format) (GB_IMAGE_FMT_IS_24_BITS(_format) ? 3 : 4)
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user