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, http://www.lea

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!

Re: Using OpenGL

2016-09-15 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 15 September 2016 at 19:03:22 UTC, Darren wrote: This is the code I'm using: https://dfcode.wordpress.com/2016/09/15/texcodewip/ (The code for the shaders is at the bottom) For comparison, this is the code I'm trying to make work: http://www.learnopengl.com/code_viewer.php?code=

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: https://dfcode.wordpress.com/2016/09/15/texcodew

Re: Using OpenGL

2016-09-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 14 September 2016 at 16:49:51 UTC, Darren wrote: While googling, the idea seemed to be to create and SDL_Surface* and pass that (or surface.pixels) as the last argument for glTexImage2D. Didn't work for me, however. Does anyone have any tips? I'm driving blind here without

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. I

Re: Using OpenGL

2016-09-05 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 5 September 2016 at 05:14:56 UTC, Nicholas Wilson wrote: On Saturday, 3 September 2016 at 17:13:49 UTC, Darren wrote: Now I wonder if I can load shaders from separate files (à la http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/). see: https://p0nc

Re: Using OpenGL

2016-09-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 3 September 2016 at 17:13:49 UTC, Darren wrote: On Saturday, 3 September 2016 at 16:07:52 UTC, Mike Parker wrote: [...] The dynamic array! Thank you so much, I changed that on another file and it finally drew the triangle. And I ran your code and it works brilliantly. I shoul

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 Mike Parker via Digitalmars-d-learn
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 write it anyway) and less C. One thing I overlooked. In lines wher

Re: Using OpenGL

2016-09-03 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 3 September 2016 at 12:40:58 UTC, Darren wrote: I went through another tutorial. Changed the source code and left out the shaders. I get another coloured background but still no triangle. I have a feeling that glBufferData(GL_ARRAY_BUFFER, cast(int)g_vertex_buffer_data.s

Re: Using OpenGL

2016-09-03 Thread Darren via Digitalmars-d-learn
On Saturday, 3 September 2016 at 11:33:10 UTC, Mike Parker wrote: On Saturday, 3 September 2016 at 11:02:11 UTC, Lodovico Giaretta wrote: glGetShaderInfoLog(vertexShader, 512, null, &infoLog[0]); I prefer: glGetShaderInfoLog(vertexShader, 512, null, infoLog.ptr); That is a good tip to k

Re: Using OpenGL

2016-09-03 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 3 September 2016 at 11:02:11 UTC, Lodovico Giaretta wrote: glGetShaderInfoLog(vertexShader, 512, null, &infoLog[0]); I prefer: glGetShaderInfoLog(vertexShader, 512, null, infoLog.ptr);

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 yo

Re: Using OpenGL

2016-09-03 Thread Mike Parker via Digitalmars-d-learn
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 you have to put `extern(C)` on your callback declaration. Well, it

Re: Using OpenGL

2016-09-03 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 3 September 2016 at 11:10:00 UTC, Darren wrote: On Saturday, 3 September 2016 at 11:02:11 UTC, Lodovico Giaretta wrote: //glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(window, &key_callback); I actually tried this before but it doesn't work. I get the following

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, &infoLog[0]); Thank you, I knew I had to do something like this! //glfwSetKeyCallback(window, key_callback); glfw

Re: Using OpenGL

2016-09-03 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 3 September 2016 at 10:30:13 UTC, Darren wrote: [...] I never used OpenGL in D, but from a quick glance at your code, I'll suggest trying the following changes: //glGetShaderInfoLog(vertexShader, 512, null, infoLog); glGetShaderInfoLog(vertexShader, 512, null, &infoLo

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 merits

Re: Using OpenGL

2016-09-03 Thread pineapple via Digitalmars-d-learn
On Saturday, 3 September 2016 at 09:30:58 UTC, Darren wrote: 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 ident

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'? source\app.d

Re: Using OpenGL

2016-09-02 Thread Mike Parker via Digitalmars-d-learn
On Friday, 2 September 2016 at 20:38:15 UTC, Darren wrote: 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-glfw

Re: Using OpenGL (custom port)

2009-10-06 Thread David Butler
I got it working, it did turn out to be a slight error in the type declaration. I had this: typedef HGLRC function (HDC hDC, HGLRC hShareContext, in int *attribList) PFNWGLCREATECONTEXTATTRIBSARBPROC; And it needed to be: typedef extern (Windows) ...everything else... Whoops. But I can no

Re: Using OpenGL (custom port)

2009-10-06 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Butler wrote: > > Is there a difference between a pointer to a D array and an int* in C? > How do I convert between the two? Am I even looking in the right place? > > Thanks for any help! > > -Dave Butler There's nothing wrong with your int

Re: Using OpenGL (custom port)

2009-10-05 Thread bearophile
Moritz Warning: > Please also keep in mind that only array literals are \0 terminated. char/wchar/dchar array literals only, I think. Bye, bearophile

Re: Using OpenGL (custom port)

2009-10-04 Thread Moritz Warning
On Sun, 04 Oct 2009 19:52:12 -0400, David Butler wrote: [..] > Is there a difference between a pointer to a D array and an int* in C? > How do I convert between the two? Am I even looking in the right place? > You can think of a D array as a struct of a length value and a C pointer. struct Arr

Re: Using OpenGL (custom port)

2009-10-04 Thread David Butler
Oops, I edited part of the code. Just substitute in 'tmpContext' anywhere you see 'context'.