Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Java + OpenGL ES: Test for Transparency?

Java + OpenGL ES: Test for Transparency?

Scheduled Pinned Locked Moved Java
javagraphicsgame-devquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stephen Dycus
    wrote on last edited by
    #1

    ByteBuffer pixel = ByteBuffer.allocateDirect(1);
    byte transparentByte = 0;

    gl.glBindTexture(GL10.GL_TEXTURE_2D, _id);

    pixel.position(0);
    gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, x, y, 1, 1, GL10.GL_ALPHA, GL10.GL_UNSIGNED_BYTE, pixel); pixel.position(0);

    if(pixel.get() != transparentByte)
    {
    //DO STUFF
    }

    This never hits... It'll cycle through every pixel in the texture and never hit on a non-transparent pixel. What am I doing wrong? EDIT: It looks like whether or not I use GL_ALPHA or GL_RGBA, pixel.get() returns 0 for every pixel... it's not grabbing it from the texture or I'm not using ByteBuffer correctly... hmm...

    S 1 Reply Last reply
    0
    • S Stephen Dycus

      ByteBuffer pixel = ByteBuffer.allocateDirect(1);
      byte transparentByte = 0;

      gl.glBindTexture(GL10.GL_TEXTURE_2D, _id);

      pixel.position(0);
      gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, x, y, 1, 1, GL10.GL_ALPHA, GL10.GL_UNSIGNED_BYTE, pixel); pixel.position(0);

      if(pixel.get() != transparentByte)
      {
      //DO STUFF
      }

      This never hits... It'll cycle through every pixel in the texture and never hit on a non-transparent pixel. What am I doing wrong? EDIT: It looks like whether or not I use GL_ALPHA or GL_RGBA, pixel.get() returns 0 for every pixel... it's not grabbing it from the texture or I'm not using ByteBuffer correctly... hmm...

      S Offline
      S Offline
      Stephen Dycus
      wrote on last edited by
      #2

      Well... I fixed my problem by just not using OpenGL so the question still stands for anyone who comes across this thread.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups