本文整理汇总了C++中R_GammaCorrect函数的典型用法代码示例。如果您正苦于以下问题:C++ R_GammaCorrect函数的具体用法?C++ R_GammaCorrect怎么用?C++ R_GammaCorrect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_GammaCorrect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_TakeScreenshot
// "filename" param is something like "screenshots/shot0000.tga"
// note that if the last extension is ".jpg", then it'll save a JPG, else TGA
//
void R_TakeScreenshot( int x, int y, int width, int height, char *fileName ) {
#ifndef _XBOX
byte *buffer;
int i, c, temp;
qboolean bSaveAsJPG = !strnicmp(&fileName[strlen(fileName)-4],".jpg",4);
if (bSaveAsJPG)
{
// JPG saver expects to be fed RGBA data, though it presumably ignores 'A'...
//
buffer = (unsigned char *) Z_Malloc(glConfig.vidWidth*glConfig.vidHeight*4, TAG_TEMP_WORKSPACE, qfalse);
qglReadPixels( x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
// gamma correct
if ( tr.overbrightBits>0 && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer, glConfig.vidWidth * glConfig.vidHeight * 4 );
}
SaveJPG(fileName, 95, width, height, buffer);
}
else
{
// TGA...
//
buffer = (unsigned char *) Z_Malloc(glConfig.vidWidth*glConfig.vidHeight*3 + 18, TAG_TEMP_WORKSPACE, qfalse);
memset (buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = width & 255;
buffer[13] = width >> 8;
buffer[14] = height & 255;
buffer[15] = height >> 8;
buffer[16] = 24; // pixel size
qglReadPixels( x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 );
// swap rgb to bgr
c = 18 + width * height * 3;
for (i=18 ; i<c ; i+=3) {
temp = buffer[i];
buffer[i] = buffer[i+2];
buffer[i+2] = temp;
}
// gamma correct
if ( tr.overbrightBits>0 && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer + 18, glConfig.vidWidth * glConfig.vidHeight * 3 );
}
FS_WriteFile( fileName, buffer, c );
}
Z_Free( buffer );
#endif
}
示例2: R_LevelShot
static void R_LevelShot( void ) {
#ifndef _XBOX
char checkname[MAX_OSPATH];
byte *buffer;
byte *source;
byte *src, *dst;
int x, y;
int r, g, b;
float xScale, yScale;
int xx, yy;
sprintf( checkname, "levelshots/%s.tga", tr.world->baseName );
source = (unsigned char *)Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight * 3 );
buffer = (unsigned char *)Hunk_AllocateTempMemory( LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18);
Com_Memset (buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = LEVELSHOTSIZE & 255;
buffer[13] = LEVELSHOTSIZE >> 8;
buffer[14] = LEVELSHOTSIZE & 255;
buffer[15] = LEVELSHOTSIZE >> 8;
buffer[16] = 24; // pixel size
qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_RGB, GL_UNSIGNED_BYTE, source );
// resample from source
xScale = glConfig.vidWidth / (4.0*LEVELSHOTSIZE);
yScale = glConfig.vidHeight / (3.0*LEVELSHOTSIZE);
for ( y = 0 ; y < LEVELSHOTSIZE ; y++ ) {
for ( x = 0 ; x < LEVELSHOTSIZE ; x++ ) {
r = g = b = 0;
for ( yy = 0 ; yy < 3 ; yy++ ) {
for ( xx = 0 ; xx < 4 ; xx++ ) {
src = source + 3 * ( glConfig.vidWidth * (int)( (y*3+yy)*yScale ) + (int)( (x*4+xx)*xScale ) );
r += src[0];
g += src[1];
b += src[2];
}
}
dst = buffer + 18 + 3 * ( y * LEVELSHOTSIZE + x );
dst[0] = b / 12;
dst[1] = g / 12;
dst[2] = r / 12;
}
}
// gamma correct
if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer + 18, LEVELSHOTSIZE * LEVELSHOTSIZE * 3 );
}
FS_WriteFile( checkname, buffer, LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18 );
Hunk_FreeTempMemory( buffer );
Hunk_FreeTempMemory( source );
Com_Printf ("Wrote %s\n", checkname );
#endif
}
示例3: RB_TakeScreenshot
/*
==================
RB_TakeScreenshot
==================
*/
void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName)
{
byte *allbuf, *buffer;
byte *srcptr, *destptr;
byte *endline, *endmem;
byte temp;
int linelen, padlen;
size_t offset = 18, memcount;
allbuf = RB_ReadPixels(x, y, width, height, &offset, &padlen);
buffer = allbuf + offset - 18;
Com_Memset (buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = width & 255;
buffer[13] = width >> 8;
buffer[14] = height & 255;
buffer[15] = height >> 8;
buffer[16] = 24; // pixel size
// swap rgb to bgr and remove padding from line endings
linelen = width * 3;
srcptr = destptr = allbuf + offset;
endmem = srcptr + (linelen + padlen) * height;
while(srcptr < endmem)
{
endline = srcptr + linelen;
while(srcptr < endline)
{
temp = srcptr[0];
*destptr++ = srcptr[2];
*destptr++ = srcptr[1];
*destptr++ = temp;
srcptr += 3;
}
// Skip the pad
srcptr += padlen;
}
memcount = linelen * height;
// gamma correct
if(glConfig.deviceSupportsGamma
//openarena: altbright
&& !r_alternateBrightness->integer
//-openarena
) {
R_GammaCorrect(allbuf + offset, memcount);
}
ri.FS_WriteFile(fileName, buffer, memcount + 18);
ri.Hunk_FreeTempMemory(allbuf);
}
示例4: R_LevelShot
void R_LevelShot( void ) {
#ifndef _XBOX
char checkname[MAX_OSPATH];
byte *buffer;
byte *source;
byte *src, *dst;
int x, y;
int r, g, b;
float xScale, yScale;
int xx, yy;
sprintf( checkname, "levelshots/%s.tga", tr.worldDir + strlen("maps/") );
source = (byte*) Z_Malloc( glConfig.vidWidth * glConfig.vidHeight * 3, TAG_TEMP_WORKSPACE, qfalse );
buffer = (byte*) Z_Malloc( LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18, TAG_TEMP_WORKSPACE, qfalse );
memset (buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = LEVELSHOTSIZE & 255;
buffer[13] = LEVELSHOTSIZE >> 8;
buffer[14] = LEVELSHOTSIZE & 255;
buffer[15] = LEVELSHOTSIZE >> 8;
buffer[16] = 24; // pixel size
qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_RGB, GL_UNSIGNED_BYTE, source );
// resample from source
xScale = glConfig.vidWidth / (4.0*LEVELSHOTSIZE);
yScale = glConfig.vidHeight / (3.0*LEVELSHOTSIZE);
for ( y = 0 ; y < LEVELSHOTSIZE ; y++ ) {
for ( x = 0 ; x < LEVELSHOTSIZE ; x++ ) {
r = g = b = 0;
for ( yy = 0 ; yy < 3 ; yy++ ) {
for ( xx = 0 ; xx < 4 ; xx++ ) {
src = source + 3 * ( glConfig.vidWidth * (int)( (y*3+yy)*yScale ) + (int)( (x*4+xx)*xScale ) );
r += src[0];
g += src[1];
b += src[2];
}
}
dst = buffer + 18 + 3 * ( y * LEVELSHOTSIZE + x );
dst[0] = b / 12;
dst[1] = g / 12;
dst[2] = r / 12;
}
}
// gamma correct
if ( glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer + 18, LEVELSHOTSIZE * LEVELSHOTSIZE * 3 );
}
FS_WriteFile( checkname, buffer, LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18 );
Z_Free( buffer );
Z_Free( source );
VID_Printf( PRINT_ALL, "Wrote %s\n", checkname );
#endif
}
示例5: R_TakeScreenshot
/*
==================
R_TakeScreenshot
==================
*/
void R_TakeScreenshot( int x, int y, int width, int height, char *fileName ) {
byte *buffer;
int i, c, temp;
buffer = (unsigned char *)Hunk_AllocateTempMemory(glConfig.vidWidth*glConfig.vidHeight*3+18);
Com_Memset (buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = width & 255;
buffer[13] = width >> 8;
buffer[14] = height & 255;
buffer[15] = height >> 8;
buffer[16] = 24; // pixel size
qglReadPixels( x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 );
// swap rgb to bgr
c = 18 + width * height * 3;
for (i=18 ; i<c ; i+=3) {
temp = buffer[i];
buffer[i] = buffer[i+2];
buffer[i+2] = temp;
}
// gamma correct
if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer + 18, glConfig.vidWidth * glConfig.vidHeight * 3 );
}
FS_WriteFile( fileName, buffer, c );
Hunk_FreeTempMemory( buffer );
}
示例6: R_LevelShot
/*
* R_LevelShot
*
* levelshots are specialized 128*128 thumbnails for
* the menu system, sampled down from full screen distorted images
*/
void
R_LevelShot(void)
{
char checkname[MAX_OSPATH];
byte *buffer;
byte *source, *allsource;
byte *src, *dst;
size_t offset = 0;
int padlen;
int x, y;
int r, g, b;
float xScale, yScale;
int xx, yy;
Q_sprintf(checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName);
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen);
source = allsource + offset;
buffer = ri.hunkalloctemp(128 * 128*3 + 18);
Q_Memset (buffer, 0, 18);
buffer[2] = 2; /* uncompressed type */
buffer[12] = 128;
buffer[14] = 128;
buffer[16] = 24; /* pixel size */
/* resample from source */
xScale = glConfig.vidWidth / 512.0f;
yScale = glConfig.vidHeight / 384.0f;
for(y = 0; y < 128; y++)
for(x = 0; x < 128; x++){
r = g = b = 0;
for(yy = 0; yy < 3; yy++)
for(xx = 0; xx < 4; xx++){
src = source +
(3 * glConfig.vidWidth + padlen) * (int)((y*3 + yy) * yScale) +
3 * (int)((x*4 + xx) * xScale);
r += src[0];
g += src[1];
b += src[2];
}
dst = buffer + 18 + 3 * (y * 128 + x);
dst[0] = b / 12;
dst[1] = g / 12;
dst[2] = r / 12;
}
/* gamma correct */
if(glConfig.deviceSupportsGamma){
R_GammaCorrect(buffer + 18, 128 * 128 * 3);
}
ri.fswritefile(checkname, buffer, 128 * 128*3 + 18);
ri.hunkfreetemp(buffer);
ri.hunkfreetemp(allsource);
ri.Printf(PRINT_ALL, "Wrote %s\n", checkname);
}
示例7: R_LevelShot
/*
====================
R_LevelShot
levelshots are specialized 128*128 thumbnails for
the menu system, sampled down from full screen distorted images
====================
*/
void R_LevelShot( void ) {
char checkname[MAX_OSPATH];
byte *buffer;
byte *source;
byte *src, *dst;
int x, y;
int r, g, b;
float xScale, yScale;
int xx, yy;
sprintf( checkname, "levelshots/%s.tga", tr.world->baseName );
source = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight * 3 );
buffer = ri.Hunk_AllocateTempMemory( 128 * 128*3 + 18);
Com_Memset (buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = 128;
buffer[14] = 128;
buffer[16] = 24; // pixel size
qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_RGB, GL_UNSIGNED_BYTE, source );
// resample from source
xScale = glConfig.vidWidth / 512.0f;
yScale = glConfig.vidHeight / 384.0f;
for ( y = 0 ; y < 128 ; y++ ) {
for ( x = 0 ; x < 128 ; x++ ) {
r = g = b = 0;
for ( yy = 0 ; yy < 3 ; yy++ ) {
for ( xx = 0 ; xx < 4 ; xx++ ) {
src = source + 3 * ( glConfig.vidWidth * (int)( (y*3+yy)*yScale ) + (int)( (x*4+xx)*xScale ) );
r += src[0];
g += src[1];
b += src[2];
}
}
dst = buffer + 18 + 3 * ( y * 128 + x );
dst[0] = b / 12;
dst[1] = g / 12;
dst[2] = r / 12;
}
}
// gamma correct
if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer + 18, 128 * 128 * 3 );
}
ri.FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 );
ri.Hunk_FreeTempMemory( buffer );
ri.Hunk_FreeTempMemory( source );
ri.Printf( PRINT_ALL, "Wrote %s\n", checkname );
}
示例8: RB_TakeScreenshot
/*
* RB_TakeScreenshot
*/
void
RB_TakeScreenshot(int x, int y, int width, int height, char *fileName)
{
byte *allbuf, *buffer;
byte *srcptr, *destptr;
byte *endline, *endmem;
byte temp;
int linelen, padlen;
size_t offset = 18, memcount;
allbuf = RB_ReadPixels(x, y, width, height, &offset, &padlen);
buffer = allbuf + offset - 18;
Q_Memset (buffer, 0, 18);
buffer[2] = 2; /* uncompressed type */
buffer[12] = width & 255;
buffer[13] = width >> 8;
buffer[14] = height & 255;
buffer[15] = height >> 8;
buffer[16] = 24; /* pixel size */
/* swap rgb to bgr and remove padding from line endings */
linelen = width * 3;
srcptr = destptr = allbuf + offset;
endmem = srcptr + (linelen + padlen) * height;
while(srcptr < endmem){
endline = srcptr + linelen;
while(srcptr < endline){
temp = srcptr[0];
*destptr++ = srcptr[2];
*destptr++ = srcptr[1];
*destptr++ = temp;
srcptr += 3;
}
/* Skip the pad */
srcptr += padlen;
}
memcount = linelen * height;
/* gamma correct */
if(glConfig.deviceSupportsGamma)
R_GammaCorrect(allbuf + offset, memcount);
ri.fswritefile(fileName, buffer, memcount + 18);
ri.hunkfreetemp(allbuf);
}
示例9: R_TakeScreenshotPNG
/*
==================
R_TakeScreenshotPNG
==================
*/
static void R_TakeScreenshotPNG( int x, int y, int width, int height, char *fileName )
{
byte *buffer = RB_ReadPixels( x, y, width, height, 0 );
if ( tr.overbrightBits > 0 && glConfig.deviceSupportsGamma )
{
R_GammaCorrect( buffer, 3 * width * height );
}
SavePNG( fileName, buffer, width, height, 3, qfalse );
ri.Hunk_FreeTempMemory( buffer );
}
示例10: R_TakeScreenshotJPEG
/*
==================
R_TakeScreenshot
==================
*/
void R_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName ) {
byte *buffer;
size_t offset = 0, memcount;
int padlen;
buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen);
memcount = (width * 3 + padlen) * height;
// gamma correct
if(glConfig.deviceSupportsGamma)
R_GammaCorrect(buffer + offset, memcount);
RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen);
Hunk_FreeTempMemory(buffer);
}
示例11: R_TakeScreenshotJPEG
void R_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName) {
byte *buffer;
size_t offset = 0, memcount;
int padlen;
buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen);
memcount = (width * 3 + padlen) * height;
// gamma correct
if (r_gammamethod->integer == GAMMA_HARDWARE)
R_GammaCorrect(buffer + offset, (int)memcount);
SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen);
ri.Hunk_FreeTempMemory(buffer);
}
示例12: RB_TakeScreenshotPNG
/*
==================
RB_TakeScreenshotPNG
==================
*/
static void RB_TakeScreenshotPNG(int x, int y, int width, int height, char *fileName)
{
byte *buffer;
size_t offset = 0, memcount;
int padlen;
buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen);
memcount = (width * 3 + padlen) * height;
// gamma correct
if(glConfig.deviceSupportsGamma)
R_GammaCorrect(buffer + offset, memcount);
RE_SavePNG(fileName, width, height, buffer+offset, 3, padlen, qfalse);
ri.Hunk_FreeTempMemory(buffer);
}
示例13: R_TakeScreenshotJPEG
/*
==================
R_TakeScreenshot
==================
*/
void R_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName ) {
byte *buffer;
buffer = (unsigned char *)Hunk_AllocateTempMemory(glConfig.vidWidth*glConfig.vidHeight*4);
qglReadPixels( x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
// gamma correct
if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer, glConfig.vidWidth * glConfig.vidHeight * 4 );
}
FS_WriteFile( fileName, buffer, 1 ); // create path
SaveJPG( fileName, 95, glConfig.vidWidth, glConfig.vidHeight, buffer);
Hunk_FreeTempMemory( buffer );
}
示例14: RB_TakeScreenshotJPEG
/*
==================
RB_TakeScreenshotJPEG
==================
*/
void RB_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName ) {
byte *buffer;
buffer = (byte *)ri.Hunk_AllocateTempMemory(glConfig.vidWidth*glConfig.vidHeight*4); // ***GREGS_VC9_PORT_MOD*** -- needed typecast
qglReadPixels( x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
// gamma correct
if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer, glConfig.vidWidth * glConfig.vidHeight * 4 );
}
ri.FS_WriteFile( fileName, buffer, 1 ); // create path
SaveJPG( fileName, 95, glConfig.vidWidth, glConfig.vidHeight, buffer);
ri.Hunk_FreeTempMemory( buffer );
}
示例15: R_LevelShot
// levelshots are specialized 128*128 thumbnails for the menu system, sampled
// down from full screen distorted images
static void R_LevelShot() {
char checkname[ MAX_OSPATH ];
String::Sprintf( checkname, MAX_OSPATH, "levelshots/%s.tga", tr.world->baseName );
byte* source = new byte[ glConfig.vidWidth * glConfig.vidHeight * 3 ];
byte* buffer = new byte[ 128 * 128 * 3 ];
qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_RGB, GL_UNSIGNED_BYTE, source );
// resample from source
float xScale = glConfig.vidWidth / 512.0f;
float yScale = glConfig.vidHeight / 384.0f;
for ( int y = 0; y < 128; y++ ) {
for ( int x = 0; x < 128; x++ ) {
int r = 0;
int g = 0;
int b = 0;
for ( int yy = 0; yy < 3; yy++ ) {
for ( int xx = 0; xx < 4; xx++ ) {
byte* src = source + 3 * ( glConfig.vidWidth * ( int )( ( y * 3 + yy ) * yScale ) + ( int )( ( x * 4 + xx ) * xScale ) );
r += src[ 0 ];
g += src[ 1 ];
b += src[ 2 ];
}
}
byte* dst = buffer + 3 * ( y * 128 + x );
dst[ 0 ] = r / 12;
dst[ 1 ] = g / 12;
dst[ 2 ] = b / 12;
}
}
// gamma correct
if ( tr.overbrightBits > 0 && glConfig.deviceSupportsGamma ) {
R_GammaCorrect( buffer, 128 * 128 * 3 );
}
R_SaveTGA( checkname, buffer, 128, 128, false );
delete[] buffer;
delete[] source;
common->Printf( "Wrote %s\n", checkname );
}