OpenGL Hello World Triangle
Why Stack Overflow recommends it
Stack Overflow users link it as the tutorial they followed when their OpenGL triangle code compiles but renders nothing or raises GL errors.
Recommended by 0 people across 0 different months, 2014 to 2018.
What it is
A short 2013 tutorial by Jamie King that draws a first OpenGL triangle. It describes vertex data with glVertexAttribPointer and glEnableVertexAttribArray, draws with glDrawArrays using GL_TRIANGLES, and sets the viewport with glViewport.
What people said
Cites carloabelli · 2014-02 · Stack Overflow · on “OpenGL Does Not Render Triangle”
I am following this tutorial [this video] with a few modifications and have got this code: #define GLSL(src) "#version 330 core\n" #src void MainWindow::initializeGL() { glClearColor(0, 0, 0, 1); // Generate buffers GLfloat verticies[] = { +0.0f, +1.0f, +0.0f, -1.0f, -1.0f, +0.0f, +1.0f, -1.0f, +0.0f, }; GLuint vertexBufferID; glGenBuffers(1, &vertexBufferID); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferID); glBufferData(GL_ARRAY_BUFFER, sizeof(verticies), verticies, GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void *)0); // Generate shaders const char *vertexShaderSrc = GLSL( layout(location = 0) in vec3 pos; void main() { gl_Position.xyz = pos
Cites candronikos · 2015-05 · Stack Overflow · on “glDrawArrays not working. Using GtkGLArea in GTK3”
I'm experimenting with using the GtkGLArea widget at the moment. None of the answers to similar questions seem to pertain to this situation. glClear() can set the background colour just fine but actually drawing arrays of triangles isn't. According to this [this video] tutorial, the code below should work. EDIT: 21/5/2015: Added shaders, still getting same results. New code below Here's the main.c and the SConstruct so you can build with scons: SOLVED: Working code under the heading SOLUTION: main.c the same SConstruct file can be used to build example main.c #include <stdlib.h> #include <stdio.h> #include <string.h> #include <glib.h> #include <gdk/gdkx.h> #include <epoxy/glx.h> #include <epoxy/g
Cites BRabbit27 · 2017-05 · Stack Overflow · on “How to use Cmake for OpenGL + Qt 5.8 in OS X Sierra?”
I just tried to setup CMake for a project using Qt 5.8 to do OpenGL stuff in OS X Sierra. Here you can see my main CMakeLists cmake_minimum_required (VERSION 3.8) set (PROJECT_NAME "FluidEngine") project (${PROJECT_NAME}) set (CMAKE_PREFIX_PATH "/Users/BRabbit27/Qt/5.8/clang_64") set (CMAKE_AUTOMOC ON) find_package (Qt5Widgets) find_package (Qt5Gui) find_package (Qt5OpenGL) set (CPP_SOURCES "") set (HPP_SOURCES "") set (INCLUDE_PATHS "") add_subdirectory (src) include_directories (${INCLUDE_PATHS} ${OPENGL_INCLUDE_DIRS}) add_executable (${PROJECT_NAME} ${CPP_SOURCES} ${HPP_SOURCES}) target_link_libraries (${PROJECT_NAME} Qt5::Widgets Qt5::Gui Qt5::OpenGL ) It perfectly configures the xcode p
Cites ProNOOB · 2017-11 · Stack Overflow · on “GL_INVALID_OPERATION when calling glVertexAttribPointer”
trying to follow this video tutorial: [this video] I've made the following code that doesn't work. But before, I don't follow the tutorial in 100%, just the OpenGL part. On this video the guy uses Qt when I am using Gtk, he also uses glew when I am using epoxy and he is programming in C++ on Windows when I am using C on Linux 4.12.12. The problem is that the call to glVertexAttribPointer gives me GL_INVALID_OPERATION. I can't really figure why. Code: #include <epoxy/gl.h> #include <epoxy/glx.h> #include <gtk/gtk.h> static void realize (GtkGLArea *area) { GLuint buffer; GLenum err; GLfloat vertices[] = { +0.0f, +1.0f, -1.0f, -1.0f, +1.0f, -1.0f }; gtk_gl_area_make_current (area); //glClearColor(1.
Cites The Guest · 2018-08 · Stack Overflow · on “Simple Modern OpenGL Hello World”
I want to make a simple modern OpenGL hello world Program. I already have some experience with modern OpenGL. I once even compiled my own shaders and all that. Now i want to use some more modern functions like glVertexAttribPointer. The Code Compiles but all i get is a black screen. No triangle is showing up. Is it some problem with my graphics card or am i doing something wrong? I was following this tutorial: [this video] When i look in the comments many people say that all they get is a black screen. #include <iostream> #define GL3_PROTOTYPES 1 #include <GL/glew.h> #include <SDL/SDL.h> #include <GL/gl.h> #include <GL/glu.h> #include <vector> #define BUFFER_OFFSET(i) ((char *)NULL + (i)) GLuint