diff --git a/gb.opengl/src/GL.c b/gb.opengl/src/GL.c index 5672206b4..251aa9c79 100644 --- a/gb.opengl/src/GL.c +++ b/gb.opengl/src/GL.c @@ -281,6 +281,8 @@ GB_DESC Cgl[] = GB_STATIC_METHOD("TexEnviv", NULL, GLTEXENVIV, "(Target)i(Pname)i(Params)Integer[]"), GB_STATIC_METHOD("TexImage1D", NULL, GLTEXIMAGE1D, "(Image)Image;[(Level)i(Border)i]"), GB_STATIC_METHOD("TexImage2D", NULL, GLTEXIMAGE2D,"(Image)Image;[(Level)i(Border)i]"), + GB_STATIC_METHOD("TexSubImage1D", NULL, GLTEXSUBIMAGE2D,"(Image)Image;(XOffset)i(Width)i[(Level)i]"), + GB_STATIC_METHOD("TexSubImage2D", NULL, GLTEXSUBIMAGE2D,"(Image)Image;(XOffset)i(YOffset)i(Width)i(Height)i[(Level)i]"), GB_STATIC_METHOD("TexParameterf", NULL, GLTEXPARAMETERF, "(Target)i(Pname)i(Param)f"), GB_STATIC_METHOD("TexParameterfv", NULL, GLTEXPARAMETERFV, "(Target)i(Pname)i(Params)Float[]"), GB_STATIC_METHOD("TexParameteri", NULL, GLTEXPARAMETERI, "(Target)i(Pname)i(Param)i"), diff --git a/gb.opengl/src/GLtextureMapping.c b/gb.opengl/src/GLtextureMapping.c index c76073c48..e548c77c1 100644 --- a/gb.opengl/src/GLtextureMapping.c +++ b/gb.opengl/src/GLtextureMapping.c @@ -242,7 +242,7 @@ BEGIN_METHOD(GLTEXIMAGE2D, GB_OBJECT Image; GB_INTEGER Level; GB_INTEGER Border) GB_IMG *image; int format; - + if (IMAGE_get(ARG(Image), &image, &format)) return; @@ -251,6 +251,32 @@ BEGIN_METHOD(GLTEXIMAGE2D, GB_OBJECT Image; GB_INTEGER Level; GB_INTEGER Border) END_METHOD +BEGIN_METHOD(GLTEXSUBIMAGE1D, GB_OBJECT Image; GB_INTEGER XOffset; GB_INTEGER Width; GB_INTEGER Level) + + GB_IMG *image; + int format; + + if (IMAGE_get(ARG(Image), &image, &format)) + return; + + glTexSubImage1D(GL_TEXTURE_1D, VARGOPT(Level, 0), VARG(XOffset), VARG(Width), + format, GL_UNSIGNED_BYTE, image->data); + +END_METHOD + +BEGIN_METHOD(GLTEXSUBIMAGE2D, GB_OBJECT Image; GB_INTEGER XOffset; GB_INTEGER YOffset; GB_INTEGER Width; GB_INTEGER Height; GB_INTEGER Level) + + GB_IMG *image; + int format; + + if (IMAGE_get(ARG(Image), &image, &format)) + return; + + glTexSubImage2D(GL_TEXTURE_2D, VARGOPT(Level, 0), VARG(XOffset), VARG(YOffset), VARG(Width), VARG(Height), + format, GL_UNSIGNED_BYTE, image->data); + +END_METHOD + BEGIN_METHOD(GLTEXPARAMETERF, GB_INTEGER Target; GB_INTEGER Pname; GB_FLOAT Param) glTexParameterf(VARG(Target), VARG(Pname), VARG(Param)); diff --git a/gb.opengl/src/GLtextureMapping.h b/gb.opengl/src/GLtextureMapping.h index aa874f9cf..c31630077 100644 --- a/gb.opengl/src/GLtextureMapping.h +++ b/gb.opengl/src/GLtextureMapping.h @@ -47,6 +47,8 @@ DECLARE_METHOD(GLTEXENVI); DECLARE_METHOD(GLTEXENVIV); DECLARE_METHOD(GLTEXIMAGE1D); DECLARE_METHOD(GLTEXIMAGE2D); +DECLARE_METHOD(GLTEXSUBIMAGE1D); +DECLARE_METHOD(GLTEXSUBIMAGE2D); DECLARE_METHOD(GLTEXPARAMETERF); DECLARE_METHOD(GLTEXPARAMETERFV); DECLARE_METHOD(GLTEXPARAMETERI);