In chapter 2, you say:
glVertexAttribPointer(18, 4, GL_FLOAT, GL_FALSE, 0, 0); Has a 1:1 correspondence with:
view sourceprint? layout(location=18) in vec4 in_Position;
However, if you try modifying the code in 2.1.c to do that, you'll find it doesn't work
What steps will reproduce the problem? 1. open 2.1.c and run it. It works fine
Change line glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); to glVertexAttribPointer(18, 4, GL_FLOAT, GL_FALSE, 0, 0);
Change line "layout(location=0) in vec4 in_Position;\n"\
to "layout(location=18) in vec4 in_Position;\n"\ What is the expected output? What do you see instead?
run the program. The program will show a white window, and in the output window the line
First-chance exception at 0x695ad127 in Chapt2.exe: 0xC0000005: Access violation reading location 0x00000000.
What version of the product are you using? On what operating system? Windows 7, x64.
Please provide any additional information below.
On windows, the line
include "stdafx.h"
needs to be added at the top in order for it to work. Other than that, it's a straight copy/paste of code 2.1.c
Comment #1
Posted on Jun 24, 2011 by Happy Rabbitalso tried changing
glEnableVertexAttribArray(0); to glEnableVertexAttribArray(18);
removes the access violation error, but still just shows a black screen.
Comment #2
Posted on Jun 25, 2011 by Quick DogThe "GLuint index"'s value should be less then GL_MAX_VERTEX_ATTRIBS(its value is 16 is most of the graphics cards.)
Try lower it value less then 16.
Comment #3
Posted on Jun 25, 2011 by Happy Rabbitsame issue even changing it to 2 or 3
Comment #4
Posted on Jun 25, 2011 by Helpful GiraffeThanks for filing the issue -- make sure to update the location parameter in your call to glEnableVertexAttribArray as well to the new location, this should fix the white window problem.
However, the reason that index 18 does not work is because this is an AMD driver bug (I assume you are using AMD hardware here). See this post ont he OpenGL forums for details: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=286280
Let me know if this works for you.
Comment #5
Posted on Jun 27, 2011 by Quick Dogshouldn't the value of index need to be less then 16? (traditional hardware)
Comment #6
Posted on Jun 27, 2011 by Helpful GiraffeIt also doesn't work with lower values such as 1, 2, or 3 or any other valid value. There is some updated information in this blog post: http://openglbook.com/glsl-input-layout-qualifier-bug-on-amd-hardware/
Comment #7
Posted on Jun 27, 2011 by Happy RabbitYes, I do have AMD hardware. Looks like it is a hardware bug. Thanks, good to know :)
Status: HardwareIssue
Labels:
Type-Defect
Priority-Medium