0
votes

I'm refering by my trouble to:

The OpenGL Programming Guide: The Official Guide to Learning OpenGL Version 4.3

In the 8th edition

Example 2.4 Initializing Uniform Variables in a Named Uniform Block:

I tryed to compile this Code example, but got compiling errors (as with every example of that book untill now)

After I wasn't able to find anyone else had this problem (what is strange in my eyes after I found the error source by my self), I tryed to figgure out what could be the problem.

        memcpy(buffer + offset[Scale], &scale, size[Scale] * TypeSize(type[Scale]));
        memcpy(buffer + offset[Translation], &translation, size[Translation] * TypeSize(type[Translation]));
        memcpy(buffer + offset[Rotation], &rotation, size[Rotation] * TypeSize(type[Rotation]));
        memcpy(buffer + offset[Enabled], &enabled, size[Enabled] * TypeSize(type[Enabled]));

This for lines are causing the error, where buffer is declared as: GLvoid *.

So my question is: Why they try to do pointer arithmetic on a void pointer (As I'm guessing, thats what GLvoid * is)?

And what I probably have to cast it to, that it gets teh right length memcpyed?

as I'm new to openGL and can't get really get the context of that (300 lines) example to get by my self what the GLvoid * is working with.

Can any one who knows the book, or at least the example tell me what I had to cast the Dst part of memcpy to? Or tell me what else I'm maybe doing wrong and how to solve it?

1
What are the exact errors you are getting? Try also compiling with e.g. clang, its error message will be similar, but might just provide that word or phrase that gives you a better hint on how to attack this problem.rubenvb
its simply: "1>c:\users\dhein\documents\visual studio 2010\projects\shadergettingstarted\shadergettingstarted\shadergettingstarted.cpp(199): error C2036: 'GLvoid *' : unknown size "dhein
Note this may not have anything to do with your current problem... If you're using the Visual Studio OpenGL headers, you have version 1.1 at your disposal. That sucks, but yeah, reality is a... euhm... not nice. You'll need some helper library that gets you up-to-date functionality at runtime. See e.g. this tutorial which uses GLEW for this purpose (scroll down and grab the pdf, the code on the website is missing all <header_names> after the #include statements...rubenvb
@Axalo: yep as I stated in my OP, thats the problem.dhein
@rubenvb: I'm using glut and glew, as they are part of the headers especially provided by the book for tutorial purposes. So It is not expected they missed something in it, what they use in their examples (but by the samples up to now, It wouldn't suprise me anymore.)dhein

1 Answers

1
votes

You cannot add to a void pointer since it's size is undefined.
Casting it to char * should solve your issue.