From Quake Wiki

Extension Proposal[edit]

Suggested extension for copying a portion of the screen to a texture in client side QuakeC. This will essentially be a wrapper for the OpenGL function glCopyTexImage2D (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/copyteximage2d.html).

Builtin functions:

string csqc_allocdynamictexture();

Allocates a dynamic texture, returns a string which can be used as any precached texture could be.

vector csqc_copytotexture(float x, float y, float w, float h, string texture);

x, y, w, and h specify the portion of the screen from which to copy pixels. They use the exact same coordinate space as R_SetView does for the view portal, were the top left of the screen is 0, 0, and the width and height are vid_conwidth and vid_conheight respectively.

texture specifies the name of the destination texture which will receive the new data. It must have been allocated with csqc_alloctexture.

glCopyTexImage2D requires that the destination texture have width and height be a power of two, though they don't have to be the same length. csqc_copytotexture should accept any width and height, and automatically use a larger texture. The vector returned is the s and t texture coordinates of the corner of the desired texture within the larger power-of-2 sided texture.

Possible Issues[edit]

glCopyTexImage2D copies pixels upside-down compared to quake's 2D coordinate system:

Pixel ordering is such that lower x and y screen coordinates correspond to lower s and t texture coordinates.

This means that the texture coordinates will be upside down in QuakeC.

I think the desired image will be aligned to the top left of the texture, but upside down. (It might be aligned to the bottom, have to check).