Previous 199869 Revisions Next

r35267 Wednesday 25th February, 2015 at 22:44:17 UTC by Couriersud
Enable OpenGL renderer on Windows. By default, run-time function
resolution is enabled.
To resolve addresses, the code now first tries GetProcAddress followed
by wglGetProcAddress. [Couriersud]
[src/lib/util]coretmpl.h
[src/osd/sdl]drawogl.c gl_shader_mgr.c gl_shader_mgr.h gl_shader_tool.c gl_shader_tool.h osd_opengl.h sdl.mak video.c
[src/osd/windows]windows.mak

trunk/src/lib/util/coretmpl.h
r243778r243779
127127      global_free_array(oldarray);
128128   }
129129
130#ifdef __GNUC__
130#if defined(__GNUC__) && !defined(SDLMAME_MACOSX)
131131   void clear_internal(UINT32 start, UINT32 count, UINT8 data) { assert(__is_pod(_ElementType)); memset((void *)&m_array[start], data, count * sizeof(*m_array)); }
132132#else
133133   void clear_internal(UINT32 start, UINT32 count, UINT8 data) { memset(&m_array[start], data, count * sizeof(*m_array)); }
trunk/src/osd/sdl/drawogl.c
r243778r243779
2727// standard SDL headers
2828#define TOBEMIGRATED 1
2929#include "sdlinc.h"
30#else
31#define SDLMAME_SDL2 1
32#include "GL/gl.h"
33#include "GL/glext.h"
34#include "GL/wglext.h"
35
36typedef HGLRC SDL_GLContext;
3730#endif
3831
3932// OpenGL headers
40#ifndef OSD_WINDOWS
4133#include "osd_opengl.h"
34
35#ifdef OSD_WINDOWS
36#define SDLMAME_SDL2 1
37#ifndef USE_DISPATCH_GL
38#include "GL/wglext.h"
4239#endif
40#endif
41
4342#include "modules/lib/osdlib.h"
43#include "modules/lib/osdobj_common.h"
4444
4545
4646#include "gl_shader_tool.h"
r243778r243779
193193//  TYPES
194194//============================================================
195195
196#if (SDLMAME_SDL2)
197
198#ifdef OSD_WINDOWS
199class win_gl_context : public osd_gl_context
200{
201public:
202   win_gl_context(HWND window) : osd_gl_context(), m_context(0), m_window(NULL), m_hdc(0)
203   {
204      m_error[0] = 0;
205
206      this->wglGetProcAddress = (PROC WINAPI (*)(LPCSTR lpszProc)) GetProcAddress(m_module, "wglGetProcAddress");
207      this->wglCreateContext = (HGLRC WINAPI (*)(HDC hdc)) GetProcAddress(m_module, "wglCreateContext");
208      this->wglDeleteContext = (BOOL WINAPI (*)(HGLRC hglrc)) GetProcAddress(m_module, "wglDeleteContext");
209      this->wglMakeCurrent = (BOOL WINAPI (*)(HDC hdc, HGLRC hglrc)) GetProcAddress(m_module, "wglMakeCurrent");
210
211      m_hdc = GetDC(window);
212      if (!setupPixelFormat(m_hdc))
213      {
214         m_context = wglCreateContext(m_hdc);
215         if  (!m_context)
216         {
217            FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, m_error, 255, NULL);
218            return;
219         }
220         wglMakeCurrent(m_hdc, m_context);
221      }
222   }
223
224   virtual ~win_gl_context()
225   {
226      wglDeleteContext(m_context);
227      ReleaseDC(m_window, m_hdc);
228   }
229
230   virtual void MakeCurrent()
231   {
232      wglMakeCurrent(m_hdc, m_context);
233   }
234
235   virtual const char *LastErrorMsg()
236   {
237      if (m_error[0] == 0)
238         return NULL;
239      else
240         return m_error;
241   }
242
243   virtual void *getProcAddress(const char *proc)
244   {
245      void *ret = (void *) GetProcAddress(m_module, proc);
246      if (ret == NULL)
247         ret = (void *) wglGetProcAddress(proc);
248      return ret;
249   }
250
251   virtual int SetSwapInterval(const int swap)
252   {
253      // FIXME: Missing!
254      return 0;
255   }
256
257   virtual void SwapBuffer()
258   {
259      SwapBuffers(m_hdc);
260      //wglSwapLayerBuffers(GetDC(window().m_hwnd), WGL_SWAP_MAIN_PLANE);
261   }
262
263   static void load_library()
264   {
265      m_module = LoadLibraryA("opengl32.dll");
266   }
267
268private:
269
270   int setupPixelFormat(HDC hDC)
271   {
272       PIXELFORMATDESCRIPTOR pfd = {
273           sizeof(PIXELFORMATDESCRIPTOR),  /* size */
274           1,                              /* version */
275           PFD_SUPPORT_OPENGL |
276           PFD_DRAW_TO_WINDOW |
277           PFD_DOUBLEBUFFER,               /* support double-buffering */
278           PFD_TYPE_RGBA,                  /* color type */
279           32,                             /* prefered color depth */
280           0, 0, 0, 0, 0, 0,               /* color bits (ignored) */
281           0,                              /* no alpha buffer */
282           0,                              /* alpha bits (ignored) */
283           0,                              /* no accumulation buffer */
284           0, 0, 0, 0,                     /* accum bits (ignored) */
285           16,                             /* depth buffer */
286           0,                              /* no stencil buffer */
287           0,                              /* no auxiliary buffers */
288           PFD_MAIN_PLANE,                 /* main layer */
289           0,                              /* reserved */
290           0, 0, 0,                        /* no layer, visible, damage masks */
291       };
292       int pixelFormat;
293
294       pixelFormat = ChoosePixelFormat(hDC, &pfd);
295       if (pixelFormat == 0) {
296           strcpy(m_error, "ChoosePixelFormat failed");
297           return 1;
298       }
299
300       if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) {
301           strcpy(m_error, "SetPixelFormat failed.");
302           return 1;
303       }
304       return 0;
305   }
306
307
308   HGLRC m_context;
309   HWND m_window;
310   HDC m_hdc;
311   char m_error[256];
312
313   PROC WINAPI (*wglGetProcAddress)(LPCSTR lpszProc);
314   HGLRC WINAPI (*wglCreateContext)(HDC hdc);
315   BOOL WINAPI (*wglDeleteContext)(HGLRC hglrc);
316   BOOL WINAPI (*wglMakeCurrent)(HDC hdc, HGLRC hglrc);
317
318   static HMODULE m_module;
319};
320
321HMODULE win_gl_context::m_module;
322
323
324#else
325class sdl_gl_context : public osd_gl_context
326{
327public:
328   sdl_gl_context(SDL_Window *window) : osd_gl_context(), m_context(0), m_window(window)
329   {
330      m_error[0] = 0;
331      m_context = SDL_GL_CreateContext(window);
332      if  (!m_context)
333      {
334         snprintf(m_error,255, "OpenGL not supported on this driver: %s", SDL_GetError());
335      }
336   }
337   virtual ~sdl_gl_context()
338   {
339      SDL_GL_DeleteContext(m_context);
340   }
341   virtual void MakeCurrent()
342   {
343      SDL_GL_MakeCurrent(m_window, m_context);
344   }
345
346   virtual int SetSwapInterval(const int swap)
347   {
348      return SDL_GL_SetSwapInterval(swap);
349   }
350
351   virtual const char *LastErrorMsg()
352   {
353      if (m_error[0] == 0)
354         return NULL;
355      else
356         return m_error;
357   }
358   virtual void *getProcAddress(const char *proc)
359   {
360      return SDL_GL_GetProcAddress(proc);
361   }
362
363   virtual void SwapBuffer()
364   {
365      SDL_GL_SwapWindow(m_window);
366   }
367
368private:
369   SDL_GLContext m_context;
370   SDL_Window *m_window;
371   char m_error[256];
372};
373#endif
374#else
375// SDL 1.2
376class sdl12_gl_context : public osd_gl_context
377{
378public:
379   sdl12_gl_context(SDL_Surface *window) : osd_gl_context(), m_window(window)
380   {
381      m_error[0] = 0;
382   }
383   virtual ~sdl12_gl_context()
384   {
385   }
386   virtual void MakeCurrent()
387   {
388   }
389
390   virtual int SetSwapInterval(const int swap)
391   {
392      // Not supported on 1.2
393      return 0;
394   }
395
396   virtual const char *LastErrorMsg()
397   {
398      if (m_error[0] == 0)
399         return NULL;
400      else
401         return m_error;
402   }
403
404   virtual void *getProcAddress(const char *proc)
405   {
406      return SDL_GL_GetProcAddress(proc);
407   }
408
409   virtual void SwapBuffer()
410   {
411      SDL_GL_SwapBuffers();
412   }
413
414private:
415   SDL_Surface *m_window;
416   char m_error[256];
417};
418
419
420#endif
421
196422//============================================================
197423//  Textures
198424//============================================================
r243778r243779
262488   : osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0),
263489      m_width(0), m_height(0),
264490      m_blitwidth(0), m_blitheight(0),
265#if (SDLMAME_SDL2)
266      m_gl_context_id(0),
267#else
268#endif
491      m_gl_context(NULL),
269492      m_initialized(0),
270493      m_last_blendmode(0),
271494      m_texture_max_width(0),
r243778r243779
342565   int             m_blitwidth;
343566   int             m_blitheight;
344567
345#if (SDLMAME_SDL2)
346   SDL_GLContext   m_gl_context_id;
347#ifdef OSD_WINDOWS
348   HDC             m_hdc;
349#endif
350#else
351#endif
568   osd_gl_context   *m_gl_context;
352569
353570   int             m_initialized;        // is everything well initialized, i.e. all GL stuff etc.
354571   // 3D info (GL mode only)
r243778r243779
533750}
534751
535752//============================================================
536// Windows Compatibility
537//============================================================
538
539#ifdef OSD_WINDOWS
540PROC SDL_GL_GetProcAddress(const char *procname)
541{
542   return wglGetProcAddress(procname);
543}
544#endif
545
546//============================================================
547753// Load the OGL function addresses
548754//============================================================
549755
550static void loadgl_functions(void)
756static void loadgl_functions(osd_gl_context *context)
551757{
552758#ifdef USE_DISPATCH_GL
553759
r243778r243779
558764    */
559765
560766   #define OSD_GL(ret,func,params) \
561   if (!( func = (ret (APIENTRY *)params) SDL_GL_GetProcAddress( #func ) )) \
767   if (!( func = (ret (APIENTRY *)params) context->getProcAddress( #func ) )) \
562768      { err_count++; osd_printf_error("GL function %s not found!\n", #func ); }
563769
564770   #define OSD_GL_UNUSED(ret,func,params)
r243778r243779
577783// Load GL library
578784//============================================================
579785
786#ifdef USE_DISPATCH_GL
787osd_gl_dispatch *gl_dispatch;
788#endif
789
580790static void load_gl_lib(running_machine &machine)
581791{
582#ifdef USE_DISPATCH_GL
583792   if (!dll_loaded)
584793   {
794#ifdef OSD_WINDOWS
795      win_gl_context::load_library();
796#else
797#ifdef USE_DISPATCH_GL
585798      /*
586799       *  directfb and and x11 use this env var
587800       *   SDL_VIDEO_GL_DRIVER
r243778r243779
598811      }
599812      osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>");
600813      /* FIXME: must be freed as well */
814#endif
815#endif
601816      gl_dispatch = (osd_gl_dispatch *) osd_malloc(sizeof(osd_gl_dispatch));
602817      dll_loaded=1;
603818   }
604#endif
605819}
606820
607821void sdl_info_ogl::initialize_gl()
r243778r243779
7881002// a
7891003//============================================================
7901004
791#ifdef OSD_WINDOWS
792void
793setupPixelFormat(HDC hDC)
794{
795   PIXELFORMATDESCRIPTOR pfd = {
796      sizeof(PIXELFORMATDESCRIPTOR),  /* size */
797      1,                              /* version */
798      PFD_SUPPORT_OPENGL |
799      PFD_DRAW_TO_WINDOW |
800      PFD_DOUBLEBUFFER,               /* support double-buffering */
801      PFD_TYPE_RGBA,                  /* color type */
802      32,                             /* prefered color depth */
803      0, 0, 0, 0, 0, 0,               /* color bits (ignored) */
804      0,                              /* no alpha buffer */
805      0,                              /* alpha bits (ignored) */
806      0,                              /* no accumulation buffer */
807      0, 0, 0, 0,                     /* accum bits (ignored) */
808      16,                             /* depth buffer */
809      0,                              /* no stencil buffer */
810      0,                              /* no auxiliary buffers */
811      PFD_MAIN_PLANE,                 /* main layer */
812      0,                              /* reserved */
813      0, 0, 0,                        /* no layer, visible, damage masks */
814   };
815   int pixelFormat;
816
817   pixelFormat = ChoosePixelFormat(hDC, &pfd);
818   if (pixelFormat == 0) {
819      osd_printf_error("ChoosePixelFormat failed.\n");
820      exit(1);
821   }
822
823   if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) {
824      osd_printf_error("SetPixelFormat failed.\n");
825      exit(1);
826   }
827}
828#endif
8291005int sdl_info_ogl::create()
8301006{
8311007#if (SDLMAME_SDL2)
8321008   // create renderer
8331009#ifdef OSD_WINDOWS
834   m_hdc = GetDC(window().m_hwnd);
835   setupPixelFormat(m_hdc);
836   m_gl_context_id = wglCreateContext(m_hdc);
837   if  (!m_gl_context_id)
838   {
839      char errorStr[1024];
840      FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, errorStr, 255, NULL);
841      osd_printf_error("OpenGL not supported on this driver %s\n", errorStr);
842      return 1;
843   }
844   wglMakeCurrent(m_hdc, m_gl_context_id);
1010   m_gl_context = global_alloc(win_gl_context(window().m_hwnd));
8451011#else
846   m_gl_context_id = SDL_GL_CreateContext(window().sdl_window());
847   if  (!m_gl_context_id)
1012   m_gl_context = global_alloc(sdl_gl_context(window().sdl_window()));
1013#endif
1014#else
1015   m_gl_context = global_alloc(sdl12_gl_context(window().sdl_surface()));
1016#endif
1017   if  (m_gl_context->LastErrorMsg() != NULL)
8481018   {
849      osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
1019      osd_printf_error("%s\n", m_gl_context->LastErrorMsg());
8501020      return 1;
8511021   }
852#endif
1022   m_gl_context->SetSwapInterval(video_config.waitvsync ? 1 : 0);
8531023
854#ifndef OSD_WINDOWS
855   SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0);
856#endif
857#else
858#endif
8591024
8601025   m_blittimer = 0;
8611026   m_surf_w = 0;
r243778r243779
8711036   /* load any GL function addresses
8721037    * this must be done here because we need a context
8731038    */
874   loadgl_functions();
1039   loadgl_functions(m_gl_context);
8751040   initialize_gl();
8761041
8771042
r243778r243779
8921057
8931058   destroy_all_textures();
8941059
895#if (SDLMAME_SDL2)
896#ifdef OSD_WINDOWS
897   wglDeleteContext(m_gl_context_id);
898   ReleaseDC(window().m_hwnd, m_hdc);
899#else
900   SDL_GL_DeleteContext(m_gl_context_id);
901#endif
902#endif
903
1060   global_free(m_gl_context);
1061   m_gl_context = NULL;
9041062}
9051063
9061064
r243778r243779
9321090   if ( !m_initialized )
9331091      return;
9341092
935#if (SDLMAME_SDL2)
936#ifdef OSD_WINDOWS
937   wglMakeCurrent(m_hdc, m_gl_context_id);
938#else
939   SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
940#endif
941#endif
1093   m_gl_context->MakeCurrent();
9421094
9431095   if(window().m_primlist)
9441096   {
r243778r243779
10431195   // VBO:
10441196   if( m_usevbo )
10451197   {
1046      pfn_glGenBuffers = (PFNGLGENBUFFERSPROC) SDL_GL_GetProcAddress("glGenBuffers");
1047      pfn_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) SDL_GL_GetProcAddress("glDeleteBuffers");
1048      pfn_glBindBuffer = (PFNGLBINDBUFFERPROC) SDL_GL_GetProcAddress("glBindBuffer");
1049      pfn_glBufferData = (PFNGLBUFFERDATAPROC) SDL_GL_GetProcAddress("glBufferData");
1050      pfn_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) SDL_GL_GetProcAddress("glBufferSubData");
1198      pfn_glGenBuffers = (PFNGLGENBUFFERSPROC) m_gl_context->getProcAddress("glGenBuffers");
1199      pfn_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) m_gl_context->getProcAddress("glDeleteBuffers");
1200      pfn_glBindBuffer = (PFNGLBINDBUFFERPROC) m_gl_context->getProcAddress("glBindBuffer");
1201      pfn_glBufferData = (PFNGLBUFFERDATAPROC) m_gl_context->getProcAddress("glBufferData");
1202      pfn_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) m_gl_context->getProcAddress("glBufferSubData");
10511203   }
10521204   // PBO:
10531205   if ( m_usepbo )
10541206   {
1055      pfn_glMapBuffer  = (PFNGLMAPBUFFERPROC) SDL_GL_GetProcAddress("glMapBuffer");
1056      pfn_glUnmapBuffer= (PFNGLUNMAPBUFFERPROC) SDL_GL_GetProcAddress("glUnmapBuffer");
1207      pfn_glMapBuffer  = (PFNGLMAPBUFFERPROC) m_gl_context->getProcAddress("glMapBuffer");
1208      pfn_glUnmapBuffer= (PFNGLUNMAPBUFFERPROC) m_gl_context->getProcAddress("glUnmapBuffer");
10571209   }
10581210   // FBO:
10591211   if ( m_usefbo )
10601212   {
1061      pfn_glIsFramebuffer = (PFNGLISFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glIsFramebufferEXT");
1062      pfn_glBindFramebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindFramebufferEXT");
1063      pfn_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glDeleteFramebuffersEXT");
1064      pfn_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenFramebuffersEXT");
1065      pfn_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
1066      pfn_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture2DEXT");
1213      pfn_glIsFramebuffer = (PFNGLISFRAMEBUFFEREXTPROC) m_gl_context->getProcAddress("glIsFramebufferEXT");
1214      pfn_glBindFramebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC) m_gl_context->getProcAddress("glBindFramebufferEXT");
1215      pfn_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC) m_gl_context->getProcAddress("glDeleteFramebuffersEXT");
1216      pfn_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC) m_gl_context->getProcAddress("glGenFramebuffersEXT");
1217      pfn_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) m_gl_context->getProcAddress("glCheckFramebufferStatusEXT");
1218      pfn_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) m_gl_context->getProcAddress("glFramebufferTexture2DEXT");
10671219   }
10681220
10691221   if ( m_usevbo &&
r243778r243779
11951347   if ( m_useglsl )
11961348   {
11971349      #ifdef GL_ARB_multitexture
1198      pfn_glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB");
1350      pfn_glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) m_gl_context->getProcAddress("glActiveTextureARB");
11991351      #else
1200      pfn_glActiveTexture = (PFNGLACTIVETEXTUREPROC) SDL_GL_GetProcAddress("glActiveTexture");
1352      pfn_glActiveTexture = (PFNGLACTIVETEXTUREPROC) m_gl_context->getProcAddress("glActiveTexture");
12011353      #endif
12021354      if (!pfn_glActiveTexture)
12031355      {
r243778r243779
12111363
12121364   if ( m_useglsl )
12131365   {
1214      m_glsl = glsl_shader_init();
1366      m_glsl = glsl_shader_init(m_gl_context);
12151367      m_useglsl = (m_glsl != NULL ? 1 : 0);
12161368
12171369      if ( ! m_useglsl )
r243778r243779
13481500      clear_flags(FI_CHANGED);
13491501   }
13501502
1351#if (SDLMAME_SDL2)
1352#ifdef OSD_WINDOWS
1353   wglMakeCurrent(m_hdc, m_gl_context_id);
1354#else
1355   SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
1356#endif
1357#endif
1503   m_gl_context->MakeCurrent();
13581504
13591505   if (m_init_context)
13601506   {
r243778r243779
17021848   window().m_primlist->release_lock();
17031849   m_init_context = 0;
17041850
1705#if (!SDLMAME_SDL2)
1706   SDL_GL_SwapBuffers();
1707#else
1708#ifdef OSD_WINDOWS
1709   SwapBuffers(m_hdc);
1710   //wglSwapLayerBuffers(GetDC(window().m_hwnd), WGL_SWAP_MAIN_PLANE);
1711#else
1712   SDL_GL_SwapWindow(window().sdl_window());
1713#endif
1714#endif
1851   m_gl_context->SwapBuffer();
1852
17151853   return 0;
17161854}
17171855
trunk/src/osd/sdl/gl_shader_mgr.c
r243778r243779
11#include <stdio.h>   /* snprintf */
22#include <stdlib.h>  /* malloc */
33
4#ifdef OSD_WINDOWS
5#include "GL/gl.h"
6#include "GL/glext.h"
7#else
4#ifndef OSD_WINDOWS
85#include "sdlinc.h"
9#include "osd_opengl.h"
106#endif
117
8#include "osd_opengl.h"
9
1210#include "gl_shader_mgr.h"
1311#include "gl_shader_tool.h"
1412
r243778r243779
120118   return glsl_scrn_programs[idx];
121119}
122120
123glsl_shader_info *glsl_shader_init(void)
121glsl_shader_info *glsl_shader_init(osd_gl_context *gl_ctx)
124122{
125123   int i,j, err;
126124
127#ifdef OSD_WINDOWS
128   err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)wglGetProcAddress);
129#else
130   err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)SDL_GL_GetProcAddress);
131#endif
125   err = gl_shader_loadExtention(gl_ctx);
132126   if(err) return NULL;
133127
134128   for (i=0; !err && i<GLSL_VERTEX_SHADER_INT_NUMBER; i++)
trunk/src/osd/sdl/gl_shader_mgr.h
r243778r243779
2424/**
2525 * returns pointer if ok, otherwise NULL
2626 */
27glsl_shader_info *glsl_shader_init(void);
27glsl_shader_info *glsl_shader_init(osd_gl_context *gl_ctx);
2828
2929/**
3030 * returns 0 if ok, otherwise an error value
trunk/src/osd/sdl/gl_shader_tool.c
r243778r243779
5454PFNGLUNIFORM4IVARBPROC pfn_glUniform4ivARB=NULL;
5555
5656
57int gl_shader_loadExtention(PFNGLGETPROCADDRESSOS GetProcAddress)
57int gl_shader_loadExtention(osd_gl_context *gl_ctx)
5858{
59   pfn_glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) GetProcAddress("glGetObjectParameterivARB");
60   pfn_glGetInfoLogARB           = (PFNGLGETINFOLOGARBPROC) GetProcAddress ("glGetInfoLogARB");
61   pfn_glDeleteObjectARB         = (PFNGLDELETEOBJECTARBPROC) GetProcAddress ("glDeleteObjectARB");
62   pfn_glCreateShaderObjectARB   = (PFNGLCREATESHADEROBJECTARBPROC) GetProcAddress ("glCreateShaderObjectARB");
63   pfn_glShaderSourceARB         = (PFNGLSHADERSOURCEARBPROC) GetProcAddress ("glShaderSourceARB");
64   pfn_glCompileShaderARB        = (PFNGLCOMPILESHADERARBPROC) GetProcAddress ("glCompileShaderARB");
65   pfn_glCreateProgramObjectARB  = (PFNGLCREATEPROGRAMOBJECTARBPROC) GetProcAddress ("glCreateProgramObjectARB");
66   pfn_glAttachObjectARB         = (PFNGLATTACHOBJECTARBPROC) GetProcAddress ("glAttachObjectARB");
67   pfn_glLinkProgramARB          = (PFNGLLINKPROGRAMARBPROC) GetProcAddress ("glLinkProgramARB");
68   pfn_glValidateProgramARB      = (PFNGLVALIDATEPROGRAMARBPROC) GetProcAddress ("glValidateProgramARB");
69   pfn_glUseProgramObjectARB     = (PFNGLUSEPROGRAMOBJECTARBPROC) GetProcAddress ("glUseProgramObjectARB");
70   pfn_glGetUniformLocationARB   = (PFNGLGETUNIFORMLOCATIONARBPROC) GetProcAddress ("glGetUniformLocationARB");
71   pfn_glUniform1fARB            = (PFNGLUNIFORM1FARBPROC) GetProcAddress ("glUniform1fARB");
72   pfn_glUniform1iARB            = (PFNGLUNIFORM1IARBPROC) GetProcAddress ("glUniform1iARB");
73   pfn_glUniform1fvARB           = (PFNGLUNIFORM1FVARBPROC) GetProcAddress ("glUniform1fvARB");
74   pfn_glUniform2fvARB           = (PFNGLUNIFORM2FVARBPROC) GetProcAddress ("glUniform2fvARB");
75   pfn_glUniform3fvARB           = (PFNGLUNIFORM3FVARBPROC) GetProcAddress ("glUniform3fvARB");
76   pfn_glUniform4fvARB           = (PFNGLUNIFORM4FVARBPROC) GetProcAddress ("glUniform4fvARB");
77   pfn_glUniform1ivARB           = (PFNGLUNIFORM1IVARBPROC) GetProcAddress ("glUniform1ivARB");
78   pfn_glUniform2ivARB           = (PFNGLUNIFORM2IVARBPROC) GetProcAddress ("glUniform2ivARB");
79   pfn_glUniform3ivARB           = (PFNGLUNIFORM3IVARBPROC) GetProcAddress ("glUniform3ivARB");
80   pfn_glUniform4ivARB           = (PFNGLUNIFORM4IVARBPROC) GetProcAddress ("glUniform4ivARB");
59   pfn_glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) gl_ctx->getProcAddress("glGetObjectParameterivARB");
60   pfn_glGetInfoLogARB           = (PFNGLGETINFOLOGARBPROC) gl_ctx->getProcAddress ("glGetInfoLogARB");
61   pfn_glDeleteObjectARB         = (PFNGLDELETEOBJECTARBPROC) gl_ctx->getProcAddress ("glDeleteObjectARB");
62   pfn_glCreateShaderObjectARB   = (PFNGLCREATESHADEROBJECTARBPROC) gl_ctx->getProcAddress ("glCreateShaderObjectARB");
63   pfn_glShaderSourceARB         = (PFNGLSHADERSOURCEARBPROC) gl_ctx->getProcAddress ("glShaderSourceARB");
64   pfn_glCompileShaderARB        = (PFNGLCOMPILESHADERARBPROC) gl_ctx->getProcAddress ("glCompileShaderARB");
65   pfn_glCreateProgramObjectARB  = (PFNGLCREATEPROGRAMOBJECTARBPROC) gl_ctx->getProcAddress ("glCreateProgramObjectARB");
66   pfn_glAttachObjectARB         = (PFNGLATTACHOBJECTARBPROC) gl_ctx->getProcAddress ("glAttachObjectARB");
67   pfn_glLinkProgramARB          = (PFNGLLINKPROGRAMARBPROC) gl_ctx->getProcAddress ("glLinkProgramARB");
68   pfn_glValidateProgramARB      = (PFNGLVALIDATEPROGRAMARBPROC) gl_ctx->getProcAddress ("glValidateProgramARB");
69   pfn_glUseProgramObjectARB     = (PFNGLUSEPROGRAMOBJECTARBPROC) gl_ctx->getProcAddress ("glUseProgramObjectARB");
70   pfn_glGetUniformLocationARB   = (PFNGLGETUNIFORMLOCATIONARBPROC) gl_ctx->getProcAddress ("glGetUniformLocationARB");
71   pfn_glUniform1fARB            = (PFNGLUNIFORM1FARBPROC) gl_ctx->getProcAddress ("glUniform1fARB");
72   pfn_glUniform1iARB            = (PFNGLUNIFORM1IARBPROC) gl_ctx->getProcAddress ("glUniform1iARB");
73   pfn_glUniform1fvARB           = (PFNGLUNIFORM1FVARBPROC) gl_ctx->getProcAddress ("glUniform1fvARB");
74   pfn_glUniform2fvARB           = (PFNGLUNIFORM2FVARBPROC) gl_ctx->getProcAddress ("glUniform2fvARB");
75   pfn_glUniform3fvARB           = (PFNGLUNIFORM3FVARBPROC) gl_ctx->getProcAddress ("glUniform3fvARB");
76   pfn_glUniform4fvARB           = (PFNGLUNIFORM4FVARBPROC) gl_ctx->getProcAddress ("glUniform4fvARB");
77   pfn_glUniform1ivARB           = (PFNGLUNIFORM1IVARBPROC) gl_ctx->getProcAddress ("glUniform1ivARB");
78   pfn_glUniform2ivARB           = (PFNGLUNIFORM2IVARBPROC) gl_ctx->getProcAddress ("glUniform2ivARB");
79   pfn_glUniform3ivARB           = (PFNGLUNIFORM3IVARBPROC) gl_ctx->getProcAddress ("glUniform3ivARB");
80   pfn_glUniform4ivARB           = (PFNGLUNIFORM4IVARBPROC) gl_ctx->getProcAddress ("glUniform4ivARB");
8181
8282   if ( pfn_glGetObjectParameterivARB && pfn_glGetInfoLogARB && pfn_glDeleteObjectARB && pfn_glCreateShaderObjectARB &&
8383         pfn_glShaderSourceARB && pfn_glCompileShaderARB && pfn_glCreateProgramObjectARB && pfn_glAttachObjectARB &&
trunk/src/osd/sdl/gl_shader_tool.h
r243778r243779
5151#define GL_GLEXT_PROTOTYPES 1
5252#endif
5353
54#ifdef OSD_WINDOWS
55#include "GL/gl.h"
56#include "GL/glext.h"
57#else
5854#include "osd_opengl.h"
59#endif
6055
6156#if defined(SDLMAME_MACOSX)
6257
r243778r243779
7671 * @return 0 - ok .. all shader ARB functions loaded
7772 *         otherwise !=0
7873 */
79int gl_shader_loadExtention(PFNGLGETPROCADDRESSOS GetProcAddress);
74int gl_shader_loadExtention(osd_gl_context *gl_ctx);
8075
8176enum GLSLCheckMode {
8277      CHECK_QUIET,         /* just return 0, if no error, otherwise the GL error code, no stderr output */
trunk/src/osd/sdl/osd_opengl.h
r243778r243779
1515   /* equivalent to #include <GL/gl.h>
1616    * #include <GL/glext.h>
1717    */
18   #ifdef OSD_WINDOWS
19   #include "GL/gl.h"
20   #include "GL/glext.h"
21   #else
1822   #if (SDLMAME_SDL2)
1923   #include <SDL2/SDL_version.h>
2024   #else
2125   #include <SDL/SDL_version.h>
2226   #endif
2327
24#if (SDL_VERSION_ATLEAST(1,2,10))
28   #if (SDL_VERSION_ATLEAST(1,2,10))
2529   #if defined(SDLMAME_WIN32)
2630      // Avoid that winnt.h (included via sdl_opengl.h, windows.h, windef.h includes intrin.h
2731      #define __INTRIN_H_
r243778r243779
3135   #else
3236   #include <SDL/SDL_opengl.h>
3337   #endif
34#else
38   #else
3539   /*
3640    * SDL 1.2.9 does not provide everything we need
3741    * We therefore distribute it ourselves
3842    */
3943   #include "SDL1211_opengl.h"
40#endif
44   #endif
45   #endif
46
47   class osd_gl_context
48   {
49   public:
50      osd_gl_context() { }
51      virtual ~osd_gl_context() { }
52      virtual void MakeCurrent() = 0;
53      virtual const char *LastErrorMsg() = 0;
54      virtual void *getProcAddress(const char *proc) = 0;
55      /*
56       *    0 for immediate updates,
57       *    1 for updates synchronized with the vertical retrace,
58       *    -1 for late swap tearing
59       *
60       *    returns -1 if swap interval is not supported
61       *
62       */
63      virtual int SetSwapInterval(const int swap) = 0;
64      virtual void SwapBuffer() = 0;
65   };
66
67
4168   #ifdef USE_DISPATCH_GL
4269
4370#ifdef MACOSX_USE_LIBSDL
trunk/src/osd/sdl/sdl.mak
r243778r243779
4848# this will also add a rpath to the executable
4949# MESA_INSTALL_ROOT = /usr/local/dfb_GL
5050
51# uncomment the next line to build a binary using
52# GL-dispatching.
51# uncomment the next line to build a binary using GL-dispatching.
5352# This option takes precedence over MESA_INSTALL_ROOT
5453
5554USE_DISPATCH_GL = 1
trunk/src/osd/sdl/video.c
r243778r243779
6363
6464sdl_video_config video_config;
6565
66#ifndef NO_OPENGL
67#ifdef USE_DISPATCH_GL
68osd_gl_dispatch *gl_dispatch;
69#endif
70#endif
71
7266sdl_monitor_info *sdl_monitor_info::primary_monitor = NULL;
7367sdl_monitor_info *sdl_monitor_info::list = NULL;
7468
trunk/src/osd/windows/windows.mak
r243778r243779
6767# USE_SDL = 1
6868
6969# uncomment next line to compile OpenGL video renderer
70# USE_OPENGL = 1
70USE_OPENGL = 1
7171
72# uncomment the next line to build a binary using GL-dispatching.
73USE_DISPATCH_GL = 1
74
7275# uncomment next line to use QT debugger
7376# USE_QTDEBUG = 1
7477
r243778r243779
403406OBJDIRS += $(WINOBJ)/../sdl
404407
405408DEFS += -DUSE_OPENGL=1
409
410ifdef USE_DISPATCH_GL
411DEFS += -DUSE_DISPATCH_GL=1
412else
406413LIBS += -lopengl32
414endif
407415
408416else
409417DEFS += -DUSE_OPENGL=0


Previous 199869 Revisions Next


© 1997-2024 The MAME Team