Re: 2D textures with OpenGL and GLUT
Jason Dagit <[email protected]> Wed, 2 Jul 2014 10:11:10 -0700
| Newsgroups | gmane.comp.lang.haskell.hopengl |
|---|---|
| Message-ID | <CAJ-DSyy0+HnWNiUGvgmaL=skO=LPT7GBhhvF14_sH1EECa5KsQ@mail.gmail.com> |
--===============3309143864164097025== Content-Type: multipart/alternative; boundary=089e0149cd42914af704fd38fa52 --089e0149cd42914af704fd38fa52 Content-Type: text/plain; charset=UTF-8 On Wed, Jul 2, 2014 at 9:33 AM, Elise Huard <[email protected]> wrote: > Hi Jason, > thanks for taking the time to answer. > So trying to read between the lines: > - do you have any _working_ examples of texture mapping with OpenGLRaw > and low-level Haskell I could have a look at? (anything would help at > this point) > I do. I converted some of the old nehe tutorials: https://github.com/dagit/nehe-tuts If you look through the history you can find examples that use a very very old version of OpenGL (instead of OpenGLRaw). The OpenGL style in those examples is old and no longer the recommended way. The examples use immediate mode which is now deprecated in favor of shaders. I think lesson 6 makes a cube and throws some textures on it. The lesson numbers are meant to match these: * http://nehe.gamedev.net/tutorial/lessons_01__05/22004/ * http://nehe.gamedev.net/tutorial/lessons_06__10/17010/ > - do you think the unsafeCoerce (which I borrowed from examples) that > transform CpFloat to GLdouble might be the issue, or is this just a > general stylistic comment? > Not just stylistic. As for correctness, I think the answer varies by platform. Specifically, I think CFloat is not required to match GLdouble in size (in fact, doubles should be expected to be twice as big). While both types should correspond to IEEE 754 floats the bit width is very likely different and that could easily cause the interpretation of the values to go wonky. Imagine passing 64bits when only the first 32bits correspond to a valid number or truncating a 64bit value to 32bits. Which examples use unsafeCoerce for this? I'm just sort of curious so I can recommend people not to use them :) --089e0149cd42914af704fd38fa52 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 Wed, Jul 2, 2014 at 9:33 AM, Elise Huard <span dir=3D"ltr"><<= a href=3D"mailto:[email protected]" target=3D"_blank">elise@jabberwocky.= eu</a>></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">Hi Jason,<br> thanks for taking the time to answer.<br> So trying to read between the lines:<br> - do you have any _working_ examples of texture mapping with OpenGLRaw<br> and low-level Haskell I could have a look at? (anything would help at<br> this point)<br></blockquote><div><br></div><div>I do. I converted some of t= he old nehe tutorials:=C2=A0<a href=3D"https://github.com/dagit/nehe-tuts">= https://github.com/dagit/nehe-tuts</a></div><div><br></div><div>If you look= through the history you can find examples that use a very very old version= of OpenGL (instead of OpenGLRaw). The OpenGL style in those examples is ol= d and no longer the recommended way. The examples use immediate mode which = is now deprecated in favor of shaders.</div> <div><br></div><div>I think lesson 6 makes a cube and throws some textures = on it. The lesson numbers are meant to match these:</div><div>=C2=A0 *=C2= =A0<a href=3D"http://nehe.gamedev.net/tutorial/lessons_01__05/22004/">http:= //nehe.gamedev.net/tutorial/lessons_01__05/22004/</a></div> <div>=C2=A0 *=C2=A0<a href=3D"http://nehe.gamedev.net/tutorial/lessons_06__= 10/17010/">http://nehe.gamedev.net/tutorial/lessons_06__10/17010/</a></div>= <div><br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"= margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,20= 4,204);border-left-style:solid;padding-left:1ex"> - do you think the unsafeCoerce (which I borrowed from examples) that<br> transform CpFloat to GLdouble might be the issue, or is this just a<br> general stylistic comment?<br></blockquote><div><br></div><div>Not just sty= listic. As for correctness, I think the answer varies by platform. Specific= ally, I think CFloat is not required to match GLdouble in size (in fact, do= ubles should be expected to be twice as big). While both types should corre= spond to IEEE 754 floats the bit width is very likely different and that co= uld easily cause the interpretation of the values to go wonky. Imagine pass= ing 64bits when only the first 32bits correspond to a valid number or trunc= ating a 64bit value to 32bits.</div> <div><br></div><div>Which examples use unsafeCoerce for this? I'm just = sort of curious so I can recommend people not to use them :)</div><div><br>= </div></div></div></div> --089e0149cd42914af704fd38fa52-- --===============3309143864164097025== 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 --===============3309143864164097025==--