2014-01-30 5 views
0

Jogl의 텍스처에 문제가 있습니다. 책꽂이를 그리고 선반이 표시되면 감촉이 바뀌어야합니다.특정 조건에서 오브젝트의 텍스처 변경

Texture book; 

    if (Library.touchTime != 0 && Library.marked.equals(name)){ 
     long actTime = System.currentTimeMillis(); 
     if (actTime - Library.touchTime <= 2000){ 
      this.book = books_marked; 
     } 
     else{ 
      Library.touchTime = 0; 
      Library.marked = ""; 
      this.book = books; 
     } 
    } 
    book.enable(); 
    book.bind(); 

//---- front -------------------------------------------------- 
    gl.glBegin(GL.GL_QUADS); 
     normVector = front.getNorm(); 
     gl.glNormal3f(normVector.getX(), normVector.getY(), normVector.getZ()); 
     drawRect(gl, 0, 1, 2, 3); 
    gl.glEnd(); 

이 OBJECTS 책과 books_marked 생성자의 매개 변수는 다음과 같이 생성됩니다 : 여기 내 코드는 지금까지입니다

// ---- Load Book Texture ----------------------------------------------- 
    try { 
     InputStream stream = getClass().getResourceAsStream("books.jpg"); 
     data = TextureIO.newTextureData(stream, false, "jpg"); 
     books = TextureIO.newTexture(data); 
    } catch (IOException e) { 
     e.printStackTrace(); 
     System.exit(1); 
    } 

// ------------------------------------------------------------- 
// ---- Load Book_marked Texture ------------------------------------- 
    try { 
     InputStream stream = getClass().getResourceAsStream("books_marked.jpg"); 
     data = TextureIO.newTextureData(stream, false, "jpg"); 
     books_marked = TextureIO.newTexture(data); 
    } catch (IOException e) { 
     e.printStackTrace(); 
     System.exit(1); 
    } 

// -------------------------------------------------------------------------  

내 의도가 만약 내 책 텍스처 객체를 실체화하는 것이 었습니다 bind() 명령이 자동으로 올바른 그림을 바인드하도록합니다. 그러나 텍스처는 변하지 않습니다. 아무도 내가 뭘 잘못 생각 했니?

+0

'if '조건이 실제로 예상대로 작동하는지 확인 했습니까? – user1781290

+0

예, 했어요. 나는 그것이 잘 작동하도록 실행 시간을 보여주는 consol에 출력을했다. – Raistlin

+0

죄송하지만 JOGL 1은 더 이상 유지 관리되지 않습니다. 문제를 해결하기에 충분하지 않더라도 JOGL 2로 전환하십시오. – gouessej

답변

0

Texture.bind (GL) 또는 glBindTexture를 호출하십시오.