Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
glVertexAttribPointer error
#1
These function calls give errors (section: add some code):

glVertexAttribPointer(p_state->user_data->positionLoc, 3, GL_FLOAT, GL_FALSE, 5*sizeof(GLfloat), RectVertices);
    // Load the texture coordinate
    glVertexAttribPointer(p_state->user_data->texCoordLoc, 2, GL_FLOAT, GL_FALSE, 5*sizeof(GLfloat), RectVertices[3]);


Severity    Code    Description    Project    File    Line    Suppression State
Error        [Clang IntelliSense] Error: no matching function for call to 'glVertexAttribPointer'    GameProject1    c:\openglesprojects\gameproject1\gameproject1\GameProject1.cpp    248    


Severity    Code    Description    Project    File    Line    Suppression State
Error        cannot convert 'GLfloat {aka float}' to 'const GLvoid* {aka const void*}' for argument '6' to 'void glVertexAttribPointer(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*)'    GameProject1    C:\OpenGLESProjects\GameProject1\GameProject1\GameProject1.cpp    248    

What is wrong?

Patrick
Reply
#2
Its not an error in the book Patrick, there's actually a fault in the way you typed it in, i would really like you to review your code and try to spot the error yourself, but if you get totally stuck (it can happen) I'll tell you in an hour.

but as this is not an actual error in the book, I will move post when you find the problem
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#3
(03-16-2018, 07:29 PM)Brian Beuken Wrote: Its not an error in the book Patrick,  there's actually a fault in the way you typed it in, i would really like you to  review your code and try to spot the error yourself, but if you get totally stuck (it can happen) I'll tell you in an hour.

but as this is not an actual error in the book, I will move post when you find the problem

found it, missing &.
Reply
#4
BTW this is a good example of an error message that actually makes sense, a lot of C++ errors are very confusing but this one

Error cannot convert 'GLfloat {aka float}' to 'const GLvoid* {aka const void*}' for argument '6' to 'void glVertexAttribPointer(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*)' GameProject1

Tells you a lot, the 6'th argument is expecting a GLvoid* (a pointer to an address) but it has a GLfloat. That should give you a clue where the error is.

Nearly all errors are due to typo's so its important to get used to that annoying fact of life, that we will make our own errors most of the time, and can't always see them
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#5
(03-16-2018, 07:44 PM)pahendriks Wrote:
(03-16-2018, 07:29 PM)Brian Beuken Wrote: Its not an error in the book Patrick,  there's actually a fault in the way you typed it in, i would really like you to  review your code and try to spot the error yourself, but if you get totally stuck (it can happen) I'll tell you in an hour.

but as this is not an actual error in the book, I will remove post when you find the problem

found it, missing &.

yup

good job... I'll move this message now
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#6
(03-16-2018, 07:44 PM)pahendriks Wrote:
(03-16-2018, 07:29 PM)Brian Beuken Wrote: Its not an error in the book Patrick,  there's actually a fault in the way you typed it in, i would really like you to  review your code and try to spot the error yourself, but if you get totally stuck (it can happen) I'll tell you in an hour.

but as this is not an actual error in the book, I will remove post when you find the problem

found it, missing &.

But no rectangle after compiling.

Can it be that this part has errors? Is the red code on the right place?

#include "MyFiles.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
MyFiles::MyFiles()
{}

MyFiles::~MyFiles()
{}

char* MyFiles::Load(char const *filename, int* width, int* height)
{
    unsigned char *data = stbi_load(filename, width, height, &comp, 4);
    
    MyFiles FileHandler;
    int Width, Height;
    char* OurRawData = FileHandler.Load((char*)"../Lenna.png", &Width, &Height);
    if (OurRawData == NULL) printf("We failed to load\n");
    
    return (char*) data;
}
Reply
#7
hmmm, how did you get to that Big Grin
the char* MyFiles::Load(.....) method is itself the load, the text in red is how you would use it in your main function
If you think about what's happening. you are loading data from a filename into *data, but then you are loading something else into *OurRawData.

So basically 2 things are being loaded here....

But if you look at the return it only returns the 1st value at *data

So the red code is in totally the wrong place, it should be part of your main function
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#8
(03-16-2018, 07:57 PM)Brian Beuken Wrote: hmmm, how did you get to that Big Grin
the char* MyFiles::Load(.....) method is itself the load, the text in red is how you would use it in your main function
If you think about what's happening. you are loading data from a filename into *data, but then you are loading something else into *OurRawData.

So basically 2 things are being loaded here....

But if you look at the return  it only returns the 1st value at *data

So the red code is in totally the wrong place, it should be part of your main function

When I put the red in main() I get an error that MyFiles is not declared in this scope.

Are sources files going to be downloadable? I'm more busy with typing and correcting than learning the concepts of game programming....
Reply
#9
yes, they will all be available, but the 1st few things I do very much encourage you to type, simply because you need to get used to typing and more important finding out your errors, I have found that cutting and pasting is not very useful for learning how to code.


Can I ask what your level of C++ knowledge is?

If its not declared in this scope, it means you have not included Myfiles.h in your file so that you can then create a MyFiles FileHander.

all C++ cpp files are built as stand alone components of the main project, they create an intermediate filetype called an obj file. The Linker then puts them all together.
To create something in a particular file, the compiler needs to know about it, so if you include the MyFiles.h your compiler knows what you are trying to do.

This is covered in the section LOADING GRAPHICS OR OTHER ASSETS
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#10
(03-16-2018, 08:22 PM)Brian Beuken Wrote: yes, they will all be available, but the 1st few things I do very much encourage you to type, simply because you need to get used to typing and more important finding out your errors, I have found that cutting and pasting is not very useful for learning how to code.


Can I ask what your level of C++ knowledge is?

If its not declared in this scope, it means you have not included Myfiles.h in your file so that you can then create a MyFiles FileHander.

all C++ cpp files are built as stand alone components of the main project, they create an intermediate filetype called an obj file. The Linker then puts them all together.
To create something in a particular file, the compiler needs to know about it, so if you include the MyFiles.h your compiler knows what you are trying to do.

This is covered in the section LOADING GRAPHICS OR OTHER ASSETS

I'm a junior in C++. On my list is spending more time reading some books on C++.

But I followed what is written in the book. And I have a MyFiles.cpp which includes the line #include "MyFiles.h".

But is this MyFiles.cpp included in the project when I try to compile? How can I check that?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)