vertex-array

OpenGL vertex buffer confusion

泪湿孤枕 提交于 2021-02-17 12:45:50
问题 Would someone care to explain the difference to be between a VertexBuffer , a VertexArray , a VertexBufferObject , and a VertexArrayObject ? I'm not even sure if these are all terms for different things, but I've seen all of them appear in the OpenGL spec. I know that a VertexBuffer simply contains vertices and nothing else, once bound, and once I've set the vertex pointers, I can use DrawArrays to draw it. I've done it this way many times. I am using what I think is a VertexArray, which

Why does OpenGL's glDrawArrays() fail with GL_INVALID_OPERATION under Core Profile 3.2, but not 3.3 or 4.2?

北城以北 提交于 2020-01-02 04:54:23
问题 I have OpenGL rendering code calling glDrawArrays that works flawlessly when the OpenGL context is (automatically / implicitly obtained) 4.2 but fails consistently (GL_INVALID_OPERATION) with an explicitly requested OpenGL core context 3.2. (Shaders are always set to #version 150 in both cases but that's beside the point here I suspect.) According to specs, there are only two instances when glDrawArrays() fails with GL_INVALID_OPERATION: "if a non-zero buffer object name is bound to an

WebGL - which API to use?

谁说胖子不能爱 提交于 2019-12-23 05:50:49
问题 I want to draw multiple polygon shapes (where each shape has it's own set of vertices). I want to be able to position these shapes independently of each other. Which API can i use to set the a_Position for the vertex shader? A) gl.vertexAttrib3f B) gl.vertexAttribPointer + gl.enableVertexAttribArray thanks. 回答1: Your question makes it sound like you're really new to WebGL? Maybe you should read some tutorials? But in answer to your question: gl.vertexAttrib3f only lets you supply a single

NDK OpenGL undefined reference to glVertexPointer

佐手、 提交于 2019-12-22 10:44:36
问题 When compiling the following C code with ndk-build in Terminal (I'm running Ubuntu): #include <jni.h> #include <GLES/gl.h> #include <GLES/glext.h> #include "org_opengldrawinjni_DrawinJNI.h" JNIEXPORT void JNICALL Java_org_opengldrawinjni_DrawinJNI_Draw (JNIEnv *envptr, jobject jobj) { GLfloat vertices[] = { 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 }; GLubyte indices[] = { 0, 1, 2 }; glVertexPointer(3, GL_FLOAT, 0, vertices); glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, indices); }

Hard time understanding indices with glDrawElements

寵の児 提交于 2019-12-22 05:10:23
问题 I'm trying to draw a terrain with GL_TRIANGLE_STRIP and glDrawElements but I'm having a really hard time understanding the indices thing behind glDrawElements ... Here's what I have so far: void Terrain::GenerateVertexBufferObjects(float ox, float oy, float oz) { float startWidth, startLength, *vArray; int vCount, vIndex = -1; // width = length = 256 startWidth = (width / 2.0f) - width; startLength = (length / 2.0f) - length; vCount = 3 * width * length; vArray = new float[vCount]; for(int z

Generating Smooth Normals from active Vertex Array

强颜欢笑 提交于 2019-12-21 23:04:01
问题 I'm attempting to hack and modify several rendering features of an old opengl fixed pipeline game, by hooking into OpenGl calls, and my current mission is to implement shader lighting. I've already created an appropriate shader program that lights most of my objects correctly, but this game's terrain is drawn with no normal data provided. The game calls: void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); and void glDrawElements(GLenum mode, GLsizei count,

Best way to draw scatter plot with lots of data points in C++ using OpenGL

会有一股神秘感。 提交于 2019-12-21 16:56:10
问题 I'm writing a program in C++ that acquires 4 dimensional points data over a UDP socket and then plots the data in 6 separate 2D scatter plots. For example if we name the dimensions: A,B,C,D the six 2d plots would be AxB, AxC, AxD, BxC, BxD, and CxD. Over the course of a few hours the program accrues ~50K points. Currently I plot each point once, using immediate mode. I don't clear the buffer between draw calls so previously plotted points persist until the buffer is cleared. I'm not happy

Fastest way to load arrays of vertices and face indices into OpenGL-ES?

╄→гoц情女王★ 提交于 2019-12-19 09:37:08
问题 I'm trying to load .obj files that I've formatted into: vertexX vertexY vertexZ normalX normalY normalZ and: index1 index2 index3 format into vector and vector arrays, which I then directly render in Opengl-ES. My problem is, when I try to load the model into the arrays, it takes about 40 seconds to load them in. I'm not sure why it's going so slow, I've seen others code load the same model in just a few seconds. Any suggestions? My code for loading the file is below: -(void)loadModel:

In the stock OpenGL ES app on iOS 5.1, are they really using the vertex arrays they declare?

牧云@^-^@ 提交于 2019-12-13 19:26:13
问题 In the stock OpenGL ES app you get (when you create a new "OpenGL game" in XCode), in the setupGL function, there is: glEnable(GL_DEPTH_TEST); //glGenVertexArraysOES( 1, &_vertexArray ) ; // va's are not being used! //glBindVertexArrayOES( _vertexArray ) ; // we comment these out // to no ill effect -- are these calls extraneous? glGenBuffers( 1, &_vertexBuffer ) ; glBindBuffer( GL_ARRAY_BUFFER, _vertexBuffer ) ; glBufferData( GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL

Understanding normals indices with Wavefront Obj

别来无恙 提交于 2019-12-09 19:17:22
问题 I've written a C++ Obj file loader that I can't get to work correctly. The problem is that while parsing a simple obj file like the following: # Blender v2.62 (sub 0) OBJ File: '' # www.blender.org mtllib cube.mtl o Cube v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -0.999999 v 0.999999 1.000000 1.000001 v -1.000000 1.000000 1.000000 v -1.000000 1.000000 -1.000000 vn 0.000000 0.000000 -1.000000