@@ -162,6 +162,7 @@ public abstract class PGL {
162162 protected static int tex2DShaderContext ;
163163 protected static int tex2DVertLoc ;
164164 protected static int tex2DTCoordLoc ;
165+ protected static int tex2DSamplerLoc ;
165166
166167 protected static boolean loadedTexRectShader = false ;
167168 protected static int texRectShaderProgram ;
@@ -170,6 +171,7 @@ public abstract class PGL {
170171 protected static int texRectShaderContext ;
171172 protected static int texRectVertLoc ;
172173 protected static int texRectTCoordLoc ;
174+ protected static int texRectSamplerLoc ;
173175
174176 protected static float [] texCoords = {
175177 // X, Y, U, V
@@ -209,15 +211,17 @@ public abstract class PGL {
209211 "uniform sampler2D textureSampler;\n " +
210212 "varying vec2 vertTexcoord;\n " +
211213 "void main() {\n " +
212- " gl_FragColor = texture2D(textureSampler, vertTexcoord.st);\n " +
214+ " gl_FragColor = texture2D(textureSampler, vertTexcoord.st);\n " +
215+ // " gl_FragColor = vec4(vertTexcoord.st, 0, 1);\n" +
213216 "}\n " ,
214217 "#version 150\n " +
215218 SHADER_PREPROCESSOR_DIRECTIVE +
216219 "uniform sampler2D textureSampler;\n " +
217220 "in vec2 vertTexcoord;\n " +
218221 "out vec4 fragColor;\n " +
219222 "void main() {\n " +
220- " fragColor = texture(textureSampler, vertTexcoord.st);\n " +
223+ // " fragColor = texture(textureSampler, vertTexcoord.st);\n" +
224+ " fragColor = vec4(vertTexcoord.st, 0, 1);\n " +
221225 "}\n "
222226 };
223227
@@ -930,6 +934,7 @@ protected void drawTexture2D(int id, int texW, int texH, int scrW, int scrH,
930934 if (0 < tex2DShaderProgram ) {
931935 tex2DVertLoc = getAttribLocation (tex2DShaderProgram , "inVertex" );
932936 tex2DTCoordLoc = getAttribLocation (tex2DShaderProgram , "inTexcoord" );
937+ tex2DSamplerLoc = getUniformLocation (tex2DShaderProgram , "textureSampler" );
933938 }
934939 loadedTex2DShader = true ;
935940 tex2DShaderContext = glContext ;
@@ -999,16 +1004,15 @@ protected void drawTexture2D(int id, int texW, int texH, int scrW, int scrH,
9991004 enabledTex = true ;
10001005 }
10011006 bindTexture (TEXTURE_2D , id );
1007+ uniform1i (tex2DSamplerLoc , 0 );
10021008
10031009 texData .position (0 );
10041010 bindBuffer (PGL .ARRAY_BUFFER , texGeoVBO );
10051011 bufferData (PGL .ARRAY_BUFFER , 16 * SIZEOF_FLOAT , texData , PGL .STATIC_DRAW );
10061012
1007- pg .report ("HERE 1" );
10081013 vertexAttribPointer (tex2DVertLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 0 );
10091014 vertexAttribPointer (tex2DTCoordLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 2 * SIZEOF_FLOAT );
10101015
1011-
10121016// texData.position(0);
10131017// vertexAttribPointer(tex2DVertLoc, 2, FLOAT, false, 4 * SIZEOF_FLOAT,
10141018// texData);
@@ -1018,7 +1022,6 @@ protected void drawTexture2D(int id, int texW, int texH, int scrW, int scrH,
10181022// pg.report("HERE 2");
10191023
10201024 drawArrays (TRIANGLE_STRIP , 0 , 4 );
1021- pg .report ("HERE 3" );
10221025
10231026 bindBuffer (ARRAY_BUFFER , 0 ); // Making sure that no VBO is bound at this point.
10241027
@@ -1058,6 +1061,7 @@ protected void drawTextureRect(int id, int texW, int texH, int scrW, int scrH,
10581061 if (0 < texRectShaderProgram ) {
10591062 texRectVertLoc = getAttribLocation (texRectShaderProgram , "inVertex" );
10601063 texRectTCoordLoc = getAttribLocation (texRectShaderProgram , "inTexcoord" );
1064+ texRectSamplerLoc = getUniformLocation (texRectShaderProgram , "textureSampler" );
10611065 }
10621066 loadedTexRectShader = true ;
10631067 texRectShaderContext = glContext ;
@@ -1127,12 +1131,13 @@ protected void drawTextureRect(int id, int texW, int texH, int scrW, int scrH,
11271131 enabledTex = true ;
11281132 }
11291133 bindTexture (TEXTURE_RECTANGLE , id );
1134+ uniform1i (texRectSamplerLoc , 0 );
11301135
11311136 texData .position (0 );
11321137 bindBuffer (PGL .ARRAY_BUFFER , texGeoVBO );
11331138 bufferData (PGL .ARRAY_BUFFER , 16 * SIZEOF_FLOAT , texData , PGL .STATIC_DRAW );
11341139
1135- pg .report ("HERE 1" );
1140+ // pg.report("HERE 1");
11361141 vertexAttribPointer (texRectVertLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 0 );
11371142 vertexAttribPointer (texRectTCoordLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 2 * SIZEOF_FLOAT );
11381143
@@ -1634,6 +1639,61 @@ protected boolean hasShaders() {
16341639 }
16351640
16361641
1642+ protected boolean hasNpotTexSupport () {
1643+ int major = getGLVersion ()[0 ];
1644+ if (major < 3 ) {
1645+ String ext = getString (EXTENSIONS );
1646+ return -1 < ext .indexOf ("_texture_non_power_of_two" );
1647+ } else {
1648+ return true ;
1649+ }
1650+ }
1651+
1652+
1653+ protected boolean hasAutoMipmapGenSupport () {
1654+ int major = getGLVersion ()[0 ];
1655+ if (major < 3 ) {
1656+ String ext = getString (EXTENSIONS );
1657+ return -1 < ext .indexOf ("_generate_mipmap" );
1658+ } else {
1659+ return true ;
1660+ }
1661+ }
1662+
1663+
1664+ protected boolean hasFboMultisampleSupport () {
1665+ int major = getGLVersion ()[0 ];
1666+ if (major < 3 ) {
1667+ String ext = getString (EXTENSIONS );
1668+ return -1 < ext .indexOf ("_framebuffer_multisample" );
1669+ } else {
1670+ return true ;
1671+ }
1672+ }
1673+
1674+
1675+ protected boolean hasPackedDepthStencilSupport () {
1676+ int major = getGLVersion ()[0 ];
1677+ if (major < 3 ) {
1678+ String ext = getString (EXTENSIONS );
1679+ return -1 < ext .indexOf ("_packed_depth_stencil" );
1680+ } else {
1681+ return true ;
1682+ }
1683+ }
1684+
1685+
1686+ protected boolean hasAnisoSamplingSupport () {
1687+ int major = getGLVersion ()[0 ];
1688+ if (major < 3 ) {
1689+ String ext = getString (EXTENSIONS );
1690+ return -1 < ext .indexOf ("_texture_filter_anisotropic" );
1691+ } else {
1692+ return true ;
1693+ }
1694+ }
1695+
1696+
16371697 protected int maxSamples () {
16381698 intBuffer .rewind ();
16391699 getIntegerv (MAX_SAMPLES , intBuffer );
@@ -2140,6 +2200,9 @@ protected interface FontOutline {
21402200 public static int RGBA4 ;
21412201 public static int RGB5_A1 ;
21422202 public static int RGB565 ;
2203+ public static int RGB8 ;
2204+ public static int RGBA8 ;
2205+ public static int ALPHA8 ;
21432206
21442207 public static int READ_ONLY ;
21452208 public static int WRITE_ONLY ;
@@ -2354,7 +2417,6 @@ protected interface FontOutline {
23542417 public static int READ_FRAMEBUFFER ;
23552418 public static int DRAW_FRAMEBUFFER ;
23562419
2357- public static int RGBA8 ;
23582420 public static int DEPTH24_STENCIL8 ;
23592421
23602422 public static int DEPTH_COMPONENT ;
0 commit comments