title: How to add a shader to a fixed-pipeline OpenGL app
body: <p>I am updating an existing app for Mac OS that is based on the older fixed-pipeline OpenGL. (OpenGL 2, I guess it is.) It uses an NSOpenGLView and an ortho projection to create animated kaleidoscopes, with either still images or input from a connected video camera.</p>
  
  <p>It was written before HD cameras were available (or at least readily so.) It's written to expect YCBCR_422 video frames from Quicktime (k422YpCbCr8CodecType) and passes the frames to OpenGL as GL_YCBCR_422_APPLE to map them to a texture.</p>
  
  <p>My company decided it was time to update the app to support the new crop of HD cameras, and I am not sure how to proceed.</p>
  
  <p>I have a decent amount of OpenGL experience, but my knowledge is spotty and has gaps in it.</p>
  
  <p>I'm using the delegate method captureOutput:didOutputVideoFrame:withSampleBuffer:fromConnection to receive frames from the camera via a QTCaptureDecompressedVideoOutput</p>
  
  <p>I have a Logitech c615 for testing, and the buffers I'm getting are reported as being in 32 bit RGBA (GL_RGBA8) format. I believe it's actually in ARGB format.</p>
  
  <p>However, according to the docs on glTexImage2D, the only supported input pixel formats are GL_COLOR_INDEX, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RGB, GL_BGR GL_RGBA, GL_BGRA,  GL_LUMINANCE, or GL_LUMINANCE_ALPHA.</p>
  
  <p>I would like to add a fragment shader that would swizzle my texture data into RGBA format when I map my texture into my output mesh.</p>
  
  <p>Since writing this app I've learned the basics of shaders from writing iOS apps for OpenGL ES 2, which does not support fixed pipeline OpenGL at all.</p>
  
  <p>I really don't want to rewrite the app to be fully shader based if I can help it. I'd like to implement an optional fragment shader that I can use to swizzle my pixel data for video sources when I need it, but continue to use the fixed pipeline for managing my projection matrix and model view matrix.</p>
  
  <p>How do you go about adding a shader to the (otherwise fixed) rendering pipeline? </p>