Re: 2D textures with OpenGL and GLUT

Jason Dagit <[email protected]> Tue, 8 Jul 2014 09:32:03 -0700
Newsgroups gmane.comp.lang.haskell.hopengl
Message-ID <CAJ-DSyy+w_id_jVZ64_9nKCNo6Ysmtk=Ecs0zdPeYR_BTXjigQ@mail.gmail.com>
--===============3229880397864074857==
Content-Type: multipart/alternative; boundary=001a11c3f4d4b2b2da04fdb12175

--001a11c3f4d4b2b2da04fdb12175
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Jul 8, 2014 at 9:20 AM, Elise Huard <[email protected]> wrote:

> I wanted to thank you, because pointing to unsafeCoerce was a nice bit
> of serendipity.  I'll admit I thought it was nitpicking initially, but
> I did a quick pass at cleaning things up last week after your mail
> (not perfect, but this was a prototype so I'm not looking for pretty):
>
>
> https://github.com/elisehuard/game-prototype/commit/5cf85fa60f325dbe610b5=
e1f017c9427e304daf6
>
> and that fixed the texture mapping!
> Consider me informed on that issue :)
>

Cool! By the way, the 'proper way' to convert between Double and CDouble is
to use realToFrac:

Prelude Foreign.C.Types =CE=BB> realToFrac (1 :: Double) :: CDouble
1.0

In specific case like this (Double <-> CDouble) it should be equivalent
(but as a user of the library you shouldn't depend on know that). In some
cases it can be a performance hit, but that's what RULEs pragmas are for.
Moreover, some versions of the Haskell OpenGL bindings made it so that
GLdouble was not the same type as CDouble. So the safest way is to use
realToFrac and depend on the library writer to provide RULEs that make it
efficient.

I hope that helps,
Jason

--001a11c3f4d4b2b2da04fdb12175
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Tue, Jul 8, 2014 at 9:20 AM, Elise Huard <span dir=3D"ltr">&lt;<=
a href=3D"mailto:[email protected]" target=3D"_blank">haskell@elisehuar=
d.be</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex">I wanted to thank you, because pointing to unsafeCoerce wa=
s a nice bit<br>

of serendipity. =C2=A0I&#39;ll admit I thought it was nitpicking initially,=
 but<br>
I did a quick pass at cleaning things up last week after your mail<br>
(not perfect, but this was a prototype so I&#39;m not looking for pretty):<=
br>
<br>
<a href=3D"https://github.com/elisehuard/game-prototype/commit/5cf85fa60f32=
5dbe610b5e1f017c9427e304daf6" target=3D"_blank">https://github.com/elisehua=
rd/game-prototype/commit/5cf85fa60f325dbe610b5e1f017c9427e304daf6</a><br>
<br>
and that fixed the texture mapping!<br>
Consider me informed on that issue :)<br></blockquote><div><br></div><div>C=
ool! By the way, the &#39;proper way&#39; to convert between Double and CDo=
uble is to use realToFrac:</div><div><br></div><div><div>Prelude Foreign.C.=
Types =CE=BB&gt; realToFrac (1 :: Double) :: CDouble</div>
<div>1.0</div></div><div><br></div><div>In specific case like this (Double =
&lt;-&gt; CDouble) it should be equivalent (but as a user of the library yo=
u shouldn&#39;t depend on know that). In some cases it can be a performance=
 hit, but that&#39;s what RULEs pragmas are for. Moreover, some versions of=
 the Haskell OpenGL bindings made it so that GLdouble was not the same type=
 as CDouble. So the safest way is to use realToFrac and depend on the libra=
ry writer to provide RULEs that make it efficient.</div>
<div><br></div><div>I hope that helps,</div><div>Jason</div><div><br></div>=
<div><br></div></div></div></div>

--001a11c3f4d4b2b2da04fdb12175--

--===============3229880397864074857==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
HOpenGL mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/hopengl

--===============3229880397864074857==--