54 |
backup = null; |
backup = null; |
55 |
} |
} |
56 |
|
|
57 |
|
/** Check mipmap levels of a texture. |
58 |
|
* @return null, if everything is OK, an error string otherwise. |
59 |
|
*/ |
60 |
|
static public String checkMipmap(GL.Texture tex) { |
61 |
|
int base = (int)tex.getParameter("TEXTURE_BASE_LEVEL")[0]; |
62 |
|
int max = (int)tex.getParameter("TEXTURE_MAX_LEVEL")[0]; |
63 |
|
|
64 |
|
int w = (int)tex.getLevelParameter(base, "TEXTURE_WIDTH")[0]; |
65 |
|
int h = (int)tex.getLevelParameter(base, "TEXTURE_HEIGHT")[0]; |
66 |
|
int format = (int)tex.getLevelParameter(base, "TEXTURE_INTERNAL_FORMAT")[0]; |
67 |
|
|
68 |
|
if(w == 0 || h == 0) { |
69 |
|
return "Warning: texture base level size zero: "+w+" "+h; |
70 |
|
} |
71 |
|
|
72 |
|
for(int i=base+1; i<max; i++) { |
73 |
|
if(w == 1 && h == 1) break; |
74 |
|
w /= 2; if(w == 0) w = 1; |
75 |
|
h /= 2; if(h == 0) h = 1; |
76 |
|
|
77 |
|
int wc = (int)tex.getLevelParameter(i, "TEXTURE_WIDTH")[0]; |
78 |
|
int hc = (int)tex.getLevelParameter(i, "TEXTURE_HEIGHT")[0]; |
79 |
|
int formatc = (int)tex.getLevelParameter(i, "TEXTURE_INTERNAL_FORMAT")[0]; |
80 |
|
|
81 |
|
if(wc != w || hc != h) |
82 |
|
return "Texture level size wrong: "+base+" "+i+" "+w+" "+h+" "+wc+" "+hc; |
83 |
|
|
84 |
|
if(formatc != format) |
85 |
|
return "Texture level format wrong: "+base+" "+i+" "+format+" "+formatc; |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
} |
90 |
|
return null; |
91 |
|
} |
92 |
|
|
93 |
} |
} |