Error drawing vertex buffer object - android

I have an Android application, that render some 3D-model, loaded from OBJ-file. At first I try to render only vertices (without normals and texture-coord info).
After loading OBJ-file vertices to vector of triangles I try to create VBO:
struct obj_model_t {
GLuint vertex_buf;
GLuint tex_coord_buf;
GLuint normals_buf;
unsigned int count;
};
...
obj_model_t out_model;
// loading triangles to std::vector<glm::vec3> out_vertices;
glGenBuffers(1, &out_model.vertex_buf);
glBindBuffer(GL_ARRAY_BUFFER, out_model.vertex_buf);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * out_vertices.size(), &out_vertices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
And then, in render function I try to bind this VBO and draw triangles from that:
void engine_t::render(double elapsedTime) {
// clear buffer and other preparations for render
mat4 mvp = camera_.projection_matrix() * camera_.view_matrix();
glUseProgram(gProgram);
checkGlError("glUseProgram");
glUniformMatrix4fv(g_uMVPMatrix_Handle, 1, GL_FALSE, &mvp[0][0]);
glBindBuffer(GL_ARRAY_BUFFER, model_.vertex_buf);
checkGlError("glBindBuffer");
glEnableVertexAttribArray(g_vPosition_Handle);
checkGlError("glEnableVertexAttribArray");
glVertexAttribPointer(g_vPosition_Handle, 3, GL_FLOAT, GL_FALSE, 0, (void *)0);
checkGlError("glVertexAttribPointer");
glDrawArrays(GL_TRIANGLES, 0, model_.count); // E/Adreno200-ES20(27772): gl_draw_error_checks:418>: GL_INVALID_OPERATION
checkGlError("glDrawArrays"); // after glDrawArrays glError (0x502)
glDisableVertexAttribArray(g_vPosition_Handle);
checkGlError("glDisableVertexAttribArray");
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
But if I replace out_vertices from loading function to global space and use:
glVertexAttribPointer(g_vPosition_Handle, 3, GL_FLOAT, GL_FALSE, 0, (void *)&out_vertices[0]);
without binding model_.vertex_buf (without call glBindBuffer(GL_ARRAY_BUFFER, model_.vertex_buf);) my model renders normally.
How I can fix this problem and use VBO to draw my vertices?

Related

Android OpenGl ES 3.0 update VBO data on button click?

Is there any way to draw mesh dynamically.
like on press of a button send new float array to openGL ES 30 VBO.
currently i draw both rectangle and triangle STATIC in Native C++ they are visible, But when i pass triangle array from java using JNI. I got an error
call to OpenGL ES API with no current context (logged once per thread)
Native C++.
GLuint fvao, bvao;
GLuint VBO[2];
void setupBuffers() {
glGenVertexArrays(1,&bvao);
glBindVertexArray(bvao);
glGenBuffers(1, &VBO[0]);
glBindBuffer(GL_ARRAY_BUFFER, VBO[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(rect), rect, GL_STATIC_DRAW);
.
.
.
// Triangle --------------------------------------
glGenVertexArrays(1,&fvao);
glBindVertexArray(fvao);
glGenBuffers(1, &VBO[1]);
glBindBuffer(GL_ARRAY_BUFFER, VBO[1]);
glBufferData(GL_ARRAY_BUFFER, 0, nullptr, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0); // pos
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid*)(0 * sizeof(GLfloat)));
glEnableVertexAttribArray(1); // color
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
glEnableVertexAttribArray(2); // texture
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid*)(6 * sizeof(GLfloat)));
glBindVertexArray(0); //Unbind VAO
}
// UPDATE -----------------------
void updateBuffer(float triangle[]) {
glBindBuffer(GL_ARRAY_BUFFER, VBO[1]); //Bind array for OpenGL to use
glBufferData(GL_ARRAY_BUFFER, sizeof(triangle), triangle, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
// update Buffer JNI
extern "C" JNIEXPORT void JNICALL
Java_com_test_nativetest_GL3JNILib_update(JNIEnv * env, jclass obj, jfloatArray triangle)
{
updateBuffer(triangle);
}
If anyone can tell me what i am missing or doing wrong. Any help would be appreciated.

OpenGl error 1281 after setting gl_fragColor

I just started programming opengl-es 2.0 and I'm currently struggling to find an issue concerned with setting the color of a wavefront object im drawing (https://pastebin.com/cEvpj8rt). The drawing is working just fine until I start to manipulate the color at which point im being confronted with opengl error 1281 and I'm unable to pinpoint the cause in my code. I've broken down the shader code to what I believe is the bare minimum required for the fragment shader to work:
void main() {
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
To eliminate any additional source of error I am setting the color with a constant value as can be seen above. I doubt the error lies with the simple code above but is concerned with the code in my adapted renderer implementation. (it is based on the renderer that came with a sample from the ar-core github repo. The full code of the initial renderer can be found here: https://github.com/google-ar/arcore-android-sdk/blob/master/samples/java_arcore_hello_ar/app/src/main/java/com/google/ar/core/examples/java/helloar/rendering/ObjectRenderer.java while the adapted version can be seen here: https://pastebin.com/9cmKVnLV) Below you can find an excerpt of the code responsible for setting up and drawing the object. I reckoned the issue to be connected to the texturing which is why I removed the code.
I know its a bit much to ask for help given my lack of understanding on the matter at hand but I'd be glad for any hint/advice at this point. The error occurs after the first draw in the following method:
public void draw(float[] cameraView, float[] cameraPerspective) {
multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0);
multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0);
glUseProgram(mProgram);
glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferId);
glVertexAttribPointer(mPositionAttribute, COORDS_PER_VERTEX,
GL_FLOAT, false, 0, mVerticesBaseAddress);
glVertexAttribPointer(mNormalAttribute, 3,
GL_FLOAT, false, 0, mNormalsBaseAddress);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Set the ModelViewProjection matrix in the shader.
glUniformMatrix4fv(mModelViewUniform, 1,
false, mModelViewMatrix, 0);
glUniformMatrix4fv(mModelViewProjectionUniform, 1,
false, mModelViewProjectionMatrix, 0);
glEnableVertexAttribArray(mPositionAttribute);
glEnableVertexAttribArray(mNormalAttribute);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferId);
glDrawElements(GL_TRIANGLES, mIndexCount, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(mPositionAttribute);
glDisableVertexAttribArray(mNormalAttribute);
// this is where the error is detected
OpenGlHelper.checkGLError(TAG, "After draw");
}
Here the method which is used for initialization:
public void createOnGlThread(Context context) throws IOException {
InputStream objInputStream = context.getAssets()
.open(OBJ_ASSET_NAME);
Obj obj = ObjReader.read(objInputStream);
obj = ObjUtils.convertToRenderable(obj);
IntBuffer wideIndices = ObjData.getFaceVertexIndices(obj, 3);
FloatBuffer vertices = ObjData.getVertices(obj);
FloatBuffer texCoords = ObjData.getTexCoords(obj, 2);
FloatBuffer normals = ObjData.getNormals(obj);
ShortBuffer indices = ByteBuffer.allocateDirect(2 * wideIndices.limit())
.order(ByteOrder.nativeOrder()).asShortBuffer();
while (wideIndices.hasRemaining()) {
indices.put((short) wideIndices.get());
}
indices.rewind();
int[] buffers = new int[2];
glGenBuffers(2, buffers, 0);
mVertexBufferId = buffers[0];
mIndexBufferId = buffers[1];
// Load vertex buffer
mVerticesBaseAddress = 0;
mTexCoordsBaseAddress = mVerticesBaseAddress + 4 * vertices.limit();
mNormalsBaseAddress = mTexCoordsBaseAddress + 4 * texCoords.limit();
final int totalBytes = mNormalsBaseAddress + 4 * normals.limit();
glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferId);
glBufferData(GL_ARRAY_BUFFER, totalBytes, null, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, mVerticesBaseAddress,
4 * vertices.limit(), vertices);
glBufferSubData(GL_ARRAY_BUFFER, mTexCoordsBaseAddress,
4 * texCoords.limit(), texCoords);
glBufferSubData(GL_ARRAY_BUFFER, mNormalsBaseAddress,
4 * normals.limit(), normals);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Load index buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferId);
mIndexCount = indices.limit();
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 2 * mIndexCount,
indices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
OpenGlHelper.checkGLError(TAG, "OBJ buffer load");
mProgram = glCreateProgram();
glAttachShader(mProgram, OpenGlHelper.loadGLShader(TAG, context,
GL_VERTEX_SHADER, R.raw.sphere_vertex));
glAttachShader(mProgram, OpenGlHelper.loadGLShader(TAG, context,
GL_FRAGMENT_SHADER, R.raw.sphere_fragment));
glLinkProgram(mProgram);
glUseProgram(mProgram);
OpenGlHelper.checkGLError(TAG, "Program creation");
mModelViewUniform = glGetUniformLocation(mProgram, "u_ModelView");
mModelViewProjectionUniform =
glGetUniformLocation(mProgram, "u_ModelViewProjection");
mPositionAttribute = glGetAttribLocation(mProgram, "a_Position");
mNormalAttribute = glGetAttribLocation(mProgram, "a_Normal");
OpenGlHelper.checkGLError(TAG, "Program parameters");
setIdentityM(mModelMatrix, 0);
}

