/[gzz]/gzz/gfx/jni/GzzGL-jni.cxx
ViewVC logotype

Diff of /gzz/gfx/jni/GzzGL-jni.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.62 by humppake, Wed Nov 13 11:21:53 2002 UTC revision 1.63 by jvk, Wed Nov 13 22:48:56 2002 UTC
# Line 10  Line 10 
10  #include "libtext/Text.hxx"  #include "libtext/Text.hxx"
11  #include "libutil/Vec23.hxx"  #include "libutil/Vec23.hxx"
12  #include "libutil/Debug.hxx"  #include "libutil/Debug.hxx"
13    #include "libutil/buildmipmaps.hxx"
14    
15  #include "libos/Os.hxx"  #include "libos/Os.hxx"
16    
# Line 585  GLenum tokenFromJstring(JNIEnv *env, jst Line 586  GLenum tokenFromJstring(JNIEnv *env, jst
586      return ret;      return ret;
587  }  }
588    
589    bool hasGenMipmaps() {
590        static int initialized;
591        static bool hasExtension;
592        // XXX: the test should probably be done elsewhere
593        if (!initialized) {
594            hasExtension = strstr((const char *)glGetString(GL_EXTENSIONS),
595                                  "GL_SGIS_generate_mipmap") != 0;
596            initialized = true;
597        }
598        return hasExtension;
599    }
600    
601  JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1loadNull2D  JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1loadNull2D
602    (JNIEnv *env, jclass, jint id, jint level, jstring internalFormat_s,    (JNIEnv *env, jclass, jint id, jint level, jstring internalFormat_s,
603      jint w, jint h, jint border, jstring format_s, jstring type_s) {      jint w, jint h, jint border, jstring format_s, jstring type_s) {
# Line 693  JNIEXPORT jint JNICALL Java_gzz_gfx_gl_G Line 706  JNIEXPORT jint JNICALL Java_gzz_gfx_gl_G
706    
707        glBindTexture(target, id);        glBindTexture(target, id);
708    
709          int buildmipmaps = 0;
710    
711        if (!shade_all_levels) {        if (!shade_all_levels) {
712            glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);            if (hasGenMipmaps()) {
713            GLERR;                glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
714                  GLERR;
715              } else {
716                  buildmipmaps = 1;
717              }
718        }        }
719                    
720        int level;        int level;
721        for (level = 0; ; level++) {        for (level = 0; ; level++) {
722            s->render(&p, w, h, (d==0?1:d), comp, value);            s->render(&p, w, h, (d==0?1:d), comp, value);
723    
724              if (buildmipmaps) {
725                  assert(d==0); // 3D buildmipmaps not implemented in libutil
726                  Util::buildmipmaps(GL_TEXTURE_2D,
727                                     tokenFromJstring(env, internalFormat),
728                                     w, h,
729                                     tokenFromJstring(env, format),
730                                     GL_FLOAT,
731                                     value);
732              } else
733            if (d == 0)            if (d == 0)
734                glTexImage2D(GL_TEXTURE_2D, level,                glTexImage2D(GL_TEXTURE_2D, level,
735                             tokenFromJstring(env, internalFormat),                             tokenFromJstring(env, internalFormat),

Legend:
Removed from v.1.62  
changed lines
  Added in v.1.63

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26