[4] | 1 | /****************************************************************************** |
---|
| 2 | * SAGE - Scalable Adaptive Graphics Environment |
---|
| 3 | * |
---|
| 4 | * Module: sageDisplay.h |
---|
| 5 | * Author : Byungil Jeong, Rajvikram Singh |
---|
| 6 | * |
---|
| 7 | * Description: This is the header file for the video display module of SAGE. |
---|
| 8 | * |
---|
| 9 | * Notes : Since the display window may receive its many pieces from many servers, we need to pass multiple buffers |
---|
| 10 | * to this class. Each of the buffers passed contains a frame which forms a part (or whole) of the image on |
---|
| 11 | * the display side. |
---|
| 12 | * |
---|
| 13 | * Copyright (C) 2007 Electronic Visualization Laboratory, |
---|
| 14 | * University of Illinois at Chicago |
---|
| 15 | * |
---|
| 16 | * All rights reserved. |
---|
| 17 | * |
---|
| 18 | * Redistribution and use in source and binary forms, with or without |
---|
| 19 | * modification, are permitted provided that the following conditions are met: |
---|
| 20 | * |
---|
| 21 | * * Redistributions of source code must retain the above copyright |
---|
| 22 | * notice, this list of conditions and the following disclaimer. |
---|
| 23 | * * Redistributions in binary form must reproduce the above |
---|
| 24 | * copyright notice, this list of conditions and the following disclaimer |
---|
| 25 | * in the documentation and/or other materials provided with the distribution. |
---|
| 26 | * * Neither the name of the University of Illinois at Chicago nor |
---|
| 27 | * the names of its contributors may be used to endorse or promote |
---|
| 28 | * products derived from this software without specific prior written permission. |
---|
| 29 | * |
---|
| 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 31 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 32 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
| 33 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
| 34 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
| 35 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 36 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
| 37 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
| 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
| 39 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
| 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 41 | * |
---|
| 42 | * Direct questions, comments etc about SAGE to sage_users@listserv.uic.edu or |
---|
| 43 | * http://www.evl.uic.edu/cavern/forum/ |
---|
| 44 | * |
---|
| 45 | ***************************************************************************************************************************/ |
---|
| 46 | |
---|
| 47 | #ifndef SAGE_DISPLAY_H |
---|
| 48 | #define SAGE_DISPLAY_H |
---|
| 49 | |
---|
| 50 | #ifndef GL_ABGR_EXT |
---|
| 51 | # define GL_ABGR_EXT 0x8000 |
---|
| 52 | #endif |
---|
| 53 | #ifndef GL_BGR |
---|
| 54 | # define GL_BGR 0x80E0 |
---|
| 55 | #endif |
---|
| 56 | #ifndef GL_BGRA |
---|
| 57 | # define GL_BGRA 0x80E1 |
---|
| 58 | #endif |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | #ifndef GL_UNSIGNED_SHORT_5_6_5 |
---|
| 62 | # define GL_UNSIGNED_SHORT_5_6_5 0x8363 |
---|
| 63 | #endif |
---|
| 64 | |
---|
| 65 | // awf: more (similar) defines for win32... |
---|
| 66 | #ifndef GL_UNSIGNED_SHORT_5_5_5_1 |
---|
| 67 | # define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 |
---|
| 68 | #endif |
---|
| 69 | #ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV |
---|
| 70 | # define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8066 |
---|
| 71 | #endif |
---|
| 72 | |
---|
| 73 | #include "displayContext.h" |
---|
| 74 | #include "sageDraw.h" |
---|
| 75 | #include "sagePixelType.h" |
---|
| 76 | #include "sageSharedData.h" |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | #define MAX_MONTAGE_NUM 100 |
---|
| 81 | |
---|
| 82 | class sageBlock; |
---|
| 83 | class sagePixelBlock; |
---|
| 84 | |
---|
| 85 | // The following structure holds the parameters of the montage comprising the final window |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * This holds the parameters of the montage comprising the final window |
---|
| 89 | */ |
---|
| 90 | class sageMontage : public sageRect { |
---|
| 91 | private: |
---|
| 92 | displayContext *context; |
---|
| 93 | sagePixelType pInfo; |
---|
| 94 | |
---|
| 95 | int texWidth, texHeight; // current texture size for this montage |
---|
| 96 | //bool validTexCoord; |
---|
| 97 | //sageRect imgInfo; |
---|
| 98 | sageRect texInfo; |
---|
| 99 | |
---|
| 100 | GLubyte *texture; |
---|
| 101 | |
---|
| 102 | public: |
---|
| 103 | int texHandle; |
---|
| 104 | sageRect texCoord; |
---|
| 105 | sagePixFmt pixelType; |
---|
| 106 | float depth; |
---|
| 107 | int monIdx; |
---|
| 108 | int tileIdx; |
---|
| 109 | bool visible; |
---|
| 110 | //int id; |
---|
| 111 | |
---|
| 112 | sageMontage(displayContext *dct, sagePixFmt pfmt); |
---|
| 113 | |
---|
| 114 | int init(sageRect &viewPort, sageRect &blockLayout, |
---|
| 115 | sageRotation orientation); |
---|
| 116 | int copyConfig(sageMontage &mon); |
---|
| 117 | bool checkDispInfo(sagePixelBlock *block); |
---|
| 118 | int renewTexture(); |
---|
| 119 | int deleteTexture(); |
---|
| 120 | bool genTexCoord(); |
---|
| 121 | int loadPixelBlock(sagePixelBlock *block); // load a pixel block into texture memory |
---|
| 122 | |
---|
| 123 | //inline void getImageOrg(int &x, int &y) { x = imgInfo.x, y = imgInfo.y; } |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * \brief The video display module of SAGE. |
---|
| 128 | * |
---|
| 129 | * This class is for drawing pixel data onto screen, and all OpenGL related codes are here |
---|
| 130 | * |
---|
| 131 | * Since the display window may receive its many pieces from many servers, we need to pass multiple buffers to this class. |
---|
| 132 | * Each of the buffers passed contains a frame which forms a part (or whole) of the image on the display side. |
---|
| 133 | */ |
---|
| 134 | class sageDisplay { |
---|
| 135 | protected: |
---|
| 136 | displayContext *context; |
---|
| 137 | sageDisplayConfig configStruct; |
---|
| 138 | |
---|
| 139 | sageMontage* montages[MAX_TILES_PER_NODE][MAX_MONTAGE_NUM]; |
---|
| 140 | int noOfMontages[MAX_TILES_PER_NODE]; |
---|
| 141 | |
---|
| 142 | int tileNum; |
---|
| 143 | bool dirty; |
---|
| 144 | sageDraw drawObj; |
---|
| 145 | |
---|
| 146 | public: |
---|
| 147 | sageDisplay(displayContext *dct, struct sageDisplayConfig &cfg); |
---|
| 148 | int addMontage(sageMontage *mon); // register a new montage into the montage list |
---|
| 149 | int replaceMontage(sageMontage *mon); // replace the current montage by another montage |
---|
| 150 | int removeMontage(sageMontage *mon); // delete montage from the montage list |
---|
| 151 | int updateScreen(dispSharedData *shared=NULL, bool barrierFlag=false); /**< draw montages onto screen */ |
---|
| 152 | int changeBGColor(int red, int green, int blue); |
---|
| 153 | |
---|
| 154 | int addDrawObjectInstance(char *data); |
---|
| 155 | int updateObjectPosition(char *data); |
---|
| 156 | int removeDrawObject(char *data); |
---|
| 157 | int forwardObjectMessage(char *data); |
---|
| 158 | int showObject(char *data); |
---|
| 159 | |
---|
| 160 | inline void setDirty() { dirty = true; } |
---|
| 161 | inline bool isDirty() { return dirty; } |
---|
| 162 | inline sageRect& getTileRect(int idx) { return configStruct.tileRect[idx]; } |
---|
| 163 | inline int getTileNum() { return tileNum; } |
---|
| 164 | // int setupWinBorders(char *info); |
---|
| 165 | // int drawWinBorders(); |
---|
| 166 | // int updateWinBorders(char *info); |
---|
| 167 | // int updateWinDepth(int appID, float depth, float titleOffset); |
---|
| 168 | // int deleteWinBorders(int appID); |
---|
| 169 | |
---|
| 170 | ~sageDisplay(); |
---|
| 171 | }; |
---|
| 172 | |
---|
| 173 | #endif |
---|