GlGenTextures
glGenTextures — generate texture names.
C Specification
Parameters:
- n: Specifies the number of texture names to be generated.
- textures: Specifies an array in which the generated texture names are stored.
Description
glGenTextures returns n texture names in textures. There is no guarantee that the names form a contiguous set of integers; however, it is guaranteed that none of the returned names was in use immediately before the call to glGenTextures. The generated textures have no dimensionality; they assume the dimensionality of the texture target to which they are first bound (see glBindTexture). Texture names returned by a call to glGenTextures are not returned by subsequent calls, unless they are first deleted with glDeleteTextures.
Example
텍스처를 생성한다.
GLAPI void GLAPIENTRY glGenTextures (
GLsizei n, // 생성할 텍스쳐 갯수.
GLuint *textures // 텍스처에 접근할 인덱스를 받을 변수의 주소값.
);
// ...
// 텍스처를 3개 만들겠다.
GLuint tex[3];
glGenTextures( 3, tex );
// ...
// 1개를 만들겠다.
GLuing tex;
glGenTextures( 1, &tex );
버퍼 개체, 고속 텍스처 로딩
opengl 의 개체 버퍼를 통하여 텍스쳐를 로드시키는 방법. 당연히 빠른 로딩을 하려면 반드시 적용해야 될 부분입니다.
아래와 같은 단계로써 텍스쳐를 비디오 메모리로 올려 보내게 되는데요
스토리지 -버퍼를 통한 로드-> 비디오 메모리 스토리지는 데이터를 불러오는 저장공간 입니다, 웹 혹은 하드디스크 그외, 여러가지로요
함수를 참고하여 하나씩 설명 하겠습니다. openGL 초기화 개체는 생략 했어요, ( 플랫폼 마다 달라서요... glu,glx 기타등등 프레임워크를 사용하면 훨씬 편합니다 )
버퍼/텍스쳐 생성
C++
Pascal
var buffer,texture: array [0..1] of GLenum; glGenBuffers(2, @buffer[0]);
glGenTextures(2, @texture[0]);
GL 버퍼 개체를 픽셀버퍼로 선택, 생성(192010803 : RGB채널 1080p), (STATIC: 한번 편집 여러번 사용, DYNAMIC: 여러번 편집 여러번 사용)
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer[0]);
glBufferData(GL_PIXEL_UNPACK_BUFFER,1920*1080*3, nil, GL_STATIC_DRAW);
비디오 메모리를 시스템 가상 메모리에 매핑 받습니다
// 메모리포인터 := glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
FillMemory(메모리포인터,1920*1080*2,127);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
버퍼의 자료를 텍스쳐로 가져옵니다. 텍스쳐를 GL_TEXTURE_2D 로 선택, 텍스쳐 파래미터 지정, 버퍼로부터 데이터를 붙임
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, 1920, 1080, 0, GL_RGB, GL_UNSIGNED_BYTE, nil);
PBO (Pixel Buffer Object)라고도 불리는데 이 것이 다 네요. 버텍스 버퍼, 텍스쳐 버퍼 도 있습니다. 참고 함수: glGetBufferSubData, glGetTexImage ( 버퍼,텍스쳐 데이터를 뽑아오는 함수 입니다, 다른 함수는 구글 검색 : "gl함수명 wiki" )
See also
- OpenGL
- glDeleteTexture - delete named textures.
- glTexSubImage2D - specify a two-dimensional texture subimage.
- glTexParameteri - OpenGL BMP texture 로딩.