GLES error: vertex attribute array is enabled with no data bound

New to OpenGl and currently working on Android NDK. I am currently getting this error, and can't figure it out. I feel like it's something basic, but I could be wrong. the appRender is run every frame by the java render side.
Error:
E/emuglGLESv2_enc: glDrawArrays: a vertex attribute array is enabled with no data bound
app.cpp:
void appRender(long tick, int width, int height){
const float vertices[] =
{
0.0f, 0.5f, 0.0f,
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f
};
glClear(GL_COLOR_BUFFER_BIT);
GLuint vertexBuffer;
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// Setup colors for each vertex
GLfloat colors[3*4];
for (int v = 0; v < 3; v++){
colors[4*v+0] = 0;
colors[4*v+1] = 1;
colors[4*v+2] = 0;
colors[4*v+3] = 1;
}
// Setup color buffer
GLuint colorBuffer;
glGenBuffers(1, &colorBuffer);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glVertexAttribPointer(
1,
3,
GL_FLOAT,
GL_FALSE,
0,
(void*)0
);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glVertexAttribPointer(
1,
4,
GL_FLOAT,
GL_FALSE,
0,
(void*)0
);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glBindTexture(GL_TEXTURE_2D, 0);
//textRenderer.RenderTexts(0.5f);
//boxRenderer.RenderBoxes(0.5f);
}
So I found it, and yes, I'm bad.
glVertexAttribPointer(1,3,...) -> glVertexAttribPointer(0,3,...)

