JOGL-010 Texture
Post

JOGL-010 Texture

GLSL을 이용한 텍스쳐 예제이다. 예제 소스 코드의 간결함을 위해 예외 처리 등의 구문은 추가하지 않았다.

1
2
3
4
5
6
7
8
9
10
11
import java.io.*;
import com.sun.opengl.util.texture.*;

private void loadTexture(){
    try{
        Texture myTexture=    TextureIO.newTexture(new File("brick1.dds"), false);
    }catch(Exception e){
        System.err.println(e);
        System.exit(0);
    }
}
1
2
3
4
void main(){
    gl_TexCoord[0]= gl_MultiTexCoord0;
    gl_Position= ftransform();
}
1
2
3
uniform sampler2D myTex; void main(){
    gl_FragColor= texture2D(myTex, vec2(gl_TexCoord[0]));
}

img

예제 다운로드