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.

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.)

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

#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;
}

Can’t believe it didn’t see that.

Try


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

Works on my machine.

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?

Sounds like you didn’t initialize GLEW.

How Can I do that?
do i just call glewInit()?

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.

thanks for catching that.
problem is solved
thanks people