Convert a hex string into a ubyte[] or OutBuffer

2014-05-19 Thread Darren via Digitalmars-d-learn
Hi, I'm trying to do something very basic with large numbers: Let's say I have a hex representation of a large number: String hexnum = 16D81B16E091F31BEF; I'd like to convert it into a ubyte[] in order to Base64 encode it (or, indeed ASCII85 or Base32). eg, [16, D8, 1B, 16, E0, 91, F3, 1B,

Re: Convert a hex string into a ubyte[] or OutBuffer

2014-05-19 Thread Darren via Digitalmars-d-learn
On Monday, 19 May 2014 at 12:28:14 UTC, anonymous wrote: On Monday, 19 May 2014 at 11:36:43 UTC, Darren wrote: Is there an idiomatic/simple way to do that? import std.conv: parse; import std.array: array; import std.range: chunks; import std.algorithm: map; ubyte[] bytes = hexnum /* 16D8...

Segfault games with factorials

2014-07-24 Thread Darren via Digitalmars-d-learn
I have the following code in fac.d (modified from the factorial examples on RosettaCode): #!/usr/bin/rdmd import std.bigint; pure BigInt factorial(BigInt n) { static pure BigInt inner(BigInt n, BigInt acc) { return n == 0 ? acc : inner(n - 1, acc * n); } return inner(n,

Re: Segfault games with factorials

2014-07-24 Thread Darren via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: I have the following code in fac.d (modified from the factorial examples on RosettaCode): #!/usr/bin/rdmd import std.bigint

Converting int to dchar?

2016-07-31 Thread Darren via Digitalmars-d-learn
Hey, all. I'm pretty much a programming novice, so I hope you can bear with me. Does anyone know how I can change an int into a char equivalent? e.g. int i = 5; dchar value; ? assert(value == '5'); If I try and cast it to dchar, I get messed up output, and I'm not sure how to use

Re: Converting int to dchar?

2016-07-31 Thread Darren via Digitalmars-d-learn
That's a really informative response. Thank you!

Using OpenGL

2016-09-02 Thread Darren via Digitalmars-d-learn
I'm trying to teach myself OpenGL but I'm not sure how to set it up exactly. I used "dub init" to create a project, I downloaded glew32.dll and glfw.dll and put them in this folder. I added "derelict-gl3": "~>1.0.19" and "derelict-glfw3": "~>3.1.0" to dependencies, and imported them in the

Re: Using OpenGL

2016-09-03 Thread Darren via Digitalmars-d-learn
On Saturday, 3 September 2016 at 11:02:11 UTC, Lodovico Giaretta wrote: //glGetShaderInfoLog(vertexShader, 512, null, infoLog); glGetShaderInfoLog(vertexShader, 512, null, [0]); Thank you, I knew I had to do something like this! //glfwSetKeyCallback(window, key_callback);

Re: Using OpenGL

2016-09-03 Thread Darren via Digitalmars-d-learn
On Saturday, 3 September 2016 at 11:27:09 UTC, Mike Parker wrote: On Saturday, 3 September 2016 at 11:13:30 UTC, Lodovico Giaretta wrote: Ah! Well, providing error messages is always useful. Now I see your issue: your callback has D linkage, but OpenGL expects a function with C linkage. So

Re: Using OpenGL

2016-09-03 Thread Darren via Digitalmars-d-learn
On Saturday, 3 September 2016 at 16:07:52 UTC, Mike Parker wrote: On Saturday, 3 September 2016 at 16:01:34 UTC, Mike Parker wrote: The following compiles, runs, and shows the triangle. It's the code you posted above with the corrected call to glBufferData along with more D style (as I would

Re: Using OpenGL

2016-09-03 Thread Darren via Digitalmars-d-learn
Thanks for the information. The errors for the tutorial I _was_ trying to make work are as follows: source\app.d(9,5): Error: undefined identifier 'Window', did you mean variable 'window'? source\app.d(98,12): Error: undefined identifier 'Window', did you mean variable 'window'?

Re: Using OpenGL

2016-09-03 Thread Darren via Digitalmars-d-learn
It's not quite in a practically-usable state yet, but the SDL2 & OpenGL wrapper I'm working on may interest you as an example implementation if nothing else. https://github.com/pineapplemachine/mach.d/tree/master/mach/sdl I'm going to take a look at this, once I get my bearings, on the

Re: Using OpenGL

2016-09-14 Thread Darren via Digitalmars-d-learn
Kind of resurrecting this thread; hope that's okay. I'm working through this tutorial: http://www.learnopengl.com/#!Getting-started/Textures It uses SOIL to load images, but I haven't seen any SOIL bindings in dub. I tried using SDL and SDL_Image but when the program ran it just crashed.

Re: Using OpenGL

2016-09-15 Thread Darren via Digitalmars-d-learn
On Thursday, 15 September 2016 at 02:11:03 UTC, Mike Parker wrote: //snip Okay the crashing was my fault, more or less a copy-paste error. The program now runs but has a black rectangle where a texture should be. This is the code I'm using:

Re: Using OpenGL

2016-10-05 Thread Darren via Digitalmars-d-learn
On Tuesday, 4 October 2016 at 16:09:34 UTC, Darren wrote: Back again with another little problem that isn't specifically OpenGL related, but is a result of getting such code to work. I actually figured it out; my own mistakes.

Re: Using OpenGL

2016-10-04 Thread Darren via Digitalmars-d-learn
Back again with another little problem that isn't specifically OpenGL related, but is a result of getting such code to work. Code I'm working on: https://dfcode.wordpress.com/2016/10/04/linker-problem/ What I'm learning from: http://www.learnopengl.com/#!Getting-started/Camera,

Using Libraries

2016-09-20 Thread Darren via Digitalmars-d-learn
Hey, all I keep hitting roadblocks and that's mainly due to not knowing how to include libraries. So far I've been getting by with downloading .dll's and including the necessary dependencies in the dub.json file and having that build/run my project. I'm sure I'm making a mess of that, too,

Re: Using Libraries

2016-09-20 Thread Darren via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 15:07:53 UTC, rikki cattermole wrote: Ok lets start at the very beginning... I think I need to start before that, haha. I might need more of a step-by-step guide. I'm a complete beginner to programming, not just D. I worked through Programming in D,

Re: Using Libraries

2016-09-21 Thread Darren via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 19:45:57 UTC, Karabuta wrote: On Tuesday, 20 September 2016 at 15:38:55 UTC, Darren wrote: On Tuesday, 20 September 2016 at 15:07:53 UTC, rikki cattermole wrote: Ok lets start at the very beginning... I think I need to start before that, haha. I might need

Re: Using OpenGL

2016-09-16 Thread Darren via Digitalmars-d-learn
On Friday, 16 September 2016 at 01:54:50 UTC, Mike Parker wrote: snip Okay,I actually had GL_RGB for those two fields and it didn't work, but I guess I didn't try them again after I fixed the crash issue because now it works fine. Thanks again for the guidance!

Compiling and linking libraries

2016-11-16 Thread Darren via Digitalmars-d-learn
Hey all, This is a very beginner problem, but not one I know how to do on my own. Could anyone give a step-by-step guide on how to compile libraries, and then use them in my project with DUB? For example, I've been using this guide for graphics:

Re: Compiling and linking libraries

2016-11-19 Thread Darren via Digitalmars-d-learn
On Wednesday, 16 November 2016 at 16:05:06 UTC, Mike Parker wrote: On Wednesday, 16 November 2016 at 14:59:40 UTC, Edwin van Leeuwen wrote: Thank you for this! Great information. So dub dynamically "add" code from the dll into the source code at runtime? Also will I ever need to learn