Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: glmultidrawelement

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Location
    Virginia, USA
    Posts
    12

    glmultidrawelement

    I get errors about type casting
    I use visual studio 2010
    I believe i have linked all .dll .lib correctly

    I tried calling glewInit() and it still does not work.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    892
    How does a erroneous type cast have anything to do with glewInit()? How does linking to the correct export libraries have anything to do with a compile time error?

    Most importantly, how do you expect us to help you without telling us what the actual error is? Just to be clear, type casting has nothing to do with OpenGL. It's a feature of the programming language you're using not of one of the APIs. (And even if you have some library casting functionality it will still be layered on language features.)

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2012
    Location
    Virginia, USA
    Posts
    12
    I thought you guys could help me because this seemed like common errors people get.


    I am trying to compile the code from the excerpt from redbook
    The errors I get:
    error C2664:'void (GLenum,const GLsizei *,GLenum,const GLvoid **,GLsizei)' : cannot convert parameter 4 from 'GLvoid *[2]' to 'const GLvoid **'
    1> Conversion loses qualifiers
    error C2664: 'void (GLenum,const GLsizei *,GLenum,const GLvoid **,GLsizei)' : cannot convert parameter 2 from 'int' to 'const GLsizei *'
    1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

    code below

    Code :
    [FONT=Courier New]#pragma comment( lib, "glew32.lib" )
    #include <gl/glew.h>
    #include <gl/glut.h>
     
     
    void Draw() {
    	glClear(GL_COLOR_BUFFER_BIT);
    	glColor3f(1.0, 1.0, 1.0);
     
     
    	static GLint vertices[] = {25, 25,
    			         100, 325,
    			         175, 25,
    			         175, 325,
    			         250, 25,
    			         325, 325};
    	glEnableClientState(GL_VERTEX_ARRAY);
    	glVertexPointer(2, GL_INT, 0, vertices);
     
    	static GLubyte oneIndices[] = {0, 1, 2, 3, 4, 5, 6};
    	static GLubyte twoIndices[] = {7, 1, 8, 9, 10, 11};
    	static GLsizei count[] = {7, 6};
    	static GLvoid * indices[2] = {oneIndices, twoIndices};
    	glMultiDrawElements(GL_LINE_STRIP, count, GL_UNSIGNED_BYTE,indices, 2);
    }
     
    void Initialize() {
    	glClearColor(0.0, 0.0, 0.0, 0.0);
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    }
     
    int main(int iArgc, char** cppArgv) {
    	glutInit(&iArgc, cppArgv);
    	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    	glutInitWindowSize(250, 250);
    	glutInitWindowPosition(200, 200);
    	glutCreateWindow("hello");
    	Initialize();
    	glutDisplayFunc(Draw);
    	glutMainLoop();
    	return 0;
    }[/FONT]

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    892
    Can't believe it didn't see that.

    Try

    Code :
    static const GLvoid * indices[2] = {oneIndices, twoIndices};
    glMultiDrawElements(GL_LINE_STRIP, count, GL_UNSIGNED_BYTE, indices, 2);

    Works on my machine.
    Last edited by thokra; 07-30-2012 at 12:38 PM.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2012
    Location
    Virginia, USA
    Posts
    12
    Thanks, that took care of the error.
    But I get an exception
    Unhandled exception at 0x00000000 in GL.exe: 0xC0000005: Access violation. w
    Does yours display something with the exact same code above?

  6. #6
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421
    Sounds like you didn't initialize GLEW.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2012
    Location
    Virginia, USA
    Posts
    12
    How Can I do that?
    do i just call glewInit()?

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    941
    The problem is with the indices man, considering you have 2 component attributes you only have a total of seven vertices so any index greater than 6 will be out of bounds.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  9. #9
    Junior Member Newbie
    Join Date
    Jul 2012
    Location
    Virginia, USA
    Posts
    12
    thanks for catching that.
    problem is solved
    thanks people

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •