GithubHelp home page GithubHelp logo

victorgordan / opengl-tutorials Goto Github PK

View Code? Open in Web Editor NEW
954.0 954.0 424.0 187.67 MB

Tutorials from the following playlist: https://www.youtube.com/playlist?list=PLPaoO-vpZnumdcb4tZc4x5Q-v7CkrQ6M-

Home Page: https://www.youtube.com/channel/UC8WizezjQVClpWfdKMwtcmw

C++ 72.97% Objective-C 0.64% C 26.17% GLSL 0.15% CMake 0.07%
opengl opengl-tutorial opengl3

opengl-tutorials's Introduction

This is the repository that contains all the source code for the YouTube tutorial playlist which can be found here: https://www.youtube.com/playlist?list=PLPaoO-vpZnumdcb4tZc4x5Q-v7CkrQ6M-

Keep in mind that some OpenGL tutorials are linked to the Resources directory, so they don't stand by themselves (this is done in order to not duplicate large resources such as textures and models across different tutorial directories).

An ImGui tutorial can also be found here.

Exercises for the first couple of tutorial can be found in the Exercises directory. I highly recommend to go through them to get a feeling for OpenGL.

If you find any bugs or things that can be adjusted open an issue, or just write a comment on one of my videos letting me know about the problem. I read all the comments ;)

opengl-tutorials's People

Contributors

artyif avatar boybaykiller avatar happyskid avatar jack-pap avatar narmjep avatar victorgordan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opengl-tutorials's Issues

API errors in anti aliasing tutorial

There are some invalid glTexParameteri calls here that generate some errors (highlighted):

https://github.com/VictorGordan/opengl-tutorials/blob/main/YoutubeOpenGL%2022%20-%20Anti-Aliasing/Main.cpp#L149-L152

The specification says:

An INVALID_ENUM error is generated by TexParameter* if target is ei-
ther TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY,
and pname is any sampler state from table 23.18.

If we look at table 23.18, we can indeed see that all four of those parameters are sampler states, making all of these calls illegal.

These calls should be removed.

P.S. multisample textures cannot be sampled in GLSL, but only read via texelFetch and imageLoad, so it makes sense that they wouldn't support sampler state.

terminate called after throwing an instance of 'int'

I was in the part of organizing, and when i finished to copy all the code, I ran it and it got me a error that says terminate called after throwing an instance of 'int', the code is exactly the same like the tutorial.

Im using visual studio code, using the mingw, and Im not sure if that affects, also Im going to show the opengl tutorial, is exactly the same like the code of the part of video of organizing, but I just will take screenshots of how is the explorer

Screenshot 2023-04-12 103105

Also, Im showing what is in the makefile
Screenshot 2023-04-12 103052
And that's it.
And I was searching on internet, and I realize that the error probably is in the shaderClass.cpp, because in a part of the code says throw(errno), and based on google errno is "is a preprocessor macro used for error indication. It expands to a static (until C++11)thread-local (since C++11) modifiable lvalue of type int.", so I think this is the error, and that the function get_file_contents its not working well, and I think that the reason is the function cannot read the default.verg, and the default.frag. So, How can I fix this problem?

Also, I just remove the throw(errno), and now works, but with not orange triangles. So, yes that is the problem, I want with the shaders, and also because I think I will need to use the shaders, so how can I fix the error?

`glTexParameteri( GL_TEXTURE_2D_MULTISAMPLE ... ` calls throw errors

Getting GL errors with these lines:

glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Prevents edge bleeding
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Prevents edge bleeding

Looks like it's not valid to do that, the docs say:

GL_INVALID_ENUM is generated if the effective target is either GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.

Function for text file to string conversion:

I recognize that, given the stark lack of mentions on this topic that this may be an error exclusive to me. Thank you in advance for putting up with a novice's missteps. I have c&p'd the code as written for the organizing/shaderClass.cpp and continue to flag the same error at the junction of "throw(errno);" (exception unhandled, int at memory location). The address "0xccccccc...", found in the Shader Constructer defined afterward and returned from the get_file_contents function, purportedly means that the memory is allocated but not initialized. Any assistance in this would be an honor.

Fix

Change glviewport from first tutorials to
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
It will prevent some issues with scaling

5 shaders - compile errors

SHADER_COMPILATION_ERROR for:FRAGMENT
0(4) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
0(4) : error C0000: ... or #version 410
0(6) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
0(6) : error C0000: ... or #version 410
0(18) : error C5052: gl_Position is not accessible in this profile

SHADER_LINKING_ERROR for:PROGRAM
Fragment info

0(4) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
0(4) : error C0000: ... or #version 410
0(6) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
0(6) : error C0000: ... or #version 410
0(18) : error C5052: gl_Position is not accessible in this profile
(0) : error C2003: incompatible options for link

Organizing throw(errno) issue

I have literally copied and pasted the code from lessons 4 into my editor and there are no errors showing in the text when I run the code. But after it runs it doesnt show the triangle with the indices. It shows a white window that pops up then goes back.

image

errors found in the source code

YoutubeOpenGL 13 - Model Loading/Model.cpp: //========================================

