Texturing a VBO

Started by
10 comments, last by JoshuaWaring 10 years, 7 months ago

Since vertexShader is a pointer to a char, *vertexShader is of type char, and thus sizeof(*vertexShader) is equivalent to sizeof(char). In order to use sizeof to get the length of the string, you have to make vertexShader an array, and take the size of the array. I also recommend you insert new-line characters at each new line so that you can get some sensible line numbers from the error messages.

const char vertexShader[] = ""
    "void main(void){\n"
    "    gl_TexCoord[0] = gl_MultiTexCoord0;\n"
    "    gl_Position = ftransform();\n"
    "}\n";
 
int vertexSize = sizeof(vertexShader);
Advertisement

I'm still having issues drawing a simple texture to the screen :(, now nothing will apear and the drawArrays now returns a 1282 which has stumped me. Instead of creating a new thread I thought I would revive this one. I wanted to make sure that all my functions are correct.

Here is the link to the whole function to keep the post size down. http://www.pastebucket.com/19567

Thank you for any help at all.


        unsigned int VertexBufferObject[1]; 
	GLuint error = glGetError();
	glEnable(GL_TEXTURE_2D);
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, tex.textureID);

	// Pass texture to shader
	glUniform1i(glGetUniformLocation(shaderProgram, "colorMap"), GL_TEXTURE0);

	glGenBuffers(1, VertexBufferObject);
	glBindBuffer(GL_ARRAY_BUFFER, *VertexBufferObject);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_buffer), vertex_buffer, GL_STATIC_DRAW); 
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, 0, 0); 

	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);// Returns error 1282

	glDisableVertexAttribArray(0);

	glBindTexture(GL_TEXTURE_2D, 0); 
	glDeleteBuffers(1, VertexBufferObject);
	glDisable(GL_TEXTURE_2D); 

This topic is closed to new replies.

Advertisement