本文整理汇总了C++中PADP函数的典型用法代码示例。如果您正苦于以下问题:C++ PADP函数的具体用法?C++ PADP怎么用?C++ PADP使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PADP函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: of
/*
==================
RB_ReadPixels
Reads an image but takes care of alignment issues for reading RGB images.
Prepends the specified number of (uninitialized) bytes to the buffer.
The returned buffer must be freed with ri.Hunk_FreeTempMemory().
==================
*/
static byte *RB_ReadPixels( int x, int y, int width, int height, size_t offset )
{
GLint packAlign;
int lineLen, paddedLineLen;
byte *buffer, *pixels;
int i;
glGetIntegerv( GL_PACK_ALIGNMENT, &packAlign );
lineLen = width * 3;
paddedLineLen = PAD( lineLen, packAlign );
// Allocate a few more bytes so that we can choose an alignment we like
buffer = ( byte * ) ri.Hunk_AllocateTempMemory( offset + paddedLineLen * height + packAlign - 1 );
pixels = ( byte * ) PADP( buffer + offset, packAlign );
glReadPixels( x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels );
// Drop alignment and line padding bytes
for ( i = 0; i < height; ++i )
{
memmove( buffer + offset + i * lineLen, pixels + i * paddedLineLen, lineLen );
}
return buffer;
}
示例2: RB_ExecuteRenderCommands
/*
* RB_ExecuteRenderCommands
*
* This function will be called synchronously if running without
* smp extensions, or asynchronously by another thread.
*/
void
RB_ExecuteRenderCommands(const void *data)
{
int t1, t2;
t1 = ri.Milliseconds ();
if(!r_smp->integer || data == backEndData[0]->commands.cmds){
backEnd.smpFrame = 0;
}else{
backEnd.smpFrame = 1;
}
while(1){
data = PADP(data, sizeof(void *));
switch(*(const int*)data){
case RC_SET_COLOR:
data = RB_SetColor(data);
break;
case RC_STRETCH_PIC:
data = RB_StretchPic(data);
break;
case RC_DRAW_SURFS:
data = RB_DrawSurfs(data);
break;
case RC_DRAW_BUFFER:
data = RB_DrawBuffer(data);
break;
case RC_SWAP_BUFFERS:
data = RB_SwapBuffers(data);
break;
case RC_SCREENSHOT:
data = RB_TakeScreenshotCmd(data);
break;
case RC_VIDEOFRAME:
data = RB_TakeVideoFrameCmd(data);
break;
case RC_COLORMASK:
data = RB_ColorMask(data);
break;
case RC_CLEARDEPTH:
data = RB_ClearDepth(data);
break;
case RC_CAPSHADOWMAP:
data = RB_CapShadowMap(data);
break;
case RC_POSTPROCESS:
data = RB_PostProcess(data);
break;
case RC_END_OF_LIST:
default:
/* stop rendering on this thread */
t2 = ri.Milliseconds ();
backEnd.pc.msec = t2 - t1;
return;
}
}
}
示例3: RB_ExecuteRenderCommands
/*
====================
RB_ExecuteRenderCommands
====================
*/
void RB_ExecuteRenderCommands( const void *data ) {
int t1, t2;
t1 = ri.Milliseconds ();
while ( 1 ) {
data = PADP(data, sizeof(void *));
switch ( *(const int *)data ) {
case RC_SET_COLOR:
data = RB_SetColor( data );
break;
case RC_STRETCH_PIC:
data = RB_StretchPic( data );
break;
case RC_DRAW_SURFS:
data = RB_DrawSurfs( data );
break;
case RC_DRAW_BUFFER:
data = RB_DrawBuffer( data );
break;
case RC_SWAP_BUFFERS:
data = RB_SwapBuffers( data );
break;
case RC_SCREENSHOT:
data = RB_TakeScreenshotCmd( data );
break;
case RC_VIDEOFRAME:
data = RB_TakeVideoFrameCmd( data );
break;
case RC_COLORMASK:
data = RB_ColorMask(data);
break;
case RC_CLEARDEPTH:
data = RB_ClearDepth(data);
break;
case RC_CAPSHADOWMAP:
data = RB_CapShadowMap(data);
break;
case RC_POSTPROCESS:
data = RB_PostProcess(data);
break;
case RC_EXPORT_CUBEMAPS:
data = RB_ExportCubemaps(data);
break;
case RC_END_OF_LIST:
default:
// finish any 2D drawing if needed
if(tess.numIndexes)
RB_EndSurface();
// stop rendering
t2 = ri.Milliseconds ();
backEnd.pc.msec = t2 - t1;
return;
}
}
}
示例4: RB_ExecuteRenderCommands
/*
====================
RB_ExecuteRenderCommands
====================
*/
void RB_ExecuteRenderCommands( const void *data ) {
int t1, t2;
t1 = ri.Milliseconds ();
while ( 1 ) {
data = PADP(data, sizeof(void *));
switch ( *(const int *)data ) {
case RC_SET_COLOR:
data = RB_SetColor( data );
break;
case RC_STRETCH_PIC:
data = RB_StretchPic( data );
break;
case RC_ROTATED_PIC:
data = RB_RotatedPic( data );
break;
case RC_DRAW_SURFS:
data = RB_DrawSurfs( data );
break;
case RC_DRAW_BUFFER:
data = RB_DrawBuffer( data );
break;
case RC_SWAP_BUFFERS:
data = RB_SwapBuffers( data );
break;
case RC_SCREENSHOT:
data = RB_TakeScreenshotCmd( data );
break;
case RC_VIDEOFRAME:
data = RB_TakeVideoFrameCmd( data );
break;
case RC_COLORMASK:
data = RB_ColorMask(data);
break;
case RC_CLEARDEPTH:
data = RB_ClearDepth(data);
break;
case RC_END_OF_LIST:
default:
// stop rendering
t2 = ri.Milliseconds ();
backEnd.pc.msec = t2 - t1;
return;
}
}
}
示例5: qglGetIntegerv
byte *RB_ReadZBuffer(int x, int y, int width, int height, int *padlen)
{
byte *buffer, *bufstart;
int padwidth, linelen;
GLint packAlign;
qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);
linelen = width;
padwidth = PAD(linelen, packAlign);
// Allocate a few more bytes so that we can choose an alignment we like
buffer = ri.Hunk_AllocateTempMemory(padwidth * height + packAlign - 1);
bufstart = PADP(( intptr_t ) buffer, packAlign);
qglDepthRange(0.0f, 1.0f);
memset(buffer, 0, padwidth * height + packAlign - 1); //*TODO* find something to read DepthBuffer ?!
*padlen = padwidth - linelen;
return buffer;
}
示例6: qglGetIntegerv
byte *RB_ReadZBuffer(int x, int y, int width, int height, int *padlen)
{
byte *buffer, *bufstart;
int padwidth, linelen;
GLint packAlign;
qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);
linelen = width;
padwidth = PAD(linelen, packAlign);
// Allocate a few more bytes so that we can choose an alignment we like
buffer = ri.Hunk_AllocateTempMemory(padwidth * height + packAlign - 1);
bufstart = PADP(( intptr_t ) buffer, packAlign);
qglDepthRange(0.0f, 1.0f);
qglReadPixels(x, y, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, bufstart);
*padlen = padwidth - linelen;
return buffer;
}
示例7: qglGetIntegerv
byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *padlen)
{
byte *buffer, *bufstart;
int padwidth, linelen;
GLint packAlign;
qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);
linelen = width * 3;
padwidth = PAD(linelen, packAlign);
// Allocate a few more bytes so that we can choose an alignment we like
buffer = ri.Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1);
#ifdef USE_OPENGLES
bufstart=buffer;
padwidth=linelen;
int p2width=1, p2height=1;
int xx, yy, aa;
while (p2width<glConfig.vidWidth) p2width*=2;
while (p2height<glConfig.vidHeight) p2height*=2;
byte *source = (byte*) ri.Z_Malloc( p2width * p2height * 4 );
qglReadPixels( 0, 0, p2width, p2height, GL_RGBA, GL_UNSIGNED_BYTE, source );
for (yy=y; yy<height; yy++)
for (xx=x; xx<width; xx++)
for (aa=0; aa<3; aa++)
buffer[yy*width*3+xx*3+aa]=source[(yy+y)*p2width*4+(xx+x)*4+aa];
ri.Free(source);
#else
bufstart = PADP((intptr_t) buffer + *offset, packAlign);
qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart);
#endif
*offset = bufstart - buffer;
*padlen = padwidth - linelen;
return buffer;
}
示例8: glGetIntegerv
/*
==================
RB_TakeVideoFrameCmd
==================
*/
const void *RB_TakeVideoFrameCmd( const void *data )
{
const videoFrameCommand_t *cmd;
GLint packAlign;
int lineLen, captureLineLen;
byte *pixels;
int i;
int outputSize;
int j;
int aviLineLen;
cmd = ( const videoFrameCommand_t * ) data;
// RB: it is possible to we still have a videoFrameCommand_t but we already stopped
// video recording
if ( ri.CL_VideoRecording() )
{
// take care of alignment issues for reading RGB images..
glGetIntegerv( GL_PACK_ALIGNMENT, &packAlign );
lineLen = cmd->width * 3;
captureLineLen = PAD( lineLen, packAlign );
pixels = ( byte * ) PADP( cmd->captureBuffer, packAlign );
glReadPixels( 0, 0, cmd->width, cmd->height, GL_RGB, GL_UNSIGNED_BYTE, pixels );
if ( tr.overbrightBits > 0 && glConfig.deviceSupportsGamma )
{
// this also runs over the padding...
R_GammaCorrect( pixels, captureLineLen * cmd->height );
}
if ( cmd->motionJpeg )
{
// Drop alignment and line padding bytes
for ( i = 0; i < cmd->height; ++i )
{
memmove( cmd->captureBuffer + i * lineLen, pixels + i * captureLineLen, lineLen );
}
outputSize = SaveJPGToBuffer( cmd->encodeBuffer, 3 * cmd->width * cmd->height, 90, cmd->width, cmd->height, cmd->captureBuffer );
ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, outputSize );
}
else
{
aviLineLen = PAD( lineLen, AVI_LINE_PADDING );
for ( i = 0; i < cmd->height; ++i )
{
for ( j = 0; j < lineLen; j += 3 )
{
cmd->encodeBuffer[ i * aviLineLen + j + 0 ] = pixels[ i * captureLineLen + j + 2 ];
cmd->encodeBuffer[ i * aviLineLen + j + 1 ] = pixels[ i * captureLineLen + j + 1 ];
cmd->encodeBuffer[ i * aviLineLen + j + 2 ] = pixels[ i * captureLineLen + j + 0 ];
}
while ( j < aviLineLen )
{
cmd->encodeBuffer[ i * aviLineLen + j++ ] = 0;
}
}
ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, aviLineLen * cmd->height );
}
}
return ( const void * )( cmd + 1 );
}
示例9: RB_ExecuteRenderCommands
/*
====================
RB_ExecuteRenderCommands
This function will be called synchronously if running without
smp extensions, or asynchronously by another thread.
====================
*/
void RB_ExecuteRenderCommands( const void *data ) {
int t1, t2;
t1 = ri.Milliseconds ();
if ( !r_smp->integer || data == backEndData[0]->commands.cmds ) {
backEnd.smpFrame = 0;
} else {
backEnd.smpFrame = 1;
}
while ( 1 ) {
data = PADP(data, sizeof(void *));
switch ( *(const int *)data ) {
case RC_SET_COLOR:
data = RB_SetColor( data );
break;
case RC_STRETCH_PIC:
#ifdef FRAMEBUFFER_AND_GLSL_SUPPORT
R_FrameBuffer_EndFrame();
#endif
data = RB_StretchPic( data );
break;
case RC_DRAW_SURFS:
data = RB_DrawSurfs( data );
break;
case RC_DRAW_BUFFER:
#ifdef FRAMEBUFFER_AND_GLSL_SUPPORT
data = useFrameBuffer ? RB_DrawFrameBuffer( data ) : RB_DrawBuffer( data );
#else
data = RB_DrawBuffer( data );
#endif
break;
case RC_SWAP_BUFFERS:
data = RB_SwapBuffers( data );
break;
//these two use a hack to let them copy the framebuffer effects too
case RC_SCREENSHOT:
#ifdef FRAMEBUFFER_AND_GLSL_SUPPORT
R_FrameBufferUnBind();
#endif
data = RB_TakeScreenshotCmd( data );
#ifdef FRAMEBUFFER_AND_GLSL_SUPPORT
R_FrameBufferBind();
#endif
break;
case RC_VIDEOFRAME:
#ifdef FRAMEBUFFER_AND_GLSL_SUPPORT
R_FrameBufferUnBind();
#endif
data = RB_TakeVideoFrameCmd( data );
#ifdef FRAMEBUFFER_AND_GLSL_SUPPORT
R_FrameBufferBind();
#endif
break;
case RC_COLORMASK:
data = RB_ColorMask(data);
break;
case RC_CLEARDEPTH:
data = RB_ClearDepth(data);
break;
case RC_END_OF_LIST:
default:
// stop rendering on this thread
t2 = ri.Milliseconds ();
backEnd.pc.msec = t2 - t1;
return;
}
}
}
示例10: R_LoadIQModel
/*
=================
R_LoadIQModel
Load an IQM model and compute the joint matrices for every frame.
=================
*/
bool R_LoadIQModel( model_t *mod, void *buffer, int filesize,
const char *mod_name ) {
iqmHeader_t *header;
iqmVertexArray_t *vertexarray;
iqmTriangle_t *triangle;
iqmMesh_t *mesh;
iqmJoint_t *joint;
iqmPose_t *pose;
iqmAnim_t *anim;
unsigned short *framedata;
char *str, *name;
int len;
transform_t *trans, *poses;
float *bounds;
size_t size, len_names;
IQModel_t *IQModel;
IQAnim_t *IQAnim;
srfIQModel_t *surface;
vboData_t vboData;
float *weightbuf;
int *indexbuf;
i16vec4_t *qtangentbuf;
VBO_t *vbo;
IBO_t *ibo;
void *ptr;
u8vec4_t *weights;
if( !LoadIQMFile( buffer, filesize, mod_name, &len_names ) ) {
return false;
}
header = (iqmHeader_t *)buffer;
// compute required space
size = sizeof(IQModel_t);
size += header->num_meshes * sizeof( srfIQModel_t );
size += header->num_anims * sizeof( IQAnim_t );
size += header->num_joints * sizeof( transform_t );
size = PAD( size, 16 );
size += header->num_joints * header->num_frames * sizeof( transform_t );
if(header->ofs_bounds)
size += header->num_frames * 6 * sizeof(float); // model bounds
size += header->num_vertexes * 3 * sizeof(float); // positions
size += header->num_vertexes * 3 * sizeof(float); // normals
size += header->num_vertexes * 3 * sizeof(float); // tangents
size += header->num_vertexes * 3 * sizeof(float); // bitangents
size += header->num_vertexes * 2 * sizeof(int16_t); // texcoords
size += header->num_vertexes * 4 * sizeof(byte); // blendIndexes
size += header->num_vertexes * 4 * sizeof(byte); // blendWeights
size += header->num_vertexes * 4 * sizeof(byte); // colors
size += header->num_triangles * 3 * sizeof(int); // triangles
size += header->num_joints * sizeof(int); // parents
size += len_names; // joint and anim names
IQModel = (IQModel_t *)ri.Hunk_Alloc( size, ha_pref::h_low );
mod->type = modtype_t::MOD_IQM;
mod->iqm = IQModel;
ptr = IQModel + 1;
// fill header and setup pointers
IQModel->num_vertexes = header->num_vertexes;
IQModel->num_triangles = header->num_triangles;
IQModel->num_frames = header->num_frames;
IQModel->num_surfaces = header->num_meshes;
IQModel->num_joints = header->num_joints;
IQModel->num_anims = header->num_anims;
IQModel->surfaces = (srfIQModel_t *)ptr;
ptr = IQModel->surfaces + header->num_meshes;
if( header->ofs_anims ) {
IQModel->anims = (IQAnim_t *)ptr;
ptr = IQModel->anims + header->num_anims;
} else {
IQModel->anims = nullptr;
}
IQModel->joints = (transform_t *)PADP(ptr, 16);
ptr = IQModel->joints + header->num_joints;
if( header->ofs_poses ) {
poses = (transform_t *)ptr;
ptr = poses + header->num_poses * header->num_frames;
} else {
poses = nullptr;
}
if( header->ofs_bounds ) {
bounds = (float *)ptr;
ptr = bounds + 6 * header->num_frames;
} else {
bounds = nullptr;
}
//.........这里部分代码省略.........
示例11: R_LevelShot
/*
====================
R_LevelShot
levelshots are specialized 128*128 thumbnails for
the menu system, sampled down from full screen distorted images
====================
*/
void R_LevelShot( screenshotType_e type, const char *ext ) {
char fileName[MAX_OSPATH];
byte *source;
byte *resample, *resamplestart;
size_t offset = 0, memcount;
int spadlen, rpadlen;
int padwidth, linelen;
GLint packAlign;
byte *src, *dst;
int x, y;
int r, g, b;
float xScale, yScale;
int xx, yy;
int width, height;
int arg;
// Allow custom resample width/height
arg = atoi(ri.Cmd_Argv(2));
if (arg > 0)
width = height = arg;
else
width = height = 128;
if (width > glConfig.vidWidth)
width = glConfig.vidWidth;
if (height > glConfig.vidHeight)
height = glConfig.vidHeight;
Com_sprintf(fileName, sizeof(fileName), "levelshots/%s_small%s", tr.world->baseName, ext);
source = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
//
// Based on RB_ReadPixels
qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);
linelen = width * 3;
padwidth = PAD(linelen, packAlign);
// Allocate a few more bytes so that we can choose an alignment we like
resample = ri.Hunk_AllocateTempMemory(padwidth * height + offset + packAlign - 1);
resamplestart = PADP((intptr_t) resample + offset, packAlign);
offset = resamplestart - resample;
rpadlen = padwidth - linelen;
//
// resample from source
xScale = glConfig.vidWidth / (float)(width * 4.0f);
yScale = glConfig.vidHeight / (float)(height * 3.0f);
for ( y = 0 ; y < height ; y++ ) {
for ( x = 0 ; x < width ; x++ ) {
r = g = b = 0;
for ( yy = 0 ; yy < 3 ; yy++ ) {
for ( xx = 0 ; xx < 4 ; xx++ ) {
src = source + (3 * glConfig.vidWidth + spadlen) * (int)((y*3 + yy) * yScale) +
3 * (int) ((x*4 + xx) * xScale);
r += src[0];
g += src[1];
b += src[2];
}
}
dst = resample + 3 * ( y * width + x );
dst[0] = r / 12;
dst[1] = g / 12;
dst[2] = b / 12;
}
}
memcount = (width * 3 + rpadlen) * height;
// gamma correct
if(glConfig.deviceSupportsGamma)
R_GammaCorrect(resample + offset, memcount);
if ( type == ST_TGA )
RE_SaveTGA(fileName, width, height, resample + offset, rpadlen);
else if ( type == ST_JPEG )
RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample + offset, rpadlen);
else if ( type == ST_PNG )
RE_SavePNG(fileName, width, height, resample + offset, rpadlen);
ri.Hunk_FreeTempMemory(resample);
ri.Hunk_FreeTempMemory(source);
ri.Printf( PRINT_ALL, "Wrote %s\n", fileName );
}