opengl-3

Dashed line in OpenGL3?

一笑奈何 提交于 2019-12-03 08:01:41
I'm currently porting an old OpenGL 1.1 application which makes use of wireframe models to OpenGL 3.0. In 1.1 following code is used to create a dashed line: glPushAttrib(GL_ENABLE_BIT); glLineStipple(1, 0x0F0F); glEnable(GL_LINE_STIPPLE); Here as usual the parameters are pushed to the stack in order to influence all following drawing operations. My question: how is this done in OpenGL3 where this stack is no longer used? How can I set up my lines to be dashed (probably before handing the coordinates over to glBufferData()? For separate line segments, this is not very complicated at all. For

Cannot deploy GLFW 3.2

百般思念 提交于 2019-12-03 07:36:46
So this one is a doozie; I've got a pretty large OpenGL solution, written in version 3.2 core with GLSL 1.5 in Windows 7. I am using GLEW and GLM as helper libraries. When I create a window, I am using the following lines: // Initialize main window glewExperimental = GL_TRUE; glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // Use OpenGL Core v3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); if(!glfwOpenWindow(Game::WINDOW_X, Game::WINDOW_Y, 0, 0, 0, 0, 32, 0, GLFW_WINDOW)) { ... If I omit the three glfwOpenWindowHint

is VertexAttribPointer needed after each BindBuffer?

江枫思渺然 提交于 2019-12-03 07:06:04
问题 I noticed that unless I re-call VertexAttribPointer, there's not input to shaders after a BindBuffer. Is that necessary? The shaders may not change in writing but only the buffers used. 回答1: tibur already answered to the actual question, but I thought I'd add some context. glBindBuffer(GL_ARRAY_BUFFER, ...) by itself does not do anything. Think of it as an extra argument to glVertexAttribPointer . Remember, you can bind multiple buffers to different attributes (say attrib 0 uses vbo 1, while

Creating an OpenGL 3.2/3.x context in SDL 1.3

故事扮演 提交于 2019-12-03 06:17:45
I'm facing a problem where SDL says it does not support OpenGL 3.x contexts. I am trying to follow this tutorial: Creating a Cross Platform OpenGL 3.2 Context in SDL (C / SDL) . I am using GLEW in this case, but I couldn't get gl3.h to work with this either. This is the code I ended up with: #include <glew.h> #include <SDL.h> int Testing::init() { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { DEBUGLINE("Error initializing SDL."); printSDLError(); system("pause"); return 1; // Error } //Request OpenGL 3.2 context. SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL

Can't set desired OpenGL version in QGLWidget

≯℡__Kan透↙ 提交于 2019-12-03 03:06:13
I'm trying to use QGLWidget in Qt 4.8.2. I noticed that the default context QGLWidget creates doesn't show any output for OpenGL above 3.1. The Qt wiki has a tutorial that demonstrates using OpenGL 3.3 to draw a simple triangle. When I try to run the tutorial, I get a blank screen. If I change the OpenGL version to 3.1, I get the expected output (a red triangle). My video card supports OpenGL 4.2, and calling QGLFormat::openGLVersionFlags() before creating the QGLWidget shows that Qt detects OpenGL 4.2 and all previous desktop versions. Here's another minimal example: #include <QApplication>

OpenGL Low-Level Performance Questions

Deadly 提交于 2019-12-02 21:35:31
This subject, as with any optimisation problem, gets hit on a lot, but I just couldn't find what I (think) I want. A lot of tutorials, and even SO questions have similar tips; generally covering: Use GL face culling (the OpenGL function, not the scene logic) Only send 1 matrix to the GPU (projectionModelView combination), therefore decreasing the MVP calculations from per vertex to once per model (as it should be). Use interleaved Vertices Minimize as many GL calls as possible, batch where appropriate And possibly a few/many others. I am (for curiosity reasons) rendering 28 million triangles

is VertexAttribPointer needed after each BindBuffer?

纵饮孤独 提交于 2019-12-02 20:50:24
I noticed that unless I re-call VertexAttribPointer, there's not input to shaders after a BindBuffer. Is that necessary? The shaders may not change in writing but only the buffers used. tibur already answered to the actual question, but I thought I'd add some context. glBindBuffer(GL_ARRAY_BUFFER, ...) by itself does not do anything. Think of it as an extra argument to glVertexAttribPointer . Remember, you can bind multiple buffers to different attributes (say attrib 0 uses vbo 1, while attrib 1 and 2 use vbo 2). What API order would you see for that setup ? With the actual API, it's something

OpenGL Segfaults on glGenVertexArrays

别说谁变了你拦得住时间么 提交于 2019-12-02 09:20:32
问题 OpenGL or SDL segfaults when it reaches the very first statement in the class. I have no idea what is causing it. class RenderEngine { GLuint vertexArrayId; GLfloat[] vertexBufferData = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f ]; GLuint vertexBufferId; public this() { glGenVertexArrays(1, &vertexArrayId); // SEGMENTATION FAULT / RETURN -11 glBindVertexArray(vertexArrayId); glGenBuffers(1, &vertexBufferId); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId); glBufferData(GL_ARRAY

Vertex shader not compiling due to a non-Ascii character?

巧了我就是萌 提交于 2019-12-02 05:00:14
问题 So I started using OpenGL with glew and GLFW to create a game engine, and I almost immediately ran into a problem when starting working with shaders: They are not being used or have no effect whatsoever if they are being used. I have been checking my code with plenty of other examples, and they all match up, nothing looks out of place, and I am starting to run out of ideas and patience (I have been trying to figure out why for nearly a month now) with this. My main core code is here: #include

Vertex shader not compiling due to a non-Ascii character?

不羁岁月 提交于 2019-12-02 01:34:28
So I started using OpenGL with glew and GLFW to create a game engine, and I almost immediately ran into a problem when starting working with shaders: They are not being used or have no effect whatsoever if they are being used. I have been checking my code with plenty of other examples, and they all match up, nothing looks out of place, and I am starting to run out of ideas and patience (I have been trying to figure out why for nearly a month now) with this. My main core code is here: #include "headers/Default.hpp" //Window width and height variables int windowWidth = 800; int windowHeight =