1 /* 2 Copyright (C) 2003 Cedric Cellier, Dominique Lavault 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 #ifndef OPENGL_H 19 #define OPENGL_H 20 #ifdef _WINDOWS 21 #include <windows.h> 22 #include <glut.h> 23 #include <wglext.h> 24 #include <GL/gl.h> 25 #else 26 #ifdef __APPLE_CC__ 27 #include <GLUT/glut.h> 28 #include <GLUT/glx.h> 29 #include <OpenGL/gl.h> 30 #else 31 #include <GL/glut.h> 32 #include <GL/glx.h> 33 #include <GL/gl.h> 34 #endif 35 #endif 36 37 #ifndef GLAPIENTRY 38 #ifdef _WIN32 39 #define GLAPIENTRY __stdcall /* just in case */ 40 #else 41 #define GLAPIENTRY 42 #endif 43 #endif 44 45 /* Borrowed from http://www.west.net/~brittain/3dsmax2.htm#OpenGL 46 * 47 * This is an explication of how the KTX (Kinetix) extension works. 48 * 49 ****************************************************************** 50 51 The OpenGL extension described below, if present, will be used by MAX to implement dual planes 52 under OpenGL. As with all OpenGL extensions under Windows NT, the functions are imported into 53 MAX by calling wglGetProcAddress, and the functions themselves are implemented with the __stdcall 54 calling convention. The presence of this extension is indicated by the keyword "GL_KTX_buffer_region" 55 being present in the string returned by glGetString(GL_EXTENSIONS). 56 In an optimal implementation of this extension, the buffer regions are stored in video RAM so 57 that buffer data transfers do not have to cross the system bus. Note that no data in the backing 58 buffers is ever interpreted by MAX - it is just returned to the active image and/or Z 59 buffers later to restore a partially rendered scene without having to actually perform any rendering. 60 Thus, the buffered data should be kept in the native display card format without any translation. 61 62 GLuint glNewBufferRegion(GLenum type) 63 64 This function creates a new buffer region and returns a handle to it. The type parameter can be one 65 of GL_KTX_FRONT_REGION, GL_KTX_BACK_REGION, GL_KTX_Z_REGION or GL_KTX_STENCIL_REGION. 66 These symbols are defined in the MAX gfx.h header file, but they are simply mapped to 0 through 3 in the 67 order given above. Note that the storage of this region data is implementation specific and the pixel data 68 is not available to the client. 69 70 void glDeleteBufferRegion(GLuint region) 71 72 This function deletes a buffer region and any associated buffer data. 73 74 void glReadBufferRegion(GLuint region, GLint x, GLint y, GLsizei width, GLsizei height) 75 76 This function reads buffer data into a region specified by the given region handle. The type of 77 data read depends on the type of the region handle being used. All coordinates are window-based (with the 78 origin at the lower-left, as is common with OpenGL) and attempts to read areas that are clipped by the 79 window bounds fail silently. In MAX, x and y are always 0. 80 81 void glDrawBufferRegion(GLuint region, GLint x, GLint y, Glsizei width, GLsizei height, GLint xDest, GLint yDest) 82 83 This copies a rectangular region of data back to a display buffer. In other words, it moves previously saved 84 data from the specified region back to its originating buffer. The type of data drawn depends on the type of 85 the region handle being used. The rectangle specified by x, y, width, and height will always lie completely 86 within the rectangle specified by previous calls to glReadBufferRegion. This rectangle is to be placed back 87 into the display buffer at the location specified by xDest and yDest. Attempts to draw sub-regions outside the 88 area of the last buffer region read will fail (silently). In MAX, xDest and yDest are always equal to x and y, 89 respectively.) 90 91 GLuint glBufferRegionEnabled(void) 92 93 This routine returns 1 (TRUE) if MAX should use the buffer region extension, and 0 (FALSE) if MAX shouldn't. 94 This call is here so that if a single display driver supports a family of display cards with varying functionality 95 and onboard memory, the extension can be implemented yet only used if a given display card could benefit from 96 its use. In particular, if a given display card does not have enough memory to efficiently support the buffer 97 region extension, then this call should return FALSE. (Even for cards with lots of memory, whether or not to 98 enable the extension could be left up to the end-user through a configuration option available through a 99 manufacturer's addition to the Windows tabbed Display Properties dialog. Then, those users who like to have as 100 much video memory available for textures as possible could disable the option, or other users who work with large 101 scene databases but not lots of textures could explicitly enable the extension.) 102 103 Notes: Buffer region data is stored per window. Any context associated with the window can access the 104 buffer regions for that window. Buffer regions are cleaned up on deletion of the window. MAX uses the buffer 105 region calls to squirrel away complete copies of each viewport?s image and Z buffers. Then, when a rectangular 106 region of the screen must be updated because "foreground" objects have moved, that subregion is moved from 107 "storage" back to the image and Z buffers used for scene display. MAX then renders the objects that have moved 108 to complete the update of the viewport display. 109 110 */ 111 112 #ifndef GL_KTX_FRONT_REGION 113 #define GL_KTX_FRONT_REGION 0 114 #endif 115 #ifndef GL_KTX_BACK_REGION 116 #define GL_KTX_BACK_REGION 1 117 #endif 118 #ifndef GL_KTX_Z_REGION 119 #define GL_KTX_Z_REGION 2 120 #endif 121 #ifndef GL_KTX_STENCIL_REGION 122 #define GL_KTX_STENCIL_REGION 3 123 #endif 124 125 typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONPROC) (GLenum type); 126 typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONPROC) (GLuint region); 127 typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); 128 typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); 129 typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDPROC) (void); 130 131 #endif 132