Opengles 2.0 without VAO

I was going along just fine working on an opengles 2.0 application until I tested it on an older phone that doesn't support VAO and now I seem to have fallen into a marsh.
I started using opengl after VAO's were sorta standard and everywhere so I never had to render without using one. Now that I have to write code that supports it I am having some trouble.
vertex shader
attribute vec3 position;
attribute vec4 icolor;
varying vec4 fcolor;
void main()
{
gl_Position = vec4(position, 1.0);
fcolor = icolor;
}
fragment shader
precision mediump float;
varying vec4 fcolor;
void main (void)
{
gl_FragColor = fcolor;
}
application side of things
init code:
glGenBuffers(1, &verticesBuffer);
glBindBuffer(GL_ARRAY_BUFFER, verticesBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(rend2d->vertices), rend2d->vertices, GL_STATIC_DRAW);
glGenBuffers(1, &indicesBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rend2d->indices), rend2d->indices, GL_STATIC_DRAW);
glGenBuffers(1, &colorBuffer);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(rend2d->colors), rend2d->colors, GL_STATIC_DRAW);
rendering code:
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(sp);
GLint posLoc = glGetAttribLocation(sp, "position");
GLint colLoc = glGetAttribLocation(sp, "icolor");
glBindBuffer(GL_ARRAY_BUFFER, verticesBuffer);
glVertexAttribPointer(posLoc, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glVertexAttribPointer(colLoc, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer);
glDrawElements(GL_TRIANGLES, rend2d->vertexCount, GL_UNSIGNED_INT, 0);
my error might be glaringly obvious but I just don't see what part I am currently not doing correctly and hoping to get some help with semi-modern opengl. This is mainly to provide support for apps that are opengles 2.0 but do not support the
GL_OES_vertex_array_object extension.
I wanted to post the answer because it was many little things that were wrong. First I'll post the data structure that I was using to hold my gl data.
typedef struct
{
GLuint vertexCount;
GLfloat vertices[12];
GLfloat colors[16];
GLuint indices[6];
GLfloat texCoords[8];
} renderable2d;
the first problem was here. As #derhass pointed out on the irc channel opengles 2.0 doesn't support 32bit indices. So the first step was to change that gluint above to glushort
typedef struct
{
GLushort vertexCount; //I made this a short as well
GLfloat vertices[12];
GLfloat colors[16];
GLushort indices[6]; //make this a short instead of an int
GLfloat texCoords[8];
}
once that part was fixed, then I had to generate my buffers, bind them and put the data in them, then unbind.
//bind n setup vertices
glGenBuffers(1, &verticesBuffer);
glBindBuffer(GL_ARRAY_BUFFER, verticesBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(rend2d->vertices), rend2d->vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//bind n setup colors
glGenBuffers(1, &colorBuffer);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(rend2d->colors), rend2d->colors, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//bind n setup indices
glGenBuffers(1, &indicesBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rend2d->indices), rend2d->indices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
and finally on to the rendering code
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(sp);
glBindBuffer(GL_ARRAY_BUFFER, verticesBuffer);
glEnableVertexAttribArray(posLoc);
glVertexAttribPointer(posLoc, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glEnableVertexAttribArray(colLoc);
glVertexAttribPointer(colLoc, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer);
glDrawElements(GL_TRIANGLES, rend2d->vertexCount, GL_UNSIGNED_SHORT, 0);
after doing all that I got things sorted out on both devices. Just for clarity rend2d is just a textured quad so rend2d->vertexCount = 6; With more complex models well you'll get that info somewhere else.
1) GL_UNSIGNED_INT is not officially supported in ES 2.0 as an index type
your GL_UNSIGNED_INT must be either one GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT
2) Assume they are friends when you use VBO without VAO.
glBindBuffer();
glVertexAttribPointer();
glEnableVertexAttribArray(); // you don't call it
In init()
GLint posLoc = glGetAttribLocation(sp, "position");
GLint colLoc = glGetAttribLocation(sp, "icolor");
glGenBuffers(1, &verticesBuffer);
glBindBuffer(GL_ARRAY_BUFFER, verticesBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(rend2d->vertices), rend2d->vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(posLoc);
glVertexAttribPointer(posLoc, GL_FLOAT,0,0,0);
glGenBuffers(1, &colorBuffer);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(rend2d->colors), rend2d->colors, GL_STATIC_DRAW);
glEnableVertexAttribArray(colLoc)
glVertexAttribPointer(colLoc, GL_FLOAT,0,0,0);
In rendering()
glBindBuffer(GL_ARRAY_BUFFER, verticesBuffer);
glEnableVertexAttribArray(posLoc);
glVertexAttribPointer(posLoc, GL_FLOAT,0,0,0);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glEnableVertexAttribArray(colLoc)
glVertexAttribPointer(colLoc, GL_FLOAT,0,0,0);
3) Just don't use VAOs in ES 2.0 in which, VAO is not officially supported. However, IOS does as an exception.

