LearnOpenGL | Practise for OpenGL following http : //learnopengl.com/ | Computer Vision library
kandi X-RAY | LearnOpenGL Summary
kandi X-RAY | LearnOpenGL Summary
Practise for OpenGL following
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of LearnOpenGL
LearnOpenGL Key Features
LearnOpenGL Examples and Code Snippets
Community Discussions
Trending Discussions on LearnOpenGL
QUESTION
I am following an OpenGL tutorial from https://learnopengl.com/ (specifically https://learnopengl.com/Advanced-OpenGL/Depth-testing) and I have many errors to do with stbi. Error Log image here (Below I have also attached the complete Output tab). I have added the "#define STB_IMAGE_IMPLEMENTATION" at the top of the main.cpp file (and not in a header). If I don't use any stb_image functionalities, the project compiles and runs. I have had projects where stb_image worked fine, but all those projects that worked were x86 (or 32-bit). It seems that I can not get stb_image with x64 (or 64-bit). I know that x64 itself works since other projects without stb_image that were x64 have compiled. I have also looked back to where I downloaded the header file for stb_image and there was no option for x64 vs x86 as there was only one universal option. Here is an image of how the files are organized: File hierarchy. I will also include my main.cpp file but if you want to see a specific file let me know. I am very new to c++ since I come from java and python so any help is appreciated.
...ANSWER
Answered 2021-May-31 at 19:12As mentioned by Retired Ninja in the comments, all you do to fix it is to put the #define STB_IMAGE_IMPLEMENTATION and #include stb_image.h after all the headers that also include the stb_image.h file. Once this was fixed, the program runs but I am getting a frame not found error but I think that is a separate issue from this.
QUESTION
I just started learning OpenGL by following https://learnopengl.com/Getting-started/Hello-Triangle, following the tutorial I wrote the code as per my understanding which compiles and does give me an output but instead of an orangish triangle it shows a white one. If I replace the shaderProgram()
with the code from https://learnopengl.com/code_viewer_gh.php?code=src/1.getting_started/2.1.hello_triangle/hello_triangle.cpp it works (shows the orange triangle), so I think I narrowed the problem to shader program compilation, I just couldn't find what's wrong with it, following is my code.
ANSWER
Answered 2021-May-31 at 15:29shaderProgram()
never return
s anything, so the name of your GL program object is just lost, and your shaderProgram
local variable contains just some undefined value, hence you never use that program.
Note that such mistakes will be spotted by almost every decent compiler, just enable (and read) the warnings...
QUESTION
I have been trying to create an OpenGL window making use of GLAD and GLFW, following the instructions found at learnopengl.com and glfw.org. At first glance according to the documentation, this is enough to get a window working:
...ANSWER
Answered 2021-May-05 at 11:41From learnopengl.com
Because OpenGL is only really a standard/specification it is up to the driver manufacturer to implement the specification to a driver that the specific graphics card supports. Since there are many different versions of OpenGL drivers, the location of most of its functions is not known at compile-time and needs to be queried at run-time. It is then the task of the developer to retrieve the location of the functions he/she needs and store them in function pointers for later use.
GLAD is a library that defines all the functions needed to work with OpenGL without having to work out how ourselves.
When we call a GLAD function, glClear
, for example, we are actually calling a function called glad_glClear
from the gl context. When this call is made, GLAD looks for the current gl context in order to affect the correct window, sort of speak. The reason this problem appears is because GLAD will always make use of a context, even if it doesn't find one.
When this happens, a call at this location in memory (0x0000000000000000
) is made, and since it is not a GL context, an Access violation
exception is thrown.
Fixing this problem is quite simple. If you are reading this, you probably are using GLAD and GLFW. GLFW has a function that allows us to define the context in just one call after the creation of the window:
QUESTION
I'm trying to use a compute shader to do three-dimensional physical simulations but having trouble storing anything into my 3D texture. My shaders compile successfully but when reading back any value from the 3D texture I get a zero vector. I haven't used compute shaders before either so I'm not sure if I'm even distributing the work load properly in order to achieve what I want.
I've isolated the problem in a small example here. Basically the compute.glsl shader has a uniform image3D and uses imageStore to write a vec4(1,1,0,1) into gl_WorkGroupID. In C++ I create a 100x100x100 3D texture and bind it to the shader's uniform, then I call glDispatchCompute(100,100,100) - to my knowledge, this will create 1,000,000 jobs/shader invocations, one for each coordinate in the texture. In my view.glsl fragment shader I read the value of a random coordinate (in this case (3,5,7)) and output that. I use this shade a cube object.
Everything I've tried results in a black cube being output:
Here's my code (I've been following along with learnopengl.com so it's mostly the same boiler plate stuff except I extended the shader class to handle compute shaders):
...ANSWER
Answered 2021-Apr-23 at 19:15It turned out that I was missing a call to glBindImageTexture - I thought that in order to bind my texture to the shader's image variable I needed to set the uniform and call glActiveTexture+glBindTexture but it seems only glBindImageTexture is needed.
I replaced:
QUESTION
I wanna draw an opengl window in center of the screen,however I searched everywhere but didn't find any answer to it. Below is a common snippet code of creating a window But it always show up in most left-top position.How can I control it.
...ANSWER
Answered 2021-Apr-09 at 12:25Please use this function "glfwSetWindowPos".
Here is an example.
QUESTION
I don't have very much experience with OpenGL, GLFW, or GLEW so my troubleshooting ability with these libraries is slim to none. I have managed to render a triangle ([-1, -1, 0], [1, -1, 0], [0, 1, 0]) but when using the vertex attribute coordinates for a cube, along with color attributes it seems to not render. There could be a lot wrong with my code, the shaders, and my matrix operations. I wish I had a clearer understanding of what I'm doing so I could give a more descriptive account of my error. Currently the above code only renders the window. I followed https://learnopengl.com/ initially and got the first tutorials working, the following code is my "testing" file where I've attempted to reimplement some of the elements myself. There are lots of copy pasted portions that may be shared with that tutorial if it helps at all.
Any insight or suggestions would be appreciated very much.
...Main Source
ANSWER
Answered 2021-Mar-16 at 13:10The problem is that you call linkShader
separately for each shader. It is possible to link a program multiple times. The function linkShader
, however, attaches the shader to the program, linkes the program and detaches the shader from the program. Hence, the vertex and the fragment shader are never attached at the same time.
Attach the vertex and fragment shader and call linkShader
once:
QUESTION
I'm trying to build a voxel engine, and to do this I have to create hundreds of thousands of voxels, and I was hoping I could use instanced rendering. However, the drawing is very unexpected. I'm primarily following the LearnOpenGL guide.
When rendering each voxel individually, the program works fine:
However, when using instanced rendering...
Another angle...
I'm trying to render the voxels in a big chunk, so this is what my code looks like:
voxel.hpp
...ANSWER
Answered 2021-Mar-14 at 21:19Your VBO setup doesn't make the slightest sense. You set up your per-instance transformation matrix to use the same data as your geometry in Voxel::generateElement()
.
You later upload all your transformation matrixes into a separate VBO, but the attribute pointers still point to the geometry VBO. YOu need to move the attribute setup for the instanced attribute out of Voxel::generateElement()
and into Chunk::Chunk()
so you can tell it to use that VBO as source for the model matrices.
QUESTION
I am using Visual Studio Community and I am trying to create OpenGL application. I am using GLFW to open a window like this:
...ANSWER
Answered 2021-Mar-09 at 20:04As mentionned in the comments, the problem comes from the destruction of your buffers : the program tries to call glDestroyX
(in buffers destructors) after the OpenGL context was destroyed, which throws errors that GL_Call
tries to handle using GL context so it also throws error itself and so on.
To solve that, declare and use your buffers inside of a scope, and destroy GL the context after the end of the scope, so that your GL objects are destroyed before the GL context is destroyed.
QUESTION
I am learning OpenGL from http://learnopengl.com and I have a problem with transformation based on this chapter Coordinate Systems... I want to render something like this Movie but I have something like this Movie2 in 5 seconds its back on the screen. Sorry for many links but I think it's easier to show this by video. It's my render loop:
...ANSWER
Answered 2021-Feb-23 at 07:56The order of the vertex transformations in the vertex shader is incorrect:
gl_Position = u_Projection * u_Model * u_View * vec4(a_Pos, 1.0);
QUESTION
I am attempting to address the age old issue of model vs world space coordinates when adding light to a scene with transformed models.
I have a house model with two instances. a skull, a single point light in my scene as well as some terrain and a skybox. I noticed that when applying some rotations to my models, the illumination provided by the point light was rotating with it. After some reading it became obvious that I am doing all of my computations in my shaders in model space but my light position/directions are in world space.
So, I realized I needed to uniform my space for my calculations and I think it makes sense to keep the shaders in model space and convert the light components from world to model.
When I don't do the transformation it looks almost right (though not perfect which I'm betting is b/c of the different spaces). I render a small lightbulb model at the location of the light and the tops of the houses and the terrain all illuminate as I expect relatively well.
When I do the conversion of the light position back to model space I'm expecting the light to still be illuminating from the lightbulb model. However it gets wonky.
I have no rotations on the models but some minor translations so I'm confused as to why it seems like the light source gets rotated 90 degrees around the x axis...
...ANSWER
Answered 2021-Feb-14 at 07:47The model matrix transforms form model space to world space. Therefore you do the calculation of the light model in world space.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install LearnOpenGL
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page