digitalmars.D.learn - OpenGL in D2
- Siqu (48/48) Feb 21 2011 Hi,
- Nrgyzer (30/45) Feb 21 2011 to do. I'd
- Sequ (19/29) Feb 23 2011 My 'lib' folder was in /usr/lib, although that folder didn't contain 'ph...
- Nrgyzer (19/48) Feb 23 2011 contain 'phobos.lib',
- Dmitry Olshansky (10/24) Feb 21 2011 There is htod tool in the digitalmars website, but it's windows only.
- Denis Koroskin (6/36) Feb 21 2011 All attachments are encoded, but your client should be able to decode it...
- Trass3r (7/15) Feb 21 2011 Derelict does a lot more, it hides all the nasty handling of different O...
Hi, I'm trying to figure out how I could get a simple OpenGL/GLUT program working in DMD2. As an attachment, I've added a C version of what I'd like to do. I'd compile the C version using: gcc simple.c -lglut -lGLU -o simple I've found a few OpenGL projects, like bindings (http://www.dsource.org/projects/bindings/) and derelict (http://www.dsource.org/projects/derelict/), but I still can't find any way to easily use or install them (for D2 on Ubuntu). I'd have thought that, since D interfaces so well with C, just using C libraries wouldn't require specific wrapper libraries, but it seems an automated method for converting C headers to D isn't currently possible? Anyway, any help would be appreciated, Thanks. begin 644 simple.c M(VEN8VQU9&4 /$=,+V=L+F ^"B-I;F-L=61E(#Q'3"]G;'5T+F ^" IS=&%T M:6, :6YT('=I;CL*"G9O:60 :6YI="AI;G0 87)G8RP 8VAA<B`J*F%R9W8I M"GL*("\O(&EN:71I86QI>F4 9VQU=`H 9VQU=$EN:70H)F%R9V,L(&%R9W8I M.PH +R\ <W!E8VEF>2!T:&4 9&ES<&QA>2!M;V1E('1O(&)E(%)'0B!A;F0 M<VEN9VQE(&)U9F9E<FEN9R`*("\O('=E('5S92!S:6YG;&4 8G5F9F5R:6YG M('-I;F-E('1H:7, =VEL;"!B92!N;VX 86YI;6%T960*(&=L=71);FET1&ES M<&QA>4UO9&4H1TQ55%]21T)!('P 1TQ55%]324Y'3$4I.PH +R\ 9&5F:6YE M:&4 <&]S:71I;VX =VAE<F4 =&AE('=I;F1O=R!W:6QL(&%P<&5A< H 9VQU M('=A;G0 9G5L;'-C<F5E;CH*("\O(&=L=71&=6QL4V-R965N*"D["B`O+R!C M<F5A=&4 =&AE('=I;F1O=RP <V5T('1H92!T:71L92!A;F0 :V5E<"!T:&4 M;W<H(E1I=&QE(&=O97, :&5R92(I.PH +R]G;'5T1&ES<&QA>49U;F,H9&ES M<"D["B`O+V=L=71+97EB;V%R9$9U;F,H:V5Y8BD["GT*"FEN="!M86EN*&EN M="!A<F=C+"!C:&%R("HJ87)G=BE["B`O+R!I;FET($=,550 =&\ :&%N9&QE M('=I;F1O=PH :6YI="AA<F=C+&%R9W8I.PH*("\O(&]P96YG;"!C;V1E("AP M97)F;W)M960 ;VYL>2!O;B!S=&%R='5P*0H +R\ <V5T(&-L96%R+6-O;&]U M;R!C;&5A<BUC;VQO=7(*(&=L0VQE87(H1TQ?0T],3U)?0E5&1D527T))5"D[ M<&5C:69Y(&-O+6]R9&EN871E('-Y<W1E;2`H;6%P<&EN9R!I;6%G92!T;R!S M8W)E96XI"B!G;$]R=&AO*"TQ+"`Q+"TQ+"`Q+"TQ+"`Q*3L*("\O(&)E9VEN M(&1E9FEN:6YG(&$ ;F5W(&]B:F5C="`H<&]L>6=O;BD*(&=L0F5G:6XH1TQ? M4$],64=/3BD["B` +R\ 9&5F:6YE('!O;'EG;VXG<R!C;W)N97)S(" I"B` M("TP+C4I.PH +R\ 96YD(&1E9FEN:6YG(&]B:F5C=`H 9VQ%;F0H*3L*("\O M(&]U='!U="!C;VUM86YD<R!T;R!S8W)E96X*(&=L1FQU<V H*3L*"B`O+R!U M<V4 1TQ55"!T;R!R=6X ;6%I;B!L;V]P"B!G;'5T36%I;DQO;W`H*3L*(')E *='5R;B`P.PI]" `` ` end
Feb 21 2011
== Auszug aus Siqu (user example.net)'s ArtikelHi, I'm trying to figure out how I could get a simple OpenGL/GLUTprogram workingin DMD2. As an attachment, I've added a C version of what I'd liketo do. I'dcompile the C version using: gcc simple.c -lglut -lGLU -o simple I've found a few OpenGL projects, like bindings (http://www.dsource.org/projects/bindings/) and derelict (http://www.dsource.org/projects/derelict/), but I still can't findany way toeasily use or install them (for D2 on Ubuntu). I'd have thoughtthat, since Dinterfaces so well with C, just using C libraries wouldn't requirespecificwrapper libraries, but it seems an automated method for convertingC headersto D isn't currently possible? Anyway, any help would be appreciated, Thanks. << simple.c >>I'm using derelict, primary on windows, but I've also a running version on Ubuntu. You can download derelict at http://www.dsource.org/projects/derelict/ changeset/525/branches/Derelict2?old_path=%2F&format=zip I think you've already a running version of the dmd-compiler? If yes, you can simply extract the package, open your shell browse to the extracted folder and run "make -flinux.mak DC=dmd" which worked for me on windows and linux (make sure you've installed make and dmd is in your environment-values). On windows you've to create a folder called "lib" before you run the command above - I currently can't say it exactly if it's needed on linux, too. After it compiled, you can copy all the created lib-files to the lib- folder (I think this should be /usr/lib or something like this - run "find / -name 'phobos.lib'" and copy the lib-files to the same directory where phobos.lib is located. Copy the content of the "import"-dir to a location where you've all your binding for D, so that you can simply use "import derelict.sdl.sdl" or similar. When you've installed it correctly, you can use derelict/opengl like described on the derelict site. Note that you have to use 'pragma (lib, "DerelictSDL")' or similar to use the binding. It is also important the you insert 'pragma(lib, "dl")' in you source that you can compile it successfully. I hope this helped :)
Feb 21 2011
Quoted from Nrgyzer:On windows you've to create a folder called "lib" before you run the command above - I currently can't say it exactly if it's needed on linux, too.I did need to create a 'lib' directory before running 'make -flinux.mak DC=dmd'.After it compiled, you can copy all the created lib-files to the lib-folderMy 'lib' folder was in /usr/lib, although that folder didn't contain 'phobos.lib', but 'libphobos2.a'. Hopefully that works correctly.Copy the content of the "import"-dir to a location where you've all your binding for DFor now, I've just copied it into an 'import' folder in the same folder as my source code. I suspect the correct directory is '/usr/include/d/dmd/druntime/import'. I got an SDL example working by then using the command: dmd -L-lDerelictGL -L-lDerelictGLU -L-lDerelictUtil -L-lDerelictSDL test_sdl.d but unfortunately I couldn't get my example working, because it requires GLUT and the derelict library doesn't have that included. I'd actually prefer to use GLUT and also, eventually, other obscure C libraries that I know no-one else would have ported, but I suppose I'll take a look at the links provided in Trass3r's post before asking more about that.I hope this helped :)Thanks, yes that was quite helpful! Quoted from Dmitry Olshansky:Sadly your file goes like rubbish for me, is that base64 ?Yeah, I see it turned out odd, but I'm using the web interface to post here (it seems my Thunderbird in the Lab can't access the news server from behind all the firewalls - or something). The file is actually just one of the first examples from the OpenGL tutorials.
Feb 23 2011
== Auszug aus Sequ (user example.net)'s ArtikelQuoted from Nrgyzer:flinux.mak DC=dmd'.On windows you've to create a folder called "lib" before you run the command above - I currently can't say it exactly if it's needed on linux, too.I did need to create a 'lib' directory before running 'make -contain 'phobos.lib',After it compiled, you can copy all the created lib-files to the lib-folderMy 'lib' folder was in /usr/lib, although that folder didn'tbut 'libphobos2.a'. Hopefully that works correctly.folder as myCopy the content of the "import"-dir to a location where you've all your binding for DFor now, I've just copied it into an 'import' folder in the samesource code. I suspect the correct directory is '/usr/include/d/dmd/druntime/import'.I got an SDL example working by then using the command: dmd -L-lDerelictGL -L-lDerelictGLU -L-lDerelictUtil -L-lDerelictSDLtest_sdl.dbut unfortunately I couldn't get my example working, because itrequires GLUT andthe derelict library doesn't have that included. I'd actuallyprefer to use GLUTand also, eventually, other obscure C libraries that I know no-oneelse would haveported, but I suppose I'll take a look at the links provided inTrass3r's postbefore asking more about that.As I know, GLUT was also ported (http://www.yage3d.net/host/ derelict.glut.zip). I also tried it with DMD and Derelict - both V1, but I can't get it to work. I think the mistake was on my own, but I didn't spend them much time. The binding is from 2006 (or 2007) and for those I don't suggest you to use it, especially I think it doesn't work with DMD 2 and/or Derelict 2.post here (itI hope this helped :)Thanks, yes that was quite helpful! Quoted from Dmitry Olshansky:Sadly your file goes like rubbish for me, is that base64 ?Yeah, I see it turned out odd, but I'm using the web interface toseems my Thunderbird in the Lab can't access the news server frombehind all thefirewalls - or something). The file is actually just one of thefirst examplesfrom the OpenGL tutorials.
Feb 23 2011
On 21.02.2011 13:33, Siqu wrote:Hi, I'm trying to figure out how I could get a simple OpenGL/GLUT program working in DMD2. As an attachment, I've added a C version of what I'd like to do. I'd compile the C version using: gcc simple.c -lglut -lGLU -o simple I've found a few OpenGL projects, like bindings (http://www.dsource.org/projects/bindings/) and derelict (http://www.dsource.org/projects/derelict/), but I still can't find any way to easily use or install them (for D2 on Ubuntu). I'd have thought that, since D interfaces so well with C, just using C libraries wouldn't require specific wrapper libraries, but it seems an automated method for converting C headers to D isn't currently possible?There is htod tool in the digitalmars website, but it's windows only. Also it still leaves much to be desired. IMHO Derelict is so far the best way to OpenGL and such in D, because of the nice way it loads & handles all these weirdness with loading, say, OpenGL extensions. And automatically picking up any suitable shared lib is big win.Anyway, any help would be appreciated, Thanks.Sadly your file goes like rubbish for me, is that base64 ? -- Dmitry Olshansky
Feb 21 2011
On Mon, 21 Feb 2011 14:45:51 +0300, Dmitry Olshansky <dmitry.olsh gmail.com> wrote:On 21.02.2011 13:33, Siqu wrote:All attachments are encoded, but your client should be able to decode it without any issues. Try other software, I recommend Opera's built-in mail client (which features NTTP support).Hi, I'm trying to figure out how I could get a simple OpenGL/GLUT program working in DMD2. As an attachment, I've added a C version of what I'd like to do. I'd compile the C version using: gcc simple.c -lglut -lGLU -o simple I've found a few OpenGL projects, like bindings (http://www.dsource.org/projects/bindings/) and derelict (http://www.dsource.org/projects/derelict/), but I still can't find any way to easily use or install them (for D2 on Ubuntu). I'd have thought that, since D interfaces so well with C, just using C libraries wouldn't require specific wrapper libraries, but it seems an automated method for converting C headers to D isn't currently possible?There is htod tool in the digitalmars website, but it's windows only. Also it still leaves much to be desired. IMHO Derelict is so far the best way to OpenGL and such in D, because of the nice way it loads & handles all these weirdness with loading, say, OpenGL extensions. And automatically picking up any suitable shared lib is big win.Anyway, any help would be appreciated, Thanks.Sadly your file goes like rubbish for me, is that base64 ?
Feb 21 2011
I've found a few OpenGL projects, like bindings (http://www.dsource.org/projects/bindings/) and derelict (http://www.dsource.org/projects/derelict/), but I still can't find any way to easily use or install them (for D2 on Ubuntu).Use derelict2 from svn and xfBuild. Then you just need to tell dmd where derelict is via -II'd have thought that, since D interfaces so well with C, just using C libraries wouldn't require specific wrapper libraries, but it seems an automated method for converting C headers to D isn't currently possible?Derelict does a lot more, it hides all the nasty handling of different OpenGL versions that might be installed along with extension loading. To my knowledge there are several tools to convert C headers to D import modules: - htod, which is crappy. Since it's based on dmc, it nearly always complains about header files and the like; it doesn't translate preprocessor conditional compilation to versions or static if and almost always messes something up (const or whatever, can't remember) - SWIG, which I haven't tried yet for that purpose. But I think it will have the same problem with preprocessor conditional compilation. - c2d, don't know how good it works: http://dsource.org/projects/visuald/browser/trunk/c2d - bcd, which is obviously abandoned: http://www.dsource.org/projects/bcd
Feb 21 2011