glVertexAttribPointer error - Printable Version +- Forums (http://www.scratchpadgames.net/forums) +-- Forum: Main Forums (http://www.scratchpadgames.net/forums/forumdisplay.php?fid=1) +--- Forum: Help my code won't work?? (http://www.scratchpadgames.net/forums/forumdisplay.php?fid=22) +--- Thread: glVertexAttribPointer error (/showthread.php?tid=48) Pages:
1
2
|
glVertexAttribPointer error - pahendriks - 03-16-2018 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 RE: glVertexAttribPointer error - Brian Beuken - 03-16-2018 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 RE: glVertexAttribPointer error - pahendriks - 03-16-2018 (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. found it, missing &. RE: glVertexAttribPointer error - Brian Beuken - 03-16-2018 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 RE: glVertexAttribPointer error - Brian Beuken - 03-16-2018 (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. yup good job... I'll move this message now RE: glVertexAttribPointer error - pahendriks - 03-16-2018 (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 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; } RE: glVertexAttribPointer error - Brian Beuken - 03-16-2018 hmmm, how did you get to that 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 RE: glVertexAttribPointer error - pahendriks - 03-16-2018 (03-16-2018, 07:57 PM)Brian Beuken Wrote: hmmm, how did you get to that 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.... RE: glVertexAttribPointer error - Brian Beuken - 03-16-2018 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 RE: glVertexAttribPointer error - pahendriks - 03-16-2018 (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. 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? |