<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>I have created a simple stub for wglMakeContextCurrentARB in
      stw_wgl.c and stw_getprocaddress.c. It simply returns TRUE, but
      the good thing is that now the game no longer crashes because the
      function is missing! However I get a divide by zero in glu32.dll,
      presumably because the stub doesn't do jack.<br>
      I tried returning FALSE but the game has no fallback, it just
      ignores the return values and assumes that everything is fine.<br>
    </p>
    <p>From what I've seen, there is no need to override the system's
      opengl32.dll like you did for wglCreateContext/wglDeleteContext,
      so it shouldn't be too tricky to implement the function. However,
      I can't seem to find any real documentation about what it's
      supposed to do. I found this at
<a class="moz-txt-link-freetext" href="https://www.khronos.org/registry/OpenGL/extensions/ARB/WGL_ARB_make_current_read.txt">https://www.khronos.org/registry/OpenGL/extensions/ARB/WGL_ARB_make_current_read.txt</a>
      but it's pretty vague:<br>
    </p>
    <pre style="user-select: auto !important; color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap;">The function wglMakeContextCurrentARB associates the context <hglrc>
    with the device <hDrawDC> for draws and the device <hReadDC> for
    reads.  All subsequent OpenGL calls made by the calling thread are
    drawn on the device identified by <hDrawDC> and read on the device
    identified by <hReadDC>.

</pre>
    How do I do that? Do I have to copy the frame buffer? Or just the
    pointer? Or am I completely off road?<br>
    <br>
    <br>
    Thanks for helping me out ;)<br>
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">Il 2017-03-14 03:44, Brian Paul ha
      scritto:<br>
    </div>
    <blockquote cite="mid:58C75919.9060607@vmware.com" type="cite">Looks
      like my KOTOR patch never made it to master.  I'm attaching it
      below so you can try it.  I should commit it master.  In any case,
      let me know if it helps.
      <br>
      <br>
      -Brian
      <br>
      <br>
      On 03/13/2017 10:55 AM, Federico Dossena wrote:
      <br>
      <blockquote type="cite">Hi Jose, thanks for replying, I've seen
        your name inside many files in
        <br>
        mesa ;)
        <br>
        <br>
        I have tried mesa master (previously I was using 17.0.1) but it
        still
        <br>
        crashes for the same null pointer.
        <br>
        Do you have a link to that patch you've mentioned for kotor?
        <br>
        <br>
        I have used apitrace and took traces of both the nvidia driver
        (which
        <br>
        runs kotor) and mesa (up until the crash).
        <br>
        Here's a link to them:
        <br>
<a class="moz-txt-link-freetext" href="https://drive.google.com/file/d/0B6qj91UlSYlYa3dIM0FtaHNULW8/view?usp=sharing">https://drive.google.com/file/d/0B6qj91UlSYlYa3dIM0FtaHNULW8/view?usp=sharing</a>
        <br>
