本文整理汇总了C++中qglBindTexture函数的典型用法代码示例。如果您正苦于以下问题:C++ qglBindTexture函数的具体用法?C++ qglBindTexture怎么用?C++ qglBindTexture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qglBindTexture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GL_Bind
/*
** GL_Bind
*/
void GL_Bind( image_t *image ) {
int texnum;
if ( !image ) {
ri.Printf( PRINT_WARNING, "GL_Bind: NULL image\n" );
texnum = tr.defaultImage->texnum;
} else {
texnum = image->texnum;
}
if ( r_nobind->integer && tr.dlightImage ) { // performance evaluation option
texnum = tr.dlightImage->texnum;
}
if ( glState.currenttextures[glState.currenttmu] != texnum ) {
if ( image ) {
image->frameUsed = tr.frameCount;
}
glState.currenttextures[glState.currenttmu] = texnum;
if (image && image->flags & IMGFLAG_CUBEMAP)
qglBindTexture( GL_TEXTURE_CUBE_MAP, texnum );
else
qglBindTexture( GL_TEXTURE_2D, texnum );
}
}
示例2: Gui_SetScreenTexture
bool Gui_SetScreenTexture(void *data, int w, int h, int bpp)
{
GLenum texture_format;
GLuint color_depth;
if(bpp == 32) // Contains an alpha channel
{
texture_format = GL_RGBA;
color_depth = GL_RGBA;
}
else if(bpp == 24) // No alpha channel
{
texture_format = GL_RGB;
color_depth = GL_RGB;
}
else
{
return false;
}
// Bind the texture object
qglBindTexture(GL_TEXTURE_2D, load_screen_tex);
// Set the texture's stretching properties
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Edit the texture object's image data using the information SDL_Surface gives us
qglTexImage2D(GL_TEXTURE_2D, 0, color_depth, w, h, 0,
texture_format, GL_UNSIGNED_BYTE, data);
qglBindTexture(GL_TEXTURE_2D, 0);
return true;
}
示例3: GL_BindMultitexture
/*
** GL_BindMultitexture
*/
void
GL_BindMultitexture(Img *image0, GLuint env0, Img *image1, GLuint env1)
{
int texnum0, texnum1;
texnum0 = image0->texnum;
texnum1 = image1->texnum;
if(r_nobind->integer && tr.dlightImage){ /* performance evaluation option */
texnum0 = texnum1 = tr.dlightImage->texnum;
}
if(glState.currenttextures[1] != texnum1){
GL_SelectTexture(1);
image1->frameUsed = tr.frameCount;
glState.currenttextures[1] = texnum1;
qglBindTexture(GL_TEXTURE_2D, texnum1);
}
if(glState.currenttextures[0] != texnum0){
GL_SelectTexture(0);
image0->frameUsed = tr.frameCount;
glState.currenttextures[0] = texnum0;
qglBindTexture(GL_TEXTURE_2D, texnum0);
}
}
示例4: RB_BloomDownSample
static void RB_BloomDownSample( void ) {
GLenum target;
int width, height;
GLint loc;
GL_SelectTexture(0);
qglDisable(GL_TEXTURE_2D);
qglEnable(GL_TEXTURE_RECTANGLE_ARB);
target = GL_TEXTURE_RECTANGLE_ARB;
width = glConfig.vidWidth;
height = glConfig.vidHeight;
qglBindTexture(target, tr.backBufferTexture);
qglCopyTexSubImage2D(target, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
GL_SelectTexture(1);
qglDisable(GL_TEXTURE_2D);
qglEnable(GL_TEXTURE_RECTANGLE_ARB);
qglBindTexture(target, tr.bloomTexture);
qglUseProgramObjectARB(tr.downSample1Sp);
loc = qglGetUniformLocationARB(tr.downSample1Sp, "backBufferTex");
if (loc < 0) {
Com_Error(ERR_DROP, "%s() couldn't get backBufferTex", __FUNCTION__);
}
qglUniform1iARB(loc, 0);
//qglDisable(GL_BLEND);
qglBegin(GL_QUADS);
qglMultiTexCoord2iARB(GL_TEXTURE0_ARB, 0, 0);
qglMultiTexCoord2iARB(GL_TEXTURE1_ARB, 0, 0);
qglVertex2i(0, tr.bloomHeight);
qglMultiTexCoord2iARB(GL_TEXTURE0_ARB, width, 0);
qglMultiTexCoord2iARB(GL_TEXTURE1_ARB, width, 0);
qglVertex2i(tr.bloomWidth, tr.bloomHeight);
qglMultiTexCoord2iARB(GL_TEXTURE0_ARB, width, height);
qglMultiTexCoord2iARB(GL_TEXTURE1_ARB, width, height);
qglVertex2i(tr.bloomWidth, 0);
qglMultiTexCoord2iARB(GL_TEXTURE0_ARB, 0, height);
qglMultiTexCoord2iARB(GL_TEXTURE1_ARB, 0, height);
qglVertex2i(0, 0);
qglEnd();
qglUseProgramObjectARB(0);
qglDisable(GL_TEXTURE_RECTANGLE_ARB);
qglDisable(GL_TEXTURE_2D);
GL_SelectTexture(0);
qglDisable(GL_TEXTURE_RECTANGLE_ARB);
qglEnable(GL_TEXTURE_2D);
}
示例5: gld_BindFlat
void gld_BindFlat(GLTexture *gltexture, unsigned int flags)
{
const unsigned char *flat;
unsigned char *buffer;
int w, h;
if (!gltexture || gltexture->textype != GLDT_FLAT)
{
qglBindTexture(GL_TEXTURE_2D, 0);
last_glTexID = NULL;
return;
}
#ifdef HAVE_LIBSDL_IMAGE
if (gld_LoadHiresTex(gltexture, CR_DEFAULT))
{
gld_SetTexClamp(gltexture, flags);
last_glTexID = gltexture->texid_p;
return;
}
#endif
gld_GetTextureTexID(gltexture, CR_DEFAULT);
if (last_glTexID == gltexture->texid_p)
{
gld_SetTexClamp(gltexture, flags);
return;
}
last_glTexID = gltexture->texid_p;
if (*gltexture->texid_p != 0)
{
qglBindTexture(GL_TEXTURE_2D, *gltexture->texid_p);
gld_SetTexClamp(gltexture, flags);
return;
}
flat=W_CacheLumpNum(gltexture->index);
buffer=(unsigned char*)Z_Malloc(gltexture->buffer_size,PU_STATIC,0);
if (!(gltexture->flags & GLTEXTURE_MIPMAP) && gl_paletted_texture)
memset(buffer,transparent_pal_index,gltexture->buffer_size);
else
memset(buffer,0,gltexture->buffer_size);
gld_AddFlatToTexture(gltexture, buffer, flat, !(gltexture->flags & GLTEXTURE_MIPMAP) && gl_paletted_texture);
if (*gltexture->texid_p == 0)
qglGenTextures(1, gltexture->texid_p);
qglBindTexture(GL_TEXTURE_2D, *gltexture->texid_p);
buffer = gld_HQResize(gltexture, buffer, gltexture->buffer_width, gltexture->buffer_height, &w, &h);
gld_BuildTexture(gltexture, buffer, false, w, h);
gld_SetTexClamp(gltexture, flags);
W_UnlockLumpNum(gltexture->index);
}
示例6: gld_wipe_doMelt
int gld_wipe_doMelt(int ticks, int *y_lookup)
{
int i;
int total_w, total_h;
float fU1, fU2, fV1, fV2;
total_w = gld_GetTexDimension(SCREENWIDTH);
total_h = gld_GetTexDimension(SCREENHEIGHT);
fU1 = 0.0f;
fV1 = (float)SCREENHEIGHT / (float)total_h;
fU2 = (float)SCREENWIDTH / (float)total_w;
fV2 = 0.0f;
gld_EnableTexture2D(GL_TEXTURE0_ARB, true);
qglBindTexture(GL_TEXTURE_2D, wipe_scr_end_tex);
qglColor3f(1.0f, 1.0f, 1.0f);
qglBegin(GL_TRIANGLE_STRIP);
{
qglTexCoord2f(fU1, fV1); qglVertex2f(0.0f, 0.0f);
qglTexCoord2f(fU1, fV2); qglVertex2f(0.0f, (float)SCREENHEIGHT);
qglTexCoord2f(fU2, fV1); qglVertex2f((float)SCREENWIDTH, 0.0f);
qglTexCoord2f(fU2, fV2); qglVertex2f((float)SCREENWIDTH, (float)SCREENHEIGHT);
}
qglEnd();
qglBindTexture(GL_TEXTURE_2D, wipe_scr_start_tex);
qglColor3f(1.0f, 1.0f, 1.0f);
qglBegin(GL_QUAD_STRIP);
for (i=0; i <= SCREENWIDTH; i++)
{
int yoffs = MAX(0, y_lookup[i]);
float tx = (float) i / total_w;
float sx = (float) i;
float sy = (float) yoffs;
qglTexCoord2f(tx, fV1); qglVertex2f(sx, sy);
qglTexCoord2f(tx, fV2); qglVertex2f(sx, sy + (float)SCREENHEIGHT);
}
qglEnd();
return 0;
}
示例7: CreateDSTTex_ARB
/*
===============
CreateDSTTex_ARB
Create the texture which warps texture shaders
===============
*/
void CreateDSTTex_ARB (void)
{
unsigned char dist[DST_SIZE][DST_SIZE][4];
int x,y;
srand(GetTickCount());
for (x=0; x<DST_SIZE; x++)
for (y=0; y<DST_SIZE; y++) {
dist[x][y][0] = rand()%255;
dist[x][y][1] = rand()%255;
dist[x][y][2] = rand()%48;
dist[x][y][3] = rand()%48;
}
qglGenTextures(1,&dst_texture_ARB);
qglBindTexture(GL_TEXTURE_2D, dst_texture_ARB);
qglTexImage2D (GL_TEXTURE_2D, 0, 4, DST_SIZE, DST_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, dist);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
qglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
}
示例8: R_BindAnimatedImage
/*
=================
R_BindAnimatedImage
=================
*/
static void R_BindAnimatedImage( textureBundle_t *bundle ) {
int index;
if ( bundle->isVideoMap ) {
ri.CIN_RunCinematic(bundle->videoMapHandle);
ri.CIN_UploadCinematic(bundle->videoMapHandle);
return;
}
if ( bundle->isRenderTarget ) {
qglBindTexture (GL_TEXTURE_2D, bundle->renderTarget);
return;
}
if ( bundle->numImageAnimations <= 1 ) {
GL_Bind( bundle->image[0] );
return;
}
// it is necessary to do this messy calc to make sure animations line up
// exactly with waveforms of the same frequency
index = myftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE );
index >>= FUNCTABLE_SIZE2;
if ( index < 0 ) {
index = 0; // may happen with shader time offsets
}
index %= bundle->numImageAnimations;
GL_Bind( bundle->image[ index ] );
}
示例9: Terrain_DrawFace
void Terrain_DrawFace( brush_t *brush, terrainFace_t *terraface ) {
terrainMesh_t *pm;
terravert_t a0;
terravert_t a1;
terravert_t a2;
pm = brush->pTerrain;
Terrain_GetTriangle( pm, terraface->index, &a0, &a1, &a2 );
qglBindTexture( GL_TEXTURE_2D, terraface->texture->texture_number );
qglBegin( GL_TRIANGLES );
// first tri
qglColor4fv( a0.rgba );
qglTexCoord2fv( a0.tc );
qglVertex3fv( a0.xyz );
qglColor4fv( a1.rgba );
qglTexCoord2fv( a1.tc );
qglVertex3fv( a1.xyz );
qglColor4fv( a2.rgba );
qglTexCoord2fv( a2.tc );
qglVertex3fv( a2.xyz );
qglEnd ();
}
示例10: CaptureScreenAsTexID
GLuint CaptureScreenAsTexID(void)
{
GLuint id;
gld_EnableTexture2D(GL_TEXTURE0_ARB, true);
qglGenTextures(1, &id);
qglBindTexture(GL_TEXTURE_2D, id);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#ifdef ANDROID
qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
#else
qglTexImage2D(GL_TEXTURE_2D, 0, 3,
#endif
gld_GetTexDimension(SCREENWIDTH), gld_GetTexDimension(SCREENHEIGHT),
0, GL_RGB, GL_UNSIGNED_BYTE, 0);
qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, SCREENWIDTH, SCREENHEIGHT);
return id;
}
示例11: RB_BindImage
/*
* RB_BindImage
*/
void RB_BindImage( int tmu, const image_t *tex )
{
GLuint texnum;
assert( tex != NULL );
assert( tex->texnum != 0 );
if( tex->missing ) {
tex = rsh.noTexture;
} else if( !tex->loaded ) {
// not yet loaded from disk
tex = tex->flags & IT_CUBEMAP ? rsh.whiteCubemapTexture : rsh.whiteTexture;
} else if( rsh.noTexture && ( r_nobind->integer && tex->texnum != 0 ) ) {
// performance evaluation option
tex = rsh.noTexture;
}
if( rb.gl.flushTextures ) {
rb.gl.flushTextures = false;
memset( rb.gl.currentTextures, 0, sizeof( rb.gl.currentTextures ) );
}
texnum = tex->texnum;
if( rb.gl.currentTextures[tmu] == texnum )
return;
rb.gl.currentTextures[tmu] = texnum;
RB_SelectTextureUnit( tmu );
qglBindTexture( R_TextureTarget( tex->flags, NULL ), tex->texnum );
rb.stats.c_totalBinds++;
}
示例12: gld_GetTextureBuffer
unsigned char* gld_GetTextureBuffer(GLuint texid, int miplevel, int *width, int *height)
{
int w, h;
static unsigned char *buf = NULL;
static int buf_size = 512 * 256 * 4;
if (!buf)
{
buf = malloc(buf_size);
}
if (texid)
{
qglBindTexture(GL_TEXTURE_2D, texid);
}
qglGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_WIDTH, &w);
qglGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_HEIGHT, &h);
if (w * h * 4 > buf_size)
{
free(buf);
buf_size = w * h * 4;
buf = malloc(buf_size);
}
qglGetTexImage(GL_TEXTURE_2D, miplevel, GL_RGBA, GL_UNSIGNED_BYTE, buf);
if (width)
*width = w;
if (height)
*height = h;
return buf;
}
示例13: GL_Bind
/**
* @brief GL_Bind
* @param[in,out] image
*/
void GL_Bind(image_t *image)
{
int texnum;
if (!image)
{
Ren_Warning("GL_Bind: NULL image\n");
texnum = tr.defaultImage->texnum;
}
else
{
texnum = image->texnum;
}
if (r_noBind->integer && tr.dlightImage) // performance evaluation option
{
texnum = tr.dlightImage->texnum;
}
if (glState.currenttextures[glState.currenttmu] != texnum)
{
if (image)
{
image->frameUsed = tr.frameCount;
}
glState.currenttextures[glState.currenttmu] = texnum;
qglBindTexture(GL_TEXTURE_2D, texnum);
}
}
示例14: RB_ExecuteBackEndCommands
void RB_ExecuteBackEndCommands( const emptyCommand_t *cmds ) {
// r_debugRenderToTexture
int c_draw3d = 0, c_draw2d = 0, c_setBuffers = 0, c_swapBuffers = 0, c_copyRenders = 0;
if ( cmds->commandId == RC_NOP && !cmds->next ) {
return;
}
backEndStartTime = Sys_Milliseconds();
// needed for editor rendering
RB_SetDefaultGLState();
// upload any image loads that have completed
globalImages->CompleteBackgroundImageLoads();
for ( ; cmds ; cmds = (const emptyCommand_t *)cmds->next ) {
switch ( cmds->commandId ) {
case RC_NOP:
break;
case RC_DRAW_VIEW:
RB_DrawView( cmds );
if ( ((const drawSurfsCommand_t *)cmds)->viewDef->viewEntitys ) {
c_draw3d++;
}
else {
c_draw2d++;
}
break;
case RC_SET_BUFFER:
RB_SetBuffer( cmds );
c_setBuffers++;
break;
case RC_SWAP_BUFFERS:
RB_SwapBuffers( cmds );
c_swapBuffers++;
break;
case RC_COPY_RENDER:
RB_CopyRender( cmds );
c_copyRenders++;
break;
default:
common->Error( "RB_ExecuteBackEndCommands: bad commandId" );
break;
}
}
// go back to the default texture so the editor doesn't mess up a bound image
qglBindTexture( GL_TEXTURE_2D, 0 );
backEnd.glState.tmu[0].current2DMap = -1;
// stop rendering on this thread
backEndFinishTime = Sys_Milliseconds();
backEnd.pc.msec = backEndFinishTime - backEndStartTime;
if ( r_debugRenderToTexture.GetInteger() == 1 ) {
common->Printf( "3d: %i, 2d: %i, SetBuf: %i, SwpBuf: %i, CpyRenders: %i, CpyFrameBuf: %i\n", c_draw3d, c_draw2d, c_setBuffers, c_swapBuffers, c_copyRenders, backEnd.c_copyFrameBuffer );
backEnd.c_copyFrameBuffer = 0;
}
}
示例15: GL_BindNullTextures
void GL_BindNullTextures()
{
int i;
if (glRefConfig.directStateAccess)
{
for (i = 0; i < NUM_TEXTURE_BUNDLES; i++)
{
qglBindMultiTexture(GL_TEXTURE0_ARB + i, GL_TEXTURE_2D, 0);
glDsaState.textures[i] = 0;
}
}
else
{
for (i = 0; i < NUM_TEXTURE_BUNDLES; i++)
{
qglActiveTextureARB(GL_TEXTURE0_ARB + i);
qglBindTexture(GL_TEXTURE_2D, 0);
glDsaState.textures[i] = 0;
}
qglActiveTextureARB(GL_TEXTURE0_ARB);
glDsaState.texunit = GL_TEXTURE0_ARB;
}
}