From: <tj...@us...> - 2010-08-28 08:20:59
|
Revision: 13664 http://alleg.svn.sourceforge.net/alleg/?rev=13664&view=rev Author: tjaden Date: 2010-08-28 08:20:53 +0000 (Sat, 28 Aug 2010) Log Message: ----------- Add al_set_current_opengl_context as an explicit way to set the OpenGL context. al_set_target_bitmap() is unusable for forward compatible OpenGL 3 contexts. Modified Paths: -------------- allegro/branches/4.9/docs/src/refman/opengl.txt allegro/branches/4.9/include/allegro5/allegro_opengl.h allegro/branches/4.9/src/opengl/ogl_display.c Modified: allegro/branches/4.9/docs/src/refman/opengl.txt =================================================================== --- allegro/branches/4.9/docs/src/refman/opengl.txt 2010-08-28 08:20:08 UTC (rev 13663) +++ allegro/branches/4.9/docs/src/refman/opengl.txt 2010-08-28 08:20:53 UTC (rev 13664) @@ -128,7 +128,19 @@ A valid OpenGL context must exist for this function to work, which means you may *not* call it before [al_create_display]. +## API: al_set_current_opengl_context +Make the OpenGL context associated with the given display current for the +calling thread. If there is a current target bitmap which belongs to a +different OpenGL context, the target bitmap will be changed to NULL. + +Normally you do not need to use this function, as the context will be made +current when you call [al_set_target_bitmap] or [al_set_target_backbuffer]. +You might need if it you created an OpenGL "forward compatible" context. +Then [al_get_backbuffer] only returns NULL, so it would not work to pass that +to [al_set_target_bitmap]. + + ## OpenGL configuration You can disable the detection of any OpenGL extension by Allegro with Modified: allegro/branches/4.9/include/allegro5/allegro_opengl.h =================================================================== --- allegro/branches/4.9/include/allegro5/allegro_opengl.h 2010-08-28 08:20:08 UTC (rev 13663) +++ allegro/branches/4.9/include/allegro5/allegro_opengl.h 2010-08-28 08:20:53 UTC (rev 13664) @@ -121,6 +121,7 @@ int *w, int *h)); AL_FUNC(void, al_get_opengl_texture_position, (ALLEGRO_BITMAP *bitmap, int *u, int *v)); +AL_FUNC(void, al_set_current_opengl_context, (ALLEGRO_DISPLAY *display)); #ifdef __cplusplus } Modified: allegro/branches/4.9/src/opengl/ogl_display.c =================================================================== --- allegro/branches/4.9/src/opengl/ogl_display.c 2010-08-28 08:20:08 UTC (rev 13663) +++ allegro/branches/4.9/src/opengl/ogl_display.c 2010-08-28 08:20:53 UTC (rev 13664) @@ -158,6 +158,26 @@ } +/* Function: al_set_current_opengl_context + */ +void al_set_current_opengl_context(ALLEGRO_DISPLAY *display) +{ + ASSERT(display); + + if (!(display->flags & ALLEGRO_OPENGL)) + return; + + if (display) { + ALLEGRO_BITMAP *bmp = al_get_target_bitmap(); + if (bmp && bmp->display && bmp->display != display) { + al_set_target_bitmap(NULL); + } + } + + _al_set_current_display_only(display); +} + + void _al_ogl_setup_bitmap_clipping(const ALLEGRO_BITMAP *bitmap) { int x_1, y_1, x_2, y_2, h; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |