Previous 199869 Revisions Next

r30936 Wednesday 11th June, 2014 at 03:37:23 UTC by R. Belmont
SDL: Fix shaders for games that output indexed16 (e.g. pacman). [R. Belmont]
[src/osd/sdl]drawogl.c

trunk/src/osd/sdl/drawogl.c
r30935r30936
187187   UINT32              mpass_texture_scrn[2];  // Multipass OpenGL texture "name"/ID for the shader
188188   UINT32              mpass_fbo_scrn[2];      // framebuffer object for this texture, multipass
189189
190   UINT32              lut_texture;            // LUT OpenGL texture "name"/ID for the shader
191190   int                 lut_table_width;        // LUT table width
192191   int                 lut_table_height;       // LUT table height
193192
r30935r30936
16241623       texsource->rowpixels <= sdl->texture_max_width )
16251624    {
16261625       texture->type      = TEXTURE_TYPE_SHADER;
1627       texture->nocopy    = TRUE;
16281626       texture->texTarget = GL_TEXTURE_2D;
16291627       texture->texpow2   = sdl->texpoweroftwo;
16301628    }
r30935r30936
26002598
26012599   if ( texture->type == TEXTURE_TYPE_SHADER )
26022600   {
2603      if ( texture->lut_texture )
2604      {
2605         pfn_glActiveTexture(GL_TEXTURE1);
2606         glBindTexture(texture->texTarget, texture->lut_texture);
2607
2608         glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->lut_table_width);
2609
2610         // give the card a hint
2611         glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->lut_table_width, texture->lut_table_height,
2612                  GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, texsource->palette );
2613      }
26142601      pfn_glActiveTexture(GL_TEXTURE0);
26152602      glBindTexture(texture->texTarget, texture->texture);
26162603
2617      glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->texinfo.rowpixels);
2604      if (texture->nocopy)
2605         glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->texinfo.rowpixels);
2606      else
2607         glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->rawwidth);
26182608
26192609      // and upload the image
26202610      glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight,
r30935r30936
28432833static void texture_shader_update(sdl_window_info *window, texture_info *texture, int shaderIdx)
28442834{
28452835   sdl_info *sdl = (sdl_info *) window->dxdata;
2846   if ( !texture->lut_texture )
2847   {
2848      int uniform_location, scrnum;
2849      render_container *container;
2850      GLfloat vid_attributes[4]; // gamma, contrast, brightness, effect
2836   int uniform_location, scrnum;
2837   render_container *container;
2838   GLfloat vid_attributes[4];
28512839
2852      scrnum = 0;
2853      container = (render_container *)NULL;
2854      screen_device_iterator iter(window->machine().root_device());
2855      for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next())
2840   scrnum = 0;
2841   container = (render_container *)NULL;
2842   screen_device_iterator iter(window->machine().root_device());
2843   for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next())
2844   {
2845      if (scrnum == window->start_viewscreen)
28562846      {
2857         if (scrnum == window->start_viewscreen)
2858         {
2859            container = &screen->container();
2860         }
2861
2862         scrnum++;
2847         container = &screen->container();
28632848      }
28642849
2865      if (container!=NULL)
2866      {
2867         render_container::user_settings settings;
2868         container->get_user_settings(settings);
2869         //FIXME: Intended behaviour
2850      scrnum++;
2851   }
2852
2853   if (container!=NULL)
2854   {
2855      render_container::user_settings settings;
2856      container->get_user_settings(settings);
2857      //FIXME: Intended behaviour
28702858#if 1
2871         vid_attributes[0] = window->machine().options().gamma();
2872         vid_attributes[1] = window->machine().options().contrast();
2873         vid_attributes[2] = window->machine().options().brightness();
2859      vid_attributes[0] = window->machine().options().gamma();
2860      vid_attributes[1] = window->machine().options().contrast();
2861      vid_attributes[2] = window->machine().options().brightness();
28742862#else
2875         vid_attributes[0] = settings.gamma;
2876         vid_attributes[1] = settings.contrast;
2877         vid_attributes[2] = settings.brightness;
2863      vid_attributes[0] = settings.gamma;
2864      vid_attributes[1] = settings.contrast;
2865      vid_attributes[2] = settings.brightness;
28782866#endif
2879         vid_attributes[3] = 0.0f;
2880         uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[shaderIdx], "vid_attributes");
2881         pfn_glUniform4fvARB(uniform_location, 1, &(vid_attributes[shaderIdx]));
2882         if ( GL_CHECK_ERROR_QUIET() ) {
2883            osd_printf_verbose("GLSL: could not set 'vid_attributes' for shader prog idx %d\n", shaderIdx);
2884         }
2867      vid_attributes[3] = 0.0f;
2868      uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[shaderIdx], "vid_attributes");
2869      pfn_glUniform4fvARB(uniform_location, 1, &(vid_attributes[shaderIdx]));
2870      if ( GL_CHECK_ERROR_QUIET() ) {
2871         osd_printf_verbose("GLSL: could not set 'vid_attributes' for shader prog idx %d\n", shaderIdx);
28852872      }
2886      else
2887      {
2888         osd_printf_verbose("GLSL: could not get render container for screen %d\n", window->start_viewscreen);
2889      }
28902873   }
2874   else
2875   {
2876      osd_printf_verbose("GLSL: could not get render container for screen %d\n", window->start_viewscreen);
2877   }
28912878}
28922879
28932880static texture_info * texture_update(sdl_window_info *window, const render_primitive *prim, int shaderIdx)
r30935r30936
30793066         glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]);
30803067      }
30813068
3082      if(texture->lut_texture)
3083         glDeleteTextures(1, (GLuint *)&texture->lut_texture);
3084
30853069      glDeleteTextures(1, (GLuint *)&texture->texture);
30863070      if ( texture->data_own )
30873071      {

Previous 199869 Revisions Next


© 1997-2024 The MAME Team