src/video/bwindow/SDL_bopengl.cc
changeset 5918 2063df37190b
child 5919 e19c4c44f224
equal deleted inserted replaced
5917:cfd6c08e2326 5918:2063df37190b
       
     1 /*
       
     2   Simple DirectMedia Layer
       
     3   Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
       
     4 
       
     5   This software is provided 'as-is', without any express or implied
       
     6   warranty.  In no event will the authors be held liable for any damages
       
     7   arising from the use of this software.
       
     8 
       
     9   Permission is granted to anyone to use this software for any purpose,
       
    10   including commercial applications, and to alter it and redistribute it
       
    11   freely, subject to the following restrictions:
       
    12 
       
    13   1. The origin of this software must not be misrepresented; you must not
       
    14      claim that you wrote the original software. If you use this software
       
    15      in a product, an acknowledgment in the product documentation would be
       
    16      appreciated but is not required.
       
    17   2. Altered source versions must be plainly marked as such, and must not be
       
    18      misrepresented as being the original software.
       
    19   3. This notice may not be removed or altered from any source distribution.
       
    20 */
       
    21 
       
    22 #include "SDL_bopengl.h"
       
    23 #include "../SDL_sysvideo.h"
       
    24 
       
    25 
       
    26 /* Passing a NULL path means load pointers from the application */
       
    27 int BE_GL_LoadLibrary(_THIS, const char *path)
       
    28 {
       
    29 #if 0
       
    30 	if (path == NULL) {
       
    31 		if (_this->gl_config.dll_handle == NULL) {
       
    32 			image_info info;
       
    33 			int32 cookie = 0;
       
    34 			while (get_next_image_info(0, &cookie, &info) == B_OK) {
       
    35 				void *location = NULL;
       
    36 				if (get_image_symbol
       
    37 				((image_id) cookie, "glBegin",
       
    38 				B_SYMBOL_TYPE_ANY, &location) == B_OK) {
       
    39 					_this->gl_config.dll_handle = (void *) cookie;
       
    40 					_this->gl_config.driver_loaded = 1;
       
    41 					SDL_strlcpy(_this->gl_config.driver_path,
       
    42 					"libGL.so",
       
    43 					SDL_arraysize(_this->
       
    44 					gl_config.driver_path));
       
    45 				}
       
    46 			}
       
    47 		}
       
    48 	} else {
       
    49         /*
       
    50            FIXME None of BeOS libGL.so implementations have exported functions 
       
    51            to load BGLView, which should be reloaded from new lib.
       
    52            So for now just "load" linked libGL.so :(
       
    53         */
       
    54         if (_this->gl_config.dll_handle == NULL) {
       
    55         	return BE_GL_LoadLibrary(_this, NULL);
       
    56         }
       
    57 
       
    58             /* Unload old first */
       
    59             /*if (_this->gl_config.dll_handle != NULL) { */
       
    60             /* Do not try to unload application itself (if LoadLibrary was called before with NULL ;) */
       
    61             /*      image_info info;
       
    62                if (get_image_info((image_id)_this->gl_config.dll_handle, &info) == B_OK) {
       
    63                if (info.type != B_APP_IMAGE) {
       
    64                unload_add_on((image_id)_this->gl_config.dll_handle);
       
    65                }
       
    66                }
       
    67 
       
    68                }
       
    69 
       
    70                if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) {
       
    71                _this->gl_config.driver_loaded = 1;
       
    72                SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path));
       
    73                } */
       
    74 	}
       
    75 	
       
    76 	if (_this->gl_config.dll_handle != NULL) {
       
    77 		return 0;
       
    78 	} else {
       
    79 		_this->gl_config.dll_handle = NULL;
       
    80 		_this->gl_config.driver_loaded = 0;
       
    81 		*_this->gl_config.driver_path = '\0';
       
    82 		return -1;
       
    83 	}
       
    84 #endif
       
    85 }
       
    86 
       
    87 void *BE_GL_GetProcAddress(_THIS, const char *proc)
       
    88 {
       
    89 #if 0
       
    90 	if (_this->gl_config.dll_handle != NULL) {
       
    91 		void *location = NULL;
       
    92 		status_t err;
       
    93 		if ((err =
       
    94 			get_image_symbol((image_id) _this->gl_config.dll_handle,
       
    95                               proc, B_SYMBOL_TYPE_ANY,
       
    96                               &location)) == B_OK) {
       
    97             return location;
       
    98         } else {
       
    99                 SDL_SetError("Couldn't find OpenGL symbol");
       
   100                 return NULL;
       
   101         }
       
   102 	} else {
       
   103 		SDL_SetError("OpenGL library not loaded");
       
   104 		return NULL;
       
   105 	}
       
   106 #endif
       
   107 }
       
   108 
       
   109 
       
   110 
       
   111 
       
   112 int BE_GL_MakeCurrent(_THIS)
       
   113 {
       
   114 	/* FIXME: should we glview->unlock and then glview->lock()? */
       
   115 	return 0;
       
   116 }
       
   117 
       
   118 
       
   119 
       
   120 
       
   121 
       
   122 
       
   123 
       
   124 
       
   125 
       
   126 
       
   127 
       
   128 
       
   129 #if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
       
   130 
       
   131     int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
       
   132     {
       
   133         /*
       
   134            FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values
       
   135          */
       
   136         switch (attrib) {
       
   137         case SDL_GL_RED_SIZE:
       
   138             glGetIntegerv(GL_RED_BITS, (GLint *) value);
       
   139             break;
       
   140         case SDL_GL_GREEN_SIZE:
       
   141             glGetIntegerv(GL_GREEN_BITS, (GLint *) value);
       
   142             break;
       
   143         case SDL_GL_BLUE_SIZE:
       
   144             glGetIntegerv(GL_BLUE_BITS, (GLint *) value);
       
   145             break;
       
   146         case SDL_GL_ALPHA_SIZE:
       
   147             glGetIntegerv(GL_ALPHA_BITS, (GLint *) value);
       
   148             break;
       
   149         case SDL_GL_DOUBLEBUFFER:
       
   150             glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean *) value);
       
   151             break;
       
   152         case SDL_GL_BUFFER_SIZE:
       
   153             int v;
       
   154             glGetIntegerv(GL_RED_BITS, (GLint *) & v);
       
   155             *value = v;
       
   156             glGetIntegerv(GL_GREEN_BITS, (GLint *) & v);
       
   157             *value += v;
       
   158             glGetIntegerv(GL_BLUE_BITS, (GLint *) & v);
       
   159             *value += v;
       
   160             glGetIntegerv(GL_ALPHA_BITS, (GLint *) & v);
       
   161             *value += v;
       
   162             break;
       
   163         case SDL_GL_DEPTH_SIZE:
       
   164             glGetIntegerv(GL_DEPTH_BITS, (GLint *) value);      /* Mesa creates 16 only? r5 always 32 */
       
   165             break;
       
   166         case SDL_GL_STENCIL_SIZE:
       
   167             glGetIntegerv(GL_STENCIL_BITS, (GLint *) value);
       
   168             break;
       
   169         case SDL_GL_ACCUM_RED_SIZE:
       
   170             glGetIntegerv(GL_ACCUM_RED_BITS, (GLint *) value);
       
   171             break;
       
   172         case SDL_GL_ACCUM_GREEN_SIZE:
       
   173             glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint *) value);
       
   174             break;
       
   175         case SDL_GL_ACCUM_BLUE_SIZE:
       
   176             glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint *) value);
       
   177             break;
       
   178         case SDL_GL_ACCUM_ALPHA_SIZE:
       
   179             glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint *) value);
       
   180             break;
       
   181         case SDL_GL_STEREO:
       
   182         case SDL_GL_MULTISAMPLEBUFFERS:
       
   183         case SDL_GL_MULTISAMPLESAMPLES:
       
   184         default:
       
   185             *value = 0;
       
   186             return (-1);
       
   187         }
       
   188         return 0;
       
   189     }
       
   190 
       
   191     void BE_GL_SwapBuffers(_THIS)
       
   192     {
       
   193         SDL_Win->SwapBuffers();
       
   194     }
       
   195 #endif