본문 바로가기
Computer/JOGL

10. GLSL -- Texture

by DogBull 2007. 8. 3.
GLSL을 이용한 텍스쳐 예제이다.
늘 그랬던 것 처럼, 예제 소스 코드의 간결함을 위해 예외 처리 등의 구문은 추가하지 않았다.

사용자 삽입 이미지
< JOGL - Texture >

//VertexShader.vs
void main(){
    gl_TexCoord[0]= gl_MultiTexCoord0;
   
gl_Position= ftransform();
}


//FragmentShader.fs
uniform sampler2D myTex; void main(){
   
gl_FragColor= texture2D(myTex, vec2(gl_TexCoord[0]));
}

//# Render.java의 멤버함수 - 텍스쳐를 읽어들인다.
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); } }

'Computer > JOGL' 카테고리의 다른 글

11. Java Web Start  (0) 2007.08.06
glut  (0) 2007.08.06
9. GLSL -- 툰 셰이딩  (0) 2007.08.03
8. GLSL -- Animation  (0) 2007.08.03
7. GLSL -- vs & fs  (0) 2007.08.03