<a class="moz-txt-link-rfc2396E" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__drive.google.com_file_d_0B6qj91UlSYlYa3dIM0FtaHNULW8_view-3Fusp-3Dsharing&d=DwMDaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=u9OxTt6a0b4XxAVoFjjG7RmQNYLAIe3smaD2NtY0mhE&s=h5NDyV1_DsR1WIruLOfH3IDrWkYTa8VEHeC3vIiucF4&e="><https://urldefense.proofpoint.com/v2/url?u=https-3A__drive.google.com_file_d_0B6qj91UlSYlYa3dIM0FtaHNULW8_view-3Fusp-3Dsharing&d=DwMDaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=u9OxTt6a0b4XxAVoFjjG7RmQNYLAIe3smaD2NtY0mhE&s=h5NDyV1_DsR1WIruLOfH3IDrWkYTa8VEHeC3vIiucF4&e=></a>
        <br>
        <br>
        I tried reading them with the dump function but it's way above
        my
        <br>
        comprehension.
        <br>
        <br>
        I know that some applications use wglGetProcAddress to check if
        an
        <br>
        extension if available, but I've seen KOTOR check for the
        <br>
        WGL_ARB_render_texture, and when it's present it enables frame
        buffer
        <br>
        effects and soft shadows, which use wglMakeContextCurrentARB
        (not
        <br>
        wglBindTexImageARB, I was wrong in my previous mail), which for
        some
        <br>
        reason is a null pointer.
        <br>
        <br>
        ////
        <br>
        <br>
        <br>
        Il 2017-03-13 14:39, Jose Fonseca ha scritto:
        <br>
        <blockquote type="cite">On 13/03/17 11:09, Emil Velikov wrote:
          <br>
          <blockquote type="cite">On 11 March 2017 at 11:51, Federico
            Dossena <a class="moz-txt-link-rfc2396E" href="mailto:dossenus91@gmail.com"><dossenus91@gmail.com></a>
            <br>
            wrote:
            <br>
            <blockquote type="cite">In the last week I've been trying to
              bring an "old" game back to
              <br>
              life, Star
              <br>
              Wars Knights of the old republic (KOTOR, for short). It's
              from 2003
              <br>
              and uses
              <br>
              OpenGL 1.4.
              <br>
              <br>
              I have used Mesa, libtxc_dxtn and some trickery to
              decompress the
              <br>
              textures
              <br>
              to boost performance, and right now I have it up and
              running
              <br>
              smoothly with
              <br>
              Gallium on LLVMPipe, compiled on Windows. (I can upload a
              copy if
              <br>
              someone is
              <br>
              interested). This took me about 2 days of compiling and
              figuring out
              <br>
              stuff.
              <br>
              <br>
              Here's where the weirdness begins:
              <br>
              Turning on framebuffer effects or soft shadows make the
              game crash
              <br>
              right
              <br>
              after the menu. Using a disassembler and debugger and what
              little
              <br>
              knowledge
              <br>
              I have of reverse engineering, I managed to track down the
              issue to a
              <br>
              function which uses wglGetProcAddress to get the addresses
              of
              <br>
              several OpenGL
              <br>
              functions. Some of these calls return a null pointer (even
              if there
              <br>
              is a
              <br>
              valid context and it is current), and when the game tries
              to call
              <br>
              them, it
              <br>
              crashes. The first one that makes it crash is a pointer to
              <br>
              wglBindTexImageARB, but there are a few others. NOPing the
              offending
              <br>
              instructions did not work, and returning a nop function
              just makes
              <br>
              the game
              <br>
              display artifacts.
              <br>
              <br>
            </blockquote>
            Strange - afaict mesa (st/wgl) exposes both
            wglBindTexImageARB and the
            <br>
            WGL_ARB_render_texture extension.
            <br>
            You can break on DrvGetProcAddress and trace where/how we
            end up with
            <br>
            NULL function pointer.
            <br>
            <br>
            -Emil
            <br>
            _______________________________________________
            <br>
            mesa-dev mailing list
            <br>
            <a class="moz-txt-link-abbreviated" href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>
            <br>
            <a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a>
            <br>
            <br>
          </blockquote>
          <br>
          Federico,
          <br>
          <br>
          You should be using latest master for this.   There have been
          recent
          <br>
          changes/fixes to our WGL implementation.
          <br>
          <br>
          <br>
          Last fall Brian Paul fixed an issue with WGL extension seen on
          KOTOR.
          <br>
          I'm not sure the the issue has been crossported to Mesa master
          yet,
          <br>
          and it might be unrelated.
          <br>
          <br>
          <br>
          Generally speaking, wglGetProcAddress returning NULL by itself
          is not
          <br>
          a problem.  Many games wrongly rely on wglGetProcAddress NULL
          results
          <br>
          to detect whether an GL/WGL extension is present (which goes
          against
          <br>
          the spec).  Other libraries try to bindly get every possible
          <br>
          entrypoint through wglGetProcAddress, then check which ones to
          use
          <br>
          based on supported extensions (which is actually fine by the
          spec.)
          <br>
          <br>
          <br>
          For the record, getting an apitrace is usually useful to debug
          this
          <br>
          sort of issues.  One can use apitrace straigh from windows or
          with
          <br>
          WINE -- <a class="moz-txt-link-freetext" href="https://github.com/apitrace/apitrace/wiki/WINE">https://github.com/apitrace/apitrace/wiki/WINE</a>
          <br>
          <br>
          <br>
          Jose
          <br>
        </blockquote>
        <br>
        <br>
        <br>
        _______________________________________________
        <br>
        mesa-dev mailing list
        <br>
        <a class="moz-txt-link-abbreviated" href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>
        <br>
<a class="moz-txt-link-freetext" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=u9OxTt6a0b4XxAVoFjjG7RmQNYLAIe3smaD2NtY0mhE&s=jnsrLdbWwBr7d8cUeUr_dxHK8sN25_6TfLQjoVbMCj8&e=">https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=u9OxTt6a0b4XxAVoFjjG7RmQNYLAIe3smaD2NtY0mhE&s=jnsrLdbWwBr7d8cUeUr_dxHK8sN25_6TfLQjoVbMCj8&e=</a>
        <br>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>