22 meshes[i].Mesh::Draw(shader, camera, matricesMeshes[i]); // created matrices are not transferred
22 meshes[i].Mesh::Draw(shader, camera, matricesMeshes[i], translationsMeshes[i], rotationsMeshes[i], scalesMeshes[i]); // corrected
//--------------------------------------------------------------------
69 float rotValues[4] = // the function glm::make_quat() already contains a reduction to the "standard"
70 { // and does not expect manual rearrangement
71 node["rotation"][3], // fix to [0]
72 node["rotation"][0], // fix to [1]
73 node["rotation"][1], // fix to [2]
74 node["rotation"][2] // fix to [3]
75 };
76 rotation = glm::make_quat(rotValues);
//--------------------------------------------------------------------
108 glm::mat4 matNextNode = matrix * matNode * trans * rot * sca; // since it's fixed in sstring 22, it's redundant code
108 glm::mat4 matNextNode = matrix * matNode; // corrected
//--------------------------------------------------------------------
111 if (node.find("mesh") != node.end())
112 {
113 translationsMeshes.push_back(translation); // now these matrices may never appear
114 rotationsMeshes.push_back(rotation); //
115 scalesMeshes.push_back(scale); //
116 matricesMeshes.push_back(matNextNode); //
117 //
118 loadMesh(node["mesh"]); //
119 } //
translationsMeshes.push_back(translation); //
rotationsMeshes.push_back(rotation); // This is not a pretty fix at all,
scalesMeshes.push_back(scale); // but I haven’t come up with a better one yet
matricesMeshes.push_back(matNextNode); //
if (node.find("mesh") != node.end()) //
{ //
loadMesh(node["mesh"]); //
} //
//--------------------------------------------------------------------
172 unsigned char bytes[] = { data[i++], data[i++], data[i++], data[i++] }; //
201 unsigned char bytes[] = { data[i++], data[i++], data[i++], data[i++] }; //
211 unsigned char bytes[] = { data[i++], data[i++] }; //
221 unsigned char bytes[] = { data[i++], data[i++] }; //
310 vectors.push_back(glm::vec2(floatVec[i++], floatVec[i++])); // may not work
319 vectors.push_back(glm::vec3(floatVec[i++], floatVec[i++], floatVec[i++])); //
328 vectors.push_back(glm::vec4(floatVec[i++], floatVec[i++], floatVec[i++], floatVec[i++]));//

172 unsigned char bytes[] = { data[i ], data[i+1], data[i+2], data[i+3] }; // for(;i=i+4)
201 unsigned char bytes[] = { data[i ], data[i+1], data[i+2], data[i+3] }; // for(
;i=i+4)
211 unsigned char bytes[] = { data[i ], data[i+1] }; // for(;i=i+2)
221 unsigned char bytes[] = { data[i ], data[i+1] }; // for(
;i=i+2)
310 vectors.push_back(glm::vec2(floatVec[i ], floatVec[i+1])); // for(;i=i+2)
319 vectors.push_back(glm::vec3(floatVec[i ], floatVec[i+1], floatVec[i+2])); // for(
;i=i+3)
328 vectors.push_back(glm::vec4(floatVec[i ], floatVec[i+1], floatVec[i+2], floatVec[i+3])); // for(_____;i=i+4)

YoutubeOpenGL 13 - Model Loading/Texture.cpp: //========================================

                                                                          // this function remains from the first part of the course

11 stbi_set_flip_vertically_on_load(true); // when creating an object JSON, texture orientation is already taken into account
// so you need to set a trigger to enable this feature if JSON is not used.

YoutubeOpenGL 13 - Model Loading/default.vert: //========================================

36 crntPos = vec3(model * translation * -rotation * scale * vec4(aPos, 1.0f)); // Now everything will work without "minus":
crntPos = vec3(model * translation * rotation * scale * vec4(aPos, 1.0f));
42 texCoord = mat2(0.0, -1.0, 1.0, 0.0) * aTex; // no longer needed

YoutubeOpenGL 16 - Face Culling & FPS Counter/Main.cpp: //========================================

71 glCullFace(GL_FRONT); // after all the fixes it no longer works
glCullFace (GL_BACK); // "the default" value is valid

                                                                                                    //========================================

compileErrors() doesn't work as intended

// Checks if the different Shaders have compiled properly
void Shader::compileErrors(unsigned int shader /* Sidenote: shouldn't this be GLuint for maximum generality? */, const char* type)
{
	// ...
	if (type != "PROGRAM") // This is never true because const char* is not std::string and this simply compares the memory addresses. If you want to check to see if the values aren't the same use strcmp(type, program) != 0 in <cstring>
	{
		// ...
	}
	else
	{
		// ...
	}
}

YoutubeOpenGL 5 - Shaders/shaderClass.cpp - Check for compile errors function

In the line :

95: glGetProgramiv(shader, GL_COMPILE_STATUS, &hasCompiled)
95: glGetProgramiv(shader, GL_LINK_STATUS, &hasCompiled) // Corrected

I was getting a empty compile error because for the program compiler check is a linking process right?

The status of the link operation will be stored as part of the program object's state. This value will be set to GL_TRUE if the program object was linked without errors and is ready for use, and GL_FALSE otherwise. It can be queried by calling glGetProgramiv with arguments program and GL_LINK_STATUS.

https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glLinkProgram.xhtml

Amazing OpenGL course videos! Thank You.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.