Is there a way to crop a texture?

I have a video stream coming in at 1920x1080 that I want to crop to 2048x1024 with black borders so I can have mipmaps. Is there a command that will do this for me automatically?

When you render a texture it maps to the uv texture coordinates of the triangle (or quad) you are drawing. Normally you would use 0,0 to 1,1 so that the texture completely filled the quad; but if you use 0,0,2,2 and set GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T to GL_CLAMP_TO_BORDER with glTexParameter then the image will be drawn in the bottom left quarter and the rest of the quad will fill with the border colour.In you case I think you want


dx = 2048.9/1920.0 - 1.0;
u for left is dx/2
u for right is 1+dx/2

I am not sure what you want to do with the height since you images is larger than the display area. To crop


dy = 1.0 - 1024.0/1080.0
v left dy/2
v right 1 - dy/2

No, I need to crop the texture before rendering so I can get mipmaps.

I believe most implementations these days support ARB_texture_non_power_of_two so unless you need to support one that does not have this you can get mip maps without doing anything.
Otherwise you should be able to set the GL_UNPACK_* parameters with glPixelStore to crop the texture during upload - note this will throw away pixels, not perform any rescaling, but it sounds like that is what you want.

I’m not sure how glPixelStore is used. Is there a tutorial on the site?