LearnOpenGL | Code repository of all OpenGL chapters | Learning library

 by   JoeyDeVries C++ Version: Current License: Non-SPDX

kandi X-RAY | LearnOpenGL Summary

kandi X-RAY | LearnOpenGL Summary

LearnOpenGL is a C++ library typically used in Tutorial, Learning applications. LearnOpenGL has no bugs, it has no vulnerabilities and it has medium support. However LearnOpenGL has a Non-SPDX License. You can download it from GitHub.

Contains code samples for all chapters of Learn OpenGL and
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              LearnOpenGL has a medium active ecosystem.
              It has 8947 star(s) with 2532 fork(s). There are 255 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 104 open issues and 96 have been closed. On average issues are closed in 68 days. There are 17 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of LearnOpenGL is current.

            kandi-Quality Quality

              LearnOpenGL has no bugs reported.

            kandi-Security Security

              LearnOpenGL has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              LearnOpenGL has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              LearnOpenGL releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of LearnOpenGL
            Get all kandi verified functions for this library.

            LearnOpenGL Key Features

            No Key Features are available at this moment for LearnOpenGL.

            LearnOpenGL Examples and Code Snippets

            No Code Snippets are available at this moment for LearnOpenGL.

            Community Discussions

            QUESTION

            OpenGL distorted texture
            Asked 2022-Feb-28 at 16:18

            I am trying to display a texture, but for some reason it's not shown correctly it's distorted.

            This is my source code:

            ...

            ANSWER

            Answered 2022-Feb-27 at 11:14

            By default OpenGL assumes that the start of each row of an image is aligned to 4 bytes. This is because the GL_UNPACK_ALIGNMENT parameter by default is 4. Since the image has 3 color channels (GL_RGB), and is tightly packed the size of a row of the image may not be aligned to 4 bytes.
            When a RGB image with 3 color channels is loaded to a texture object and 3*width is not divisible by 4, GL_UNPACK_ALIGNMENT has to be set to 1, before specifying the texture image with glTexImage2D:

            Source https://stackoverflow.com/questions/71284184

            QUESTION

            Is the rotation matrix in Pybullet converting world coordinates into camera or camera to world?
            Asked 2022-Jan-26 at 10:02

            I am working on a project, where I need to replace the renderings by pybullet with renders generated with pytorch3d.

            I figured out that pybullet and pytorch3d have different definitions for the coordinate systems (see these links: pybullet, pytorch3d; x and z axes are flipped), and I accounted for that in my code. But I still have inconsistency in the rendered objects. I thought the problem could be that while pytorch3d expects a c2w rotation matrix (i.e. camera to world), pybullet could probably expect a w2c rotation matrix. However, I cannot find any documentation related to this. Has anyone ever encountered this problem, or maybe can give some useful hint on how to find out what exactly pybullet expects its rotation matrix to be?

            Thanks!

            ...

            ANSWER

            Answered 2022-Jan-26 at 10:02

            I assume you are talking about the viewMatrix expected by pybullet.getCameraImage(). This should indeed be a world-to-camera rotation matrix.

            However, in pyBullet the camera is looking in negative z-direction while I usually expect it to be in positive one. I am compensating for this by adding a 180°-rotation around the x-axis:

            Source https://stackoverflow.com/questions/70073425

            QUESTION

            Indexed drawing in PyOpenGL using glDrawElements doesn't draw anything
            Asked 2021-Dec-30 at 22:19

            I'm fairly new to OpenGL and I tried recreating the tutorial from https://learnopengl.com/Getting-started/Hello-Triangle to draw a rectangle in PyOpenGL.

            (Original source code: https://learnopengl.com/code_viewer_gh.php?code=src/1.getting_started/2.2.hello_triangle_indexed/hello_triangle_indexed.cpp)

            The first part of the tutorial that only draws a triangle using glDrawArrays works perfectly but when I try to use glDrawElements nothing is drawn. It doesn't even raise an error, it just shows me a black screen. I'm pretty sure I copied the instructions from the tutorial one by one and since there is no error message, I have no idea what I did wrong.

            I would appreciate any sort of help.

            My code:

            ...

            ANSWER

            Answered 2021-Dec-30 at 22:19

            If a named buffer object is bound, then the 6th parameter of glVertexAttribPointer is treated as a byte offset into the buffer object's data store. But the type of the parameter is a pointer anyway (c_void_p).

            So if the offset is 0, then the 6th parameter can either be None or c_void_p(0):

            glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0)

            Source https://stackoverflow.com/questions/70537124

            QUESTION

            GL_TEXTUREn+1 activated and bound instead of GL_TEXTUREn on Apple Silicon M1 (possible bug)
            Asked 2021-Dec-13 at 19:23

            Let's first acknowledge that OpenGL is deprecated by Apple, that the last supported version is 4.1 and that that's a shame but hey, we've got to move forward somehow and Vulkan is the way :trollface: Now that that's out of our systems, let's have a look at this weird bug I found. And let me be clear that I am running this on an Apple Silicon M1, late 2020 MacBook Pro with macOS 11.6. Let's proceed.

            I've been following LearnOpenGL and I have published my WiP right here to track my progress. All good until I got to textures. Using one texture was easy enough so I went straight into using more than one, and that's when I got into trouble. As I understand it, the workflow is more or less

            • load pixel data in a byte array called textureData, plus extra info
            • glGenTextures(1, &textureID)
            • glBindTexture(GL_TEXTURE_2D, textureID)
            • set parameters at will
            • glTexImage2D(GL_TEXTURE_2D, ... , textureData)
            • glGenerateMipmap(GL_TEXTURE_2D) (although this may be optional)

            which is what I do around here, and then

            • glUniform1i(glGetUniformLocation(ID, "textureSampler"), textureID)
            • rinse and repeat for the other texture

            and then, in the drawing loop, I should have the following:

            • glUseProgram(shaderID)
            • glActiveTexture(GL_TEXTURE0)
            • glBindTexture(GL_TEXTURE_2D, textureID)
            • glActiveTexture(GL_TEXTURE1)
            • glBindTexture(GL_TEXTURE_2D, otherTextureID)

            I then prepare my fancy fragment shader as follows:

            ...

            ANSWER

            Answered 2021-Dec-13 at 19:23

            Instead of passing a texture handle to glUniform1i(glGetUniformLocation(ID, "textureSampler"), ...), you need to pass a texture slot index.

            E.g. if you did glActiveTexture(GL_TEXTUREn) before binding the texture, pass n.

            Source https://stackoverflow.com/questions/70338946

            QUESTION

            Is it correct to say that OpenGL 3.2+ core-profile is based on "retained mode" pattern?
            Asked 2021-Nov-01 at 16:18

            I'm currently learning OpenGL by this resource and the "Core-profile vs Immediate mode" chapter confused me by the next question.

            If the old OpenGL versions (< 3.0) used immediate mode making the user (application) describe the building of a scene, and newer versions (>= 3.0) tried to abstract from it by using VBO and shaders as the only way to describe graphics, is it correct to say that core-profile in OpenGL 3.2+ makes OpenGL libraries based on a retained mode pattern, as the VBO data is something that is not stored by the user (application), therein not letting to describe how to build the scene?

            I also can't understand - does adding VBOs in OpenGL 1.4 (maybe 1.5, I'm not sure already) makes these specifications based on a retained mode?

            And so, is it correct to say that in OpenGL 3.2+ core-profile is based on retained mode and compatibility-profile is a mix of immediate and retained mode functionality?

            My understanding of immediate and retained mode definitions:

            • Immediate mode is an API design pattern, which is characterized by a direct call from the application of rendering functions, and each frame with objects displayed on it is drawn from scratch from the data that the user passes to the renderer.

            • Retained mode is an API design pattern, which is characterized by an application describing objects that should be rendered in the scene without calling the rendering functions directly - the graphics library is responsible for displaying and converting the data of the displayed objects.

            Feel free to indicate any inaccuracies or ambiguities.

            ...

            ANSWER

            Answered 2021-Nov-01 at 16:18

            Using those definitions for what you're talking about, OpenGL is not "retained mode". Your definition requires that in a "retained" renderer make rendering happen "without calling the rendering functions directly". But OpenGL doesn't render anything on its own; you have to call rendering commands directly, every frame, to make rendering happen.

            Buffer objects are just a way to store data in memory that is directly GPU-accessible. They don't really change the nature of how the user interacts with the concept of rendering. You still have to tell OpenGL to render with some set of buffers buffers if you want to render the object those buffers represent.

            It should be noted that the OpenGL community uses the term "immediate mode" specifically and only to refer to using glBegin/End-based vertex specification. It is not using the term in the same way as you have defined it. Indeed, the tutorial takes time out to explain what the term means within the context of OpenGL: "using OpenGL meant developing in immediate mode (often referred to as the fixed function pipeline)".

            That being said, even the tutorial is being rather loose in its terminolgy, as it claims that "immediate mode" is synonymous with the "fixed function pipeline". Which it isn't. Fixed functionality can use data stored in buffer objects; indeed, buffer objects were added to OpenGL before shaders.

            So it's best not to think too hard on the terminology.

            Source https://stackoverflow.com/questions/69796270

            QUESTION

            FFmpeg: Why the recorded video's quality is much lower than rendered in OpenGL
            Asked 2021-Oct-28 at 16:27

            I tried to use FFmpeg to capture frames rendered by OpenGL. The result is a .mp4 file for playing back purposes. It works since I got the .mp4 I expected, however the quality is quite low compared to the one rendered by OpenGL. Can anyone tell me why? And How can I adjust my code to make the mp4 of the same quality as the original frames generated by OpenGL?

            The result I've got:

            images OpenGL vs FFmpeg

            Here is my simple code:

            ...

            ANSWER

            Answered 2021-Oct-28 at 16:27

            Switch to the libx264rgb encoder & crf 0 for lossless capture:

            Source https://stackoverflow.com/questions/69746082

            QUESTION

            Updating vertices from compute shader
            Asked 2021-Oct-08 at 15:50

            As I understand it (correct me if I'm wrong) I can share data between a compute shader and a vertex shader by binding both to the same buffer.

            The vertex program is able to display my particles which are drawn as points but they are not being updated by the compute shader. I assume that I've simply missed something obvious but I can't for the life of me see it.

            Fragment Shader:

            ...

            ANSWER

            Answered 2021-Oct-08 at 15:50

            See OpenGL 4.6 API Core Profile Specification - 7.3 Program Objects:

            [...]

            Linking can fail for a variety of reasons [...], as well as any of the following reasons:

            [...]

            • program contains objects to form a compute shader (see section 19) and, program also contains objects to form any other type of shader.

            You need to create 2 separate shader programs. One for primitive rendering (vertex and fragment shaders) and one for computing vertices (compute shader):

            Source https://stackoverflow.com/questions/69497498

            QUESTION

            Can I have two uniform buffer pointing to same block in OpenGL?
            Asked 2021-Sep-23 at 07:33

            I am a newbie of OpenGL. I am trying to update some variables of a constant block. For example, I have a block like(Copied from opengl learnopengl.com):

            ...

            ANSWER

            Answered 2021-Sep-23 at 07:33

            What you want is not possible. A single interface block may only be served by a single buffer. The offset of the glBindBufferRange method is an offset into the buffers memory, it describes where the first variable in the interface block will start reading. It is not an offset into the interface block.

            The obvious solution to your problem is to split the interface block into to blocks, one for immutable stuff and one for the dynamic stuff.

            Source https://stackoverflow.com/questions/69295612

            QUESTION

            Can't use glGenBuffers in .h file C++
            Asked 2021-Sep-09 at 10:59

            I'm trying to learn OpenGL in C++. To clean up my code I was trying to create an header file with all variables, which decribe objects, in it. This header looks something like this:

            ...

            ANSWER

            Answered 2021-Sep-09 at 10:59

            QUESTION

            Chaining rotation on model matrix
            Asked 2021-Jul-17 at 14:50

            I have a small opengl world where I tried making a small cube with model matrix and rotating it around the origin axis. I simply got almost everything right but my problem is that whenever I try to chain the rotations .i.e. (rotating on x-axis once and y-axis next without resetting the matrix) I don't get what I wanted. I wanted the cube to rotate on a fixed axis but the cube rotates in its own axis. I mean to say that I want to rotate using the origin's axis but the model rotates using its own axis, the axis stays on the origin but it kinda rotates with the model. I thought my camera was moving not the model but when I try using multiple boxes it proved that my camera was on its own position. I cant figure out how to make the correct rotations. Here's my code for what I did(some codes are from learnopengl.com):

            ...

            ANSWER

            Answered 2021-Jul-17 at 14:49

            Matrix multiplications a not commutative. Thins means that rotateX(a) * rotateY(b) * rotateX(c) is not the same as rotateX(a+c) * rotateY(b).

            Do not add up the angles, but multiply the new rotation matrix with the current model matrix:

            Source https://stackoverflow.com/questions/68421352

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install LearnOpenGL

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/JoeyDeVries/LearnOpenGL.git

          • CLI

            gh repo clone JoeyDeVries/LearnOpenGL

          • sshUrl

            git@github.com:JoeyDeVries/LearnOpenGL.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link