Good day,
i try to pogramm a Triangle whit OpenGl (glew and GLFW)i´ve rigth noiw do it the 2th time because i forget to save, but when i start to type in glBufferData and in that my data it came a error calledto many arguments in this function(See code downside).
Thanks in advance.``
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "GotGames-Engine", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
//Auf fehler überprüfen
if (glfwInit() != GLEW_OK)
//wen ja schreibe in Konsole ...
std::cout << "error Noobs!" << std::endl;
//Print Version in Console
std::cout << glGetString(GL_VERSION) << std::endl;
//Position für ein Buffer, Wie viele in []
float position[6] =
{
-0.5f, -0.5f,
0.0f, 0.5f,
0.5f, -0.5f
};
//Buffer erstellen (ID)
unsigned int buffer;
//Buffer generienren, Wie viele Buffer generiert werden sollen, Buffer(unsigned int festlegen)
glGenBuffers(1, &buffer);
//Buffer festlgeen, (Vermutlich)Typ, Buffer auswählen
glBindBuffer(GL_ARRAY_BUFFER, buffer);
//Daten festlgen, (Vermutlich)Typ, Nummer die in den Float Position festgelegt habe., Formation (Position)
glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), position, GL_STATIC_DRAW);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
// glBegin(GL_TRIANGLES); out
// glVertex2f(-0.5f, -0.5f); out
// glVertex2f(0.0f, 0.5f); out
// glVertex2f(0.5f, -0.5f); out
// glEnd(); out
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}