Package org.newdawn.slick.opengl

Examples of org.newdawn.slick.opengl.TextureImpl


      int minFilter, int magFilter) throws IOException {
    int srcPixelFormat = 0;

    // create the texture ID for this texture
    int textureID = InternalTextureLoader.createTextureID();
    TextureImpl texture = new TextureImpl(resourceName, target, textureID);

    // Enable texturing
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    BufferedImage bufferedImage = resourceimage;
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
      srcPixelFormat = GL11.GL_RGBA;
    } else {
      srcPixelFormat = GL11.GL_RGB;
View Full Code Here


    for(int i = 0; i < (width*height*4); i++){
      buffer.put((byte) ((i%4 == 3)?255:128));
    }
    buffer.flip();
   
    R texImpl = (R)new TextureImpl("emptytexture", GL_TEXTURE_2D, 0);
    texImpl.setTextureData(GL_RGBA, 4, GL_LINEAR, GL_LINEAR, buffer);
    texImpl.setTextureFilter(GL_LINEAR);
    texImpl.setTextureWidth(width);
    texImpl.setTextureHeight(height);
    texImpl.reload();
View Full Code Here

      int minFilter, int magFilter) throws IOException {
    ImageIOImageData data = new ImageIOImageData();int srcPixelFormat = 0;

    // create the texture ID for this texture
    int textureID = InternalTextureLoader.createTextureID();
    TextureImpl texture = new TextureImpl(resourceName, target, textureID);

    // Enable texturing
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    BufferedImage bufferedImage = resourceimage;
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
      srcPixelFormat = GL11.GL_RGBA;
    } else {
      srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    ByteBuffer textureBuffer = data.imageToByteBuffer(bufferedImage, false, false, null);
    texture.setTextureHeight(data.getTexHeight());
    texture.setTextureWidth(data.getTexWidth());
    texture.setAlpha(data.getDepth() == 32);
   
    if (target == GL11.GL_TEXTURE_2D) {
      GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
      GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
     
          if (GLContext.getCapabilities().GL_EXT_texture_mirror_clamp) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, EXTTextureMirrorClamp.GL_MIRROR_CLAMP_TO_EDGE_EXT);
              GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, EXTTextureMirrorClamp.GL_MIRROR_CLAMP_TO_EDGE_EXT);
          } else {
              GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
              GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
          }
    }

        GL11.glTexImage2D(target,
                      0,
                      dstPixelFormat,
                      texture.getTextureWidth(),
                      texture.getTextureHeight(),
                      0,
                      srcPixelFormat,
                      GL11.GL_UNSIGNED_BYTE,
                      textureBuffer);
View Full Code Here

      int minFilter, int magFilter) throws IOException {
    ImageIOImageData data = new ImageIOImageData();int srcPixelFormat = 0;

    // create the texture ID for this texture
    int textureID = InternalTextureLoader.createTextureID();
    TextureImpl texture = new TextureImpl(resourceName, target, textureID);

    // Enable texturing
    Renderer.get().glEnable(SGL.GL_TEXTURE_2D);

    // bind this texture
    Renderer.get().glBindTexture(target, textureID);

    BufferedImage bufferedImage = resourceimage;
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
      srcPixelFormat = SGL.GL_RGBA;
    } else {
      srcPixelFormat = SGL.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    ByteBuffer textureBuffer = data.imageToByteBuffer(bufferedImage, false, false, null);
    texture.setTextureHeight(data.getTexHeight());
    texture.setTextureWidth(data.getTexWidth());
    texture.setAlpha(data.getDepth() == 32);
   
    if (target == SGL.GL_TEXTURE_2D) {
      Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MIN_FILTER, minFilter);
      Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MAG_FILTER, magFilter);
     
          if (Renderer.get().canTextureMirrorClamp()) {
            Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
            Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
          } else {
            Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP);
            Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP);
          }
    }

    Renderer.get().glTexImage2D(target,
                      0,
                      dstPixelFormat,
                      texture.getTextureWidth(),
                      texture.getTextureHeight(),
                      0,
                      srcPixelFormat,
                      SGL.GL_UNSIGNED_BYTE,
                      textureBuffer);
View Full Code Here

TOP

Related Classes of org.newdawn.slick.opengl.TextureImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.