source: trunk/src/testing/include/appleMultiContext.h @ 4

Revision 4, 4.1 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module: appleMultiContext.h
5 * Author : Luc Renambot, Byungil Jeong
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 APPLE_MULTI_CONTEXT_H
48#define APPLE_MULTI_CONTEXT_H
49
50#if defined(__APPLE__)
51
52#include <ApplicationServices/ApplicationServices.h>
53#include <OpenGL/gl.h>   // Header File For The OpenGL Library
54#include <OpenGL/glu.h>   // Header File For The GLu Library
55#include <OpenGL/OpenGL.h>
56#include <AGL/agl.h>
57
58#include "displayContext.h"
59
60///////////////////////////
61// Define a playback window
62class Window {
63
64public:
65
66   Window(const Rect & rect, int fulls);
67
68   ~Window() {
69      aglDestroyContext(m_ctx);
70      DisposeWindow(m_win);
71   }
72
73   void clear() {
74      aglSetCurrentContext(m_ctx);
75
76      glClearColor(0,0,0,1);
77      glClear(GL_COLOR_BUFFER_BIT);
78
79      glFlush();
80
81      aglSwapBuffers(m_ctx);
82   }
83
84   void clearOpenGLData() {
85      m_init = false;
86   }
87
88   WindowRef theWindow() {
89      return m_win;
90   }
91
92   void beginGL() {
93      aglSetCurrentContext(m_ctx);
94      glClear(GL_COLOR_BUFFER_BIT);
95   }
96
97   void endGL() {
98      glFlush();
99      aglSwapBuffers(m_ctx);
100   }
101 
102   void contextSwitching() {
103      aglSetCurrentContext(m_ctx);
104   }
105
106protected:
107
108   // Carbon API window reference:
109   WindowRef m_win;
110
111   // Window geometry:
112   Rect m_rect;
113
114   // OpenGL context:
115   AGLContext m_ctx;
116
117   // OpenGL data:
118   bool m_init;
119};
120
121class appleMultiContext : public displayContext {
122protected:
123   Window *windows[MAX_TILES_PER_NODE];
124   
125public:
126   int init(struct sageDisplayConfig &cfg);   
127   void clearScreen() {}
128   void setupViewport(int i, sageRect &tileRect);
129   void refreshTile(int i) { windows[i]->endGL(); }
130   void refreshScreen() {}
131   void changeBackground(int red, int green, int blue);
132   void switchContext(int i) { windows[i]->contextSwitching(); }
133   void checkEvent();
134};
135
136#endif
137
138#endif
Note: See TracBrowser for help on using the repository browser.