opengl-3

The simplest, minimalistic, opengl 3.2 cocoa project

江枫思渺然 提交于 2019-12-09 16:11:30
问题 I have used the legacy openGL with cocoa for years, but I'm now struggling to make the transition to openGL 3.2. There are several examples in the internet, but they are all too complex (and many don't even compile any more under XCode 5.1). Could someone write an example of the simplest, minimalistic, minimum cocoa code just to draw a read triangle to a NSOpenGLView? (no fancy shaders, no displayCallbacks, the fewer the code lines, the better). 回答1: https://stackoverflow.com/a/22502999

glVertexAttribPointer raising GL_INVALID_OPERATION

非 Y 不嫁゛ 提交于 2019-12-09 08:04:06
问题 I'm trying to put together a very basic OpenGL 3.2 (core profile) application. In the following code, which is supposed to create a VBO containing the vertex positions for a triangle, the call to glVertexAttribPointer fails and raises the OpenGL error GL_INVALID_OPERATION . What does this mean, and how might I go about fixing it? GLuint vbo, attribLocation = glGetAttribLocation(...); glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); GLfloat vertices[] = { 0, 1, 0, 1, 0, 0, -1, 0, 0 }

Dashed line in OpenGL3?

╄→尐↘猪︶ㄣ 提交于 2019-12-09 06:27:16
问题 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

Anti-Aliasing issue with MSAA, drawing CSG with depth and FBO

浪子不回头ぞ 提交于 2019-12-08 19:21:10
问题 I have reimplemented OpenCSG for modern OpenGL version. PixelFormatAttributes: NSOpenGLPFAColorSize , 24 , NSOpenGLPFAAlphaSize , 8 , NSOpenGLPFADepthSize , 32 , NSOpenGLPFAStencilSize , 8 , NSOpenGLPFAAccelerated , NSOpenGLPFADoubleBuffer , NSOpenGLPFASupersample , NSOpenGLPFASampleBuffers, 1 , NSOpenGLPFASamples , 4 , FBO specs: (tried render to FBO with multisample, but lines getting more strong and visible, look on screenshot at bottom) - created texture with power of 2, GL_RGBA (tried GL

How to set up vertex attributes in OpenGL?

元气小坏坏 提交于 2019-12-08 12:07:03
问题 I am trying to create a VBO for a simple rectangle. The GL is set up to use the core profile (GL: 3.2, GLSL: 1.5, inside an NSView in Cocoa). I spent hours trying to figure out how to draw a simple rectangle in OpenGL. It seems really hard to find any decent tutorials on the core profile. The best I could find was this tutorial. I adapted it to my needs and came up with the following code: GLfloat vertices[] = { 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0 }; glGenBuffers

Precision qualifier throws an error for OpenGL 3.0 under Mesa 9.2.1

久未见 提交于 2019-12-08 01:20:43
问题 A strange issue with OpenGL 3.0 under Mesa 9.2.1 on Ubuntu 13.10 (64-bit) is observed. Variable definition with explicit precision (like this: highp vec2 v; ) produces an error: syntax error, unexpected VEC2, expecting ',' or ';' It seems like precision qualifier is disabled there for some reasons. Mesa Release Notes doesn't clear the situation -- not bugs, nor notifications are relative to the topic. P.S. with OpenGL ES 3.0 precision qualifier works correctly. 回答1: Make sure you specify

Arcball camera inverting at 90 deg azimuth

▼魔方 西西 提交于 2019-12-07 23:18:55
问题 I'm attempting to implement an arcball style camera. I use glm::lookAt to keep the camera pointed at a target, and then move it around the surface of a sphere using azimuth/inclination angles to rotate the view. I'm running into an issue where the view gets flipped upside down when the azimuth approaches 90 degrees. Here's the relevant code: Get projection and view martrices. Runs in the main loop void Visual::updateModelViewProjection() { model = glm::mat4(); projection = glm::mat4(); view =

Depth Component of Converting from Window -> World Coordinates

允我心安 提交于 2019-12-07 15:15:30
问题 I'm working on a program that draws a 100x100 grid and allows the user to click on a cell and change the color. Clicking also works currently, however only when looking at the grid face on (i.e. camPos.z equal to camLook.z ) and when the grid is positioned in the center of the screen. What I've been stuck on the last few days is selecting the correct cell when looking at the grid from a different camera position or different area on the screen. My only guess would be that somehow the depth

Perspecitve divide in vertex shader?

跟風遠走 提交于 2019-12-07 14:11:38
问题 When using a perspective matrix in a vertex shader am I supposed to write code to divide by w or is it done automatically in a later stage? The reason for my question is that I have seen lots of vertex shaders using: gl_Position = matrix * pos; which makes sense if there is a later stage that divides the vector with its w component. However I never got it to work until I used the following in my vertex shader: gl_Position = matrix * pos; gl_Position = gl_Position / gl_Position.w; Is the

Render TTF SDL2.0 opengl 3.1

回眸只為那壹抹淺笑 提交于 2019-12-07 13:59:58
问题 I'm working with SDL2.0, and using a (semi modern) opengl (3.1). I'm looking to add a text overlay to my application, and to render TTF in the application. How would I go about this using modern OpenGL? EDIT: As per the suggestion of genpfault, I've tried using the SDL_TTF library, but All I'm getting is garbage on screen http://i.stack.imgur.com/FqyCT.png I've attached a gist of my shaders, which are very simple for this program, and also the snipped I'm using to load the text into surface,