Should dmd have given me a warning at least?
WhatMeWorry via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 12 17:52:37 PDT 2014
On Friday, 12 September 2014 at 22:53:35 UTC, Ali Çehreli wrote:
> On 09/12/2014 03:44 PM, WhatMeWorry wrote:
>>
>> // the following two lines compile cleanly but when executed,
>> I get
>> // D:\Projects\Derelict>02_SimpleOpenGL_3_3_program.exe
>> // object.Error: Access Violation
>> // ----------------
>>
>> string glShadingLangVer =
>> to!string(glGetString(GL_SHADING_LANGUAGE_VERSION));
>
> According to the documentation, you are supposed to make sure
> that glGetString does not return 0:
>
> https://www.opengl.org/sdk/docs/man2/xhtml/glGetString.xml
>
> (See Notes and Errors there.)
>
>> writeln("glShadingLangVer is ", glShadingLangVer);
>>
>>
>>
>>
>> glGetString has the following signature:
>>
>> const GLubyte* glGetString(GLenum name);
>>
>> I presume the const is causing the problem.
>
> No, const would have caused a compilation error. Access
> Violation is a runtime error caused by invalid memory access
> location like 0. ;)
>
> Ali
Isn't this a contradiction. The documentation says "glGetString
returns a pointer to a static string..." But further on down it
then says "If an error is generated, glGetString returns 0."
This is the numeric value zero, right?
So how can glGetString() return both a string and a zero?
Btw, your book is excellent, Ali.
More information about the Digitalmars-d-learn
mailing list