1 /* 2 * Copyright (C) 2012 3 * Binocle <http://binocle.com/> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * Written by Olivier Letz <oletz@binocle.com>. 28 */ 29 30 #ifndef NVSDIOUT_H 31 #define NVSDIOUT_H 32 33 #include <GL/glew.h> 34 35 #if defined __cplusplus 36 extern "C" { 37 #endif 38 39 typedef struct _XDisplay Display; 40 41 typedef struct { 42 int video_format; 43 int data_format; 44 int sync_mode; 45 int sync_source; 46 //int fsaa; 47 int fql; 48 int xscreen; 49 } OutputOptions; 50 51 class CNvSDIout 52 { 53 private: 54 unsigned int* (*myGLXEnumerateVideoDevicesNV)(Display *dpy, int screen, int *nelements); 55 int (*myGLXBindVideoDeviceNV)(Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); 56 57 //X stuff 58 Display *_display; // Display 59 60 int m_videoWidth; // Video format resolution in pixels 61 int m_videoHeight; // Video format resolution in lines 62 63 OutputOptions m_outputOptions; 64 65 bool m_bInitialized; 66 67 GLuint _sdi_fbo; // framebuffer object to render into the sRGB texture 68 GLuint _sdi_tex[2]; // output: SRGB8 or linear RGB16 texture 69 70 71 public: 72 73 CNvSDIout(); 74 ~CNvSDIout(); 75 76 void init(int videoFormat); 77 void deinit(); 78 void reinit(int videoFormat); 79 80 void sendTextures(); 81 isInitialized()82 inline bool isInitialized() {return m_bInitialized; } 83 84 void startRenderingTo(int textureIndex); 85 void stopRenderingTo(); 86 width()87 int width() { return m_videoWidth; } height()88 int height() { return m_videoHeight; } 89 getOutputFormat()90 int getOutputFormat() { return m_outputOptions.video_format; } 91 92 private: 93 94 void setOutputOptions(Display *display, const OutputOptions &outputOptions); 95 bool initOutputDeviceNVCtrl(); 96 bool destroyOutputDeviceNVCtrl(); 97 }; 98 99 #if defined __cplusplus 100 } /* extern "C" */ 101 #endif 102 103 #endif 104