opengl

Getting World Position from Depth Buffer Value

…衆ロ難τιáo~ 提交于 2021-02-04 10:27:08
问题 I've been working on a deferred renderer to do lighting with, and it works quite well, albeit using a position buffer in my G-buffer. Lighting is done in world space. I have tried to implement an algorithm to recreate the world space positions from the depth buffer, and the texture coordinates, albeit with no luck. My vertex shader is nothing particularly special, but this is the part of my fragment shader in which I (attempt to) calculate the world space position: // Inverse projection

How do I wrap a sprite around a cube without GL_REPEAT? [closed]

微笑、不失礼 提交于 2021-02-04 08:26:11
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Improve this question I'm using OpenGL 3.2+. I created a cube VBO of 8 verticies (each vertex consists of 8 floats: x,y,z,r,g,b,s,t), an EBO to create the faces for that cube, and a VAO to tie it all together. I have a sprite atlas consisting of hundreds of 16x16 sprites. I'm trying to get 1 sprite

OpenGL shaders don't compile

北慕城南 提交于 2021-02-02 09:21:20
问题 The shaders in my OpenGL project don't compile. I have Ubuntu 16.04 LTS, using CLion. Didn't find any solution, that's why asking here. Here is my errorlist: ATTENTION: default value of option force_s3tc_enable overridden by environment. ERROR::SHADER::VERTEX::COMPILATION_FAILED 0:1(1): error: syntax error, unexpected $end ERROR::SHADER::FRAGMENT::COMPILATION_FAILED 0:1(1): error: syntax error, unexpected $end ERROR::SHADER::PROGRAM::LINKING_FAILED error: linking with uncompiled shadererror:

美颜代码

非 Y 不嫁゛ 提交于 2021-01-30 19:24:04
precision highp float; varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform vec2 singleStepOffset; uniform highp vec4 params; const highp vec3 W = vec3(0.299,0.587,0.114); const mat3 saturateMatrix = mat3( 1.1102,-0.0598,-0.061, -0.0774,1.0826,-0.1186, -0.0228,-0.0228,1.1772); float hardlight(float color) { if(color <= 0.5){ color = color * color * 2.0; }else{ color = 1.0 - ((1.0 - color)*(1.0 - color) * 2.0); } return color; } void main(){ vec2 blurCoordinates[24]; blurCoordinates[0] = textureCoordinate.xy + singleStepOffset * vec2(0.0, -10.0); blurCoordinates[1]

VS2019创建RealSense2.0 SDK新项目--使用深度数据测量物理世界中两点间的距离

我的梦境 提交于 2021-01-30 09:44:35
项目: 硬件平台: win10 x64 Visual Studio 2019 Intel Realsense SDK 2.0 这是在官网上下载的例程,默认安装在C盘,include是头文件,samples是例子 先说明:Hello第一个例子添加的依赖项只需要realsense2.lib就行,其他的例程则需要添加更多的依赖项,否则会报错 问题描述: 在VS新建工程这里坑比较多,以下是手把手教建工程,如果已经配置成功的可略过不看哦~ 1.环境变量配置(设置完之后,建议电脑重启一下,不过问题不大,看实际情况) 电脑——属性——高级系统设置——环境变量——系统变量——Path——如下图: 2.打开vs,新建一个工程,我把这个工程放在E盘,然后在解决方案资源管理器,右键打开属性 引入头文件和库目录+添加依赖项,完成一切后,连上相机就可以啦~ 原因分析: 大量的头文件和依赖项,没有的话,靠一个main函数跑不了,路径什么的一定要设置好才行,不过每次新建都得引入一次是真的烦人,可以试下在其他的环境下跑吧。 关于用深度测两点间的距离: 本教程介绍了使用深度数据测量现实距离的简单方法。 注意:测量真实对象的尺寸是深度相机的明显应用之一。 该示例并不是要成为合适的度量工具,而是要展示关键概念。 使用更好的算法,可以大大提高测量结果。 在本教程中,您将学习如何: 在空间上使颜色流与深度对齐(与rs

How to pass data to openGL functions correctly in Rust

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 17:44:59
问题 I'm trying to abstract openGL in Rust. I use glutin to communicate with openGL (here is the code I started with). I'm having problems abstracting Uniforms in fact they randomly get -1 as location (the same code sometimes works and sometimes doesn't). I checked if the program was in use and it was so I started wondering if there is a problem in the way I send the data to openGL: // value is initialised here let name = name.to_string(); let location; unsafe { location = gl.GetUniformLocation

How can I continue working on OpenGL with macOS Catalina 10.15.4?

早过忘川 提交于 2021-01-29 16:51:52
问题 I am trying to work with OpenGL on macOS Catalina 10.15.4 but there is a error; GL/glew.h GL/freeglut.h file not found! My code // main.cpp #include"GL/glew.h" // error; 'GL/glew.h' file not found #include"GL/freeglut.h" // error; 'GL/freeglut.h' file not found #include<iostream> #define GLEW_STATIC void display(void) { } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(500, 200); glutInitWindowSize(500

GL_TRIANGLES works but GL_QUADS displays nothing

…衆ロ難τιáo~ 提交于 2021-01-29 15:55:55
问题 So I'm swapping from one program to another, and I can't figure out why but GL_QUADS will no longer display with the same code. To try and figure out why old code was not working, I made this new, simple code and it STILL does not work. The setup: vector <vec3f> squarepoints; vec3f temper(-0.5f, 0.5f, 0.5f); squarepoints.push_back(temper); temper.x += 1.0f; squarepoints.push_back(temper); temper.y -= 1.0f; squarepoints.push_back(temper); temper.x -= 1.0f; squarepoints.push_back(temper);

How to know library variable names for CMakeLists?

谁说胖子不能爱 提交于 2021-01-29 10:02:19
问题 When using CMakeLists to compile an OpenGL project, I have the following line to link glut and gl: target_link_libraries(my_exe ${OPENGL_gl_LIBRARY} ${GLUT_LIBRARIES}) I looked up how to link glut and gl with CMake so I saw that I could use ${OPENGL_gl_LIBRARY} and ${GLUT_LIBRARIES}. But how would I know the variables to use otherwise? I am used to just doing ${THELIBRARY_LIBRARES}, but in the case of gl, it changed to adding that " gl " into the variable name. How would I know that without

Program with opengl compiles, but doesn't run

二次信任 提交于 2021-01-29 07:50:44
问题 I wanted opengl for code::blocks and used the link below to set it up: http://www.deannicholls.co.uk/tutorials/show/cpp_glut I tried the example file: #include <iostream> #include <GL/glut.h> using namespace std; GLfloat mat_ambient[] = {0.5, 0.5, 0.5, 1.0}; GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0}; GLfloat mat_shininess[] = {50.0}; GLfloat light_position[] = {10.0, 10.0, 10.0, 0.0}; GLfloat model_ambient[] = {1.0, 0.5, 0.5, 1.0}; void setupMaterials() { glMaterialfv(GL_FRONT, GL_AMBIENT