2017-01-21 6 views
-2

백그라운드없이 스프라이트를 렌더링하는 방법은 무엇입니까? 전체 스프라이트를 렌더링 할 수 있지만 배경을 무시하고 싶습니다. 나는 경골에서 그런 종류의 렌더링을 보았 기 때문에 할 수 있음을 안다. 경골의 Sprite는 분홍색 배경으로 무시됩니다.
스프라이트 :LWJGL, Slick Util, 백그라운드없는 2 차원 렌더링 스프라이트

public class Sprite { 

private Texture texture; 


private float sx; 
private float sy; 
private String extension; 
private String path; 


/** 
* 
* @param sx 
* @param sy 
* @param extension 
* @param path 
*/ 
public Sprite(float sx, float sy, String extension, String path) { 

    this.sx = sx; 
    this.sy = sy; 
    this.extension = extension; 
    this.path = path; 
} 


public void render() { 

    try { 
     initTexture(); 

    } catch (Exception e) { 
     System.out.println(e.toString()); 
    } 
    Color.white.bind(); 
    texture.bind(); 
    glBegin(GL_QUADS); 


    glTexCoord2f(0, 0); 
    glVertex2f(0, 0); 
    glTexCoord2f(0, 1); 
    glVertex2f(0, texture.getTextureHeight()*2); 
    glTexCoord2f(1, 1); 
    glVertex2f(texture.getTextureWidth()*2, texture.getTextureHeight()*2); 
    glTexCoord2f(1, 0); 
    glVertex2f(texture.getTextureWidth()*2, 0); 


    glEnd(); 


} 

public float getSx() { 
    return sx; 
} 

public void setSx(float sx) { 
    this.sx = sx; 
} 

public float getSy() { 
    return sy; 
} 

public void setSy(float sy) { 
    this.sy = sy; 
} 

public void initTexture() throws Exception { 

    texture = TextureLoader.getTexture(extension, ResourceLoader.getResourceAsStream(path)); 


} 

}

답변

0

난 당신이 타일 세트 보라색 그리드를 가지고 게임을 위해를 사용하려고 같은데요.

핑크색을 투명 필름으로 교체하는 것이 좋습니다. 다음, 당신의 프로그램에서 바로 수행

glEnable(GL_BLEND); 
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 

보라색 타일 세트는/SpriteSheets 오래된 게임에서 사용되었다. 실제 필요는 없습니다.