src/video/haiku/SDL_bopengl.cc
changeset 10690 23a825f341e6
parent 9998 f67cf37e9cd4
child 10737 3406a0f8b041
equal deleted inserted replaced
10689:69d6c1c7a2bf 10690:23a825f341e6
    36 
    36 
    37 
    37 
    38 #define BGL_FLAGS BGL_RGB | BGL_DOUBLE
    38 #define BGL_FLAGS BGL_RGB | BGL_DOUBLE
    39 
    39 
    40 static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
    40 static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
    41 	return ((SDL_BWin*)(window->driverdata));
    41     return ((SDL_BWin*)(window->driverdata));
    42 }
    42 }
    43 
    43 
    44 static SDL_INLINE SDL_BApp *_GetBeApp() {
    44 static SDL_INLINE SDL_BApp *_GetBeApp() {
    45 	return ((SDL_BApp*)be_app);
    45     return ((SDL_BApp*)be_app);
    46 }
    46 }
    47 
    47 
    48 /* Passing a NULL path means load pointers from the application */
    48 /* Passing a NULL path means load pointers from the application */
    49 int BE_GL_LoadLibrary(_THIS, const char *path)
    49 int BE_GL_LoadLibrary(_THIS, const char *path)
    50 {
    50 {
    51 /* FIXME: Is this working correctly? */
    51 /* FIXME: Is this working correctly? */
    52 	image_info info;
    52     image_info info;
    53 			int32 cookie = 0;
    53             int32 cookie = 0;
    54 	while (get_next_image_info(0, &cookie, &info) == B_OK) {
    54     while (get_next_image_info(0, &cookie, &info) == B_OK) {
    55 		void *location = NULL;
    55         void *location = NULL;
    56 		if( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY,
    56         if( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY,
    57 				&location) == B_OK) {
    57                 &location) == B_OK) {
    58 
    58 
    59 			_this->gl_config.dll_handle = (void *) info.id;
    59             _this->gl_config.dll_handle = (void *) info.id;
    60 			_this->gl_config.driver_loaded = 1;
    60             _this->gl_config.driver_loaded = 1;
    61 			SDL_strlcpy(_this->gl_config.driver_path, "libGL.so",
    61             SDL_strlcpy(_this->gl_config.driver_path, "libGL.so",
    62 					SDL_arraysize(_this->gl_config.driver_path));
    62                     SDL_arraysize(_this->gl_config.driver_path));
    63 		}
    63         }
    64 	}
    64     }
    65 	return 0;
    65     return 0;
    66 }
    66 }
    67 
    67 
    68 void *BE_GL_GetProcAddress(_THIS, const char *proc)
    68 void *BE_GL_GetProcAddress(_THIS, const char *proc)
    69 {
    69 {
    70 	if (_this->gl_config.dll_handle != NULL) {
    70     if (_this->gl_config.dll_handle != NULL) {
    71 		void *location = NULL;
    71         void *location = NULL;
    72 		status_t err;
    72         status_t err;
    73 		if ((err =
    73         if ((err =
    74 			get_image_symbol((image_id) _this->gl_config.dll_handle,
    74             get_image_symbol((image_id) _this->gl_config.dll_handle,
    75                               proc, B_SYMBOL_TYPE_ANY,
    75                               proc, B_SYMBOL_TYPE_ANY,
    76                               &location)) == B_OK) {
    76                               &location)) == B_OK) {
    77             return location;
    77             return location;
    78         } else {
    78         } else {
    79                 SDL_SetError("Couldn't find OpenGL symbol");
    79                 SDL_SetError("Couldn't find OpenGL symbol");
    80                 return NULL;
    80                 return NULL;
    81         }
    81         }
    82 	} else {
    82     } else {
    83 		SDL_SetError("OpenGL library not loaded");
    83         SDL_SetError("OpenGL library not loaded");
    84 		return NULL;
    84         return NULL;
    85 	}
    85     }
    86 }
    86 }
    87 
    87 
    88 
    88 
    89 
    89 
    90 
    90 
    91 void BE_GL_SwapWindow(_THIS, SDL_Window * window) {
    91 int BE_GL_SwapWindow(_THIS, SDL_Window * window) {
    92     _ToBeWin(window)->SwapBuffers();
    92     _ToBeWin(window)->SwapBuffers();
       
    93     return 0;
    93 }
    94 }
    94 
    95 
    95 int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
    96 int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
    96 	_GetBeApp()->SetCurrentContext(((SDL_BWin*)context)->GetGLView());
    97     _GetBeApp()->SetCurrentContext(((SDL_BWin*)context)->GetGLView());
    97 	return 0;
    98     return 0;
    98 }
    99 }
    99 
   100 
   100 
   101 
   101 SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
   102 SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
   102 	/* FIXME: Not sure what flags should be included here; may want to have
   103     /* FIXME: Not sure what flags should be included here; may want to have
   103 	   most of them */
   104        most of them */
   104 	SDL_BWin *bwin = _ToBeWin(window);
   105     SDL_BWin *bwin = _ToBeWin(window);
   105 	bwin->CreateGLView(BGL_FLAGS);
   106     bwin->CreateGLView(BGL_FLAGS);
   106 	return (SDL_GLContext)(bwin);
   107     return (SDL_GLContext)(bwin);
   107 }
   108 }
   108 
   109 
   109 void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
   110 void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
   110 	/* Currently, automatically unlocks the view */
   111     /* Currently, automatically unlocks the view */
   111 	((SDL_BWin*)context)->RemoveGLView();
   112     ((SDL_BWin*)context)->RemoveGLView();
   112 }
   113 }
   113 
   114 
   114 
   115 
   115 int BE_GL_SetSwapInterval(_THIS, int interval) {
   116 int BE_GL_SetSwapInterval(_THIS, int interval) {
   116 	/* TODO: Implement this, if necessary? */
   117     /* TODO: Implement this, if necessary? */
   117 	return 0;
   118     return 0;
   118 }
   119 }
   119 
   120 
   120 int BE_GL_GetSwapInterval(_THIS) {
   121 int BE_GL_GetSwapInterval(_THIS) {
   121 	/* TODO: Implement this, if necessary? */
   122     /* TODO: Implement this, if necessary? */
   122 	return 0;
   123     return 0;
   123 }
   124 }
   124 
   125 
   125 
   126 
   126 void BE_GL_UnloadLibrary(_THIS) {
   127 void BE_GL_UnloadLibrary(_THIS) {
   127 	/* TODO: Implement this, if necessary? */
   128     /* TODO: Implement this, if necessary? */
   128 }
   129 }
   129 
   130 
   130 
   131 
   131 /* FIXME: This function is meant to clear the OpenGL context when the video
   132 /* FIXME: This function is meant to clear the OpenGL context when the video
   132    mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not
   133    mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not
   133    currently in use. */
   134    currently in use. */
   134 void BE_GL_RebootContexts(_THIS) {
   135 void BE_GL_RebootContexts(_THIS) {
   135 	SDL_Window *window = _this->windows;
   136     SDL_Window *window = _this->windows;
   136 	while(window) {
   137     while(window) {
   137 		SDL_BWin *bwin = _ToBeWin(window);
   138         SDL_BWin *bwin = _ToBeWin(window);
   138 		if(bwin->GetGLView()) {
   139         if(bwin->GetGLView()) {
   139 			bwin->LockLooper();
   140             bwin->LockLooper();
   140 			bwin->RemoveGLView();
   141             bwin->RemoveGLView();
   141 			bwin->CreateGLView(BGL_FLAGS);
   142             bwin->CreateGLView(BGL_FLAGS);
   142 			bwin->UnlockLooper();
   143             bwin->UnlockLooper();
   143 		}
   144         }
   144 		window = window->next;
   145         window = window->next;
   145 	}
   146     }
   146 }
   147 }
   147 
   148 
   148 
   149 
   149 #if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
   150 #if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
   150 
   151 
   215 #ifdef __cplusplus
   216 #ifdef __cplusplus
   216 }
   217 }
   217 #endif
   218 #endif
   218 
   219 
   219 #endif /* SDL_VIDEO_DRIVER_HAIKU */
   220 #endif /* SDL_VIDEO_DRIVER_HAIKU */
       
   221 
       
   222 /* vi: set ts=4 sw=4 expandtab: */