ok, so i used LWJGL3 in Java, but now, i want want to code in C++ using GLFW, and for rendering, i want to use VAOs and VBOs as it is the new rendering way, but, i dony know how to do it, can home one help me? plz?
Code (Java(i Need it in C++)):
private FloatBuffer storeDataInFloatBuffer(float[] data) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
Can someone replay?
The C++ equivalent of:
float[] data = {1.0f, 2.0f, 3.0f};
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
is (drumm-roll):
float data[] = {1.0f, 2.0f, 3.0f};
You are basically asking "Please, teach me C++".
You should look elsewhere.
If you use OpenGL and search for a good OpenGL tutorial using C++ and GLFW, then: https://learnopengl.com/
The "Hello Triangle" section also has the code for uploading a float array into an OpenGL buffer object: https://learnopengl.com/Getting-started/Hello-Triangle
Oh ok, thx, i actually know C++, but, i did not know that you can use a float[] isted of a FloatBuffer, thx btw :)
If you knew C++, then you'd also know that there is no such thing as a FloatBuffer.
And you'd also know the C signature of e.g. glBufferData:
void glBufferData( GLenum target,
GLsizeiptr size,
const void * data,
GLenum usage);
and know that you are supposed to pass your data directly as the (const void*) argument.
Hey,
I'm actually new to OpenGL in C/C++. And i know that there is nothing as a FloatBuffer, so i did not know how OpenGL will take it, os i posted it here, BTW sorry for the late responce, i did not see that you posted a replay here.
Regrads,
Electronics Boy(Nikunj)