Loading another 3D model on touch in qualcomm sdk for android

I am using qualcomm sdk and using the ImageTargets sample application to develop an augmented reality application. Application runs fine but i want to load another 3D model when the user touches the screen i.e. when camera view starts and comes to marker then the teapot 3D model loads and then user touches the screen a new model should load. The following are the steps i am doing :-
I have got the new 3D model and got its .h file . I have included it in assets folder
and also included it in ImageTargets.cpp file i.e. #include "./banana.h"
Then i have added ontouchEvent in ImageTargets.java file which calls another function in
ImageTargets.cpp which updates the modelID variable.
Following is the editted code of the ImageTargets.cpp in renderFrame function
#ifdef USE_OPENGL_ES_1_1
// Load projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(projectionMatrix.data);
// Load model view matrix:
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelViewMatrix.data);
glTranslatef(0.f, 0.f, kObjectScale);
glScalef(kObjectScale, kObjectScale, kObjectScale);
// Draw object:
glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
if (modeId == 0){
glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &teapotTexCoords[0]);
glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &teapotVertices[0]);
glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &teapotNormals[0]);
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &teapotIndices[0]);
}
else{
glVertexPointer(3, GL_FLOAT, 0, bananaVerts);
glNormalPointer(GL_FLOAT, 0, bananaNormals);
//glTexCoordPointer(2, GL_FLOAT, 0, bananaTexCoords);
glDrawArrays(GL_TRIANGLES, 0 , bananaNumVerts);
}
#else
LOG("When tracker found 4");
QCAR::Matrix44F modelViewProjection;
SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
&modelViewMatrix.data[0]);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
&modelViewMatrix.data[0]);
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
&modelViewMatrix.data[0] ,
&modelViewProjection.data[0]);
glUseProgram(shaderProgramID);
if (modelId == 0)
{
LOG("ModelID is 0");
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &teapotVertices[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &teapotNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &teapotTexCoords[0]);
}
else
{
LOG("ModelID is 1");
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &bananaVerts[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &bananaNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &bananaTexCoords[0]);
}
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0] );
if (modelId == 0)
{
LOG("ModelID is 0");
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &teapotIndices[0]);
}
else{
LOG("ModelID is 1");
glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);
}
SampleUtils::checkGlError("ImageTargets renderFrame");
#endif
Edit
I solved the problem though if using glDrawElements then you should not use glDrawArrays. So i created another .h file from some 3d .obj file and it started working.

Categories

Resources