GithubHelp home page GithubHelp logo

emeiri / ogldev Goto Github PK

View Code? Open in Web Editor NEW
538.0 538.0 153.0 277.82 MB

Source code of OpenGL tutorials on ogldev.org

Home Page: http://ogldev.org

C 27.35% C++ 45.60% GLSL 4.65% Shell 0.87% Objective-C 0.21% JavaScript 0.74% C# 0.14% HTML 20.02% CSS 0.20% OCaml 0.06% SCSS 0.08% Batchfile 0.01% BitBake 0.08%
opengl opengl-tutorial

ogldev's People

Contributors

coryg89 avatar dhylands avatar emeiri avatar emeiri-intel avatar jvoytech avatar kalmiya 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

ogldev's Issues

Unable to reference stb_image when compiling.

I get this a bunch when trying to compile the project. I'm not sure what the issue is - ogldev_texture seems to reference stb_image just fine to me.

/usr/bin/ld: /tmp/cc8CWbfJ.o: in function `Texture::Load()': /home/angle/Documents/Programming/C++/ogldev-master/tutorial36/../Common/ogldev_texture.cpp:45: undefined reference to `stbi_set_flip_vertically_on_load' /usr/bin/ld: /home/angle/Documents/Programming/C++/ogldev-master/tutorial36/../Common/ogldev_texture.cpp:47: undefined reference to `stbi_load' /usr/bin/ld: /home/angle/Documents/Programming/C++/ogldev-master/tutorial36/../Common/ogldev_texture.cpp:50: undefined reference to `stbi_failure_reason' /usr/bin/ld: /home/angle/Documents/Programming/C++/ogldev-master/tutorial36/../Common/ogldev_texture.cpp:73: undefined reference to `stbi_image_free' collect2: error: ld returned 1 exit status

Oh, for the build environment, I'm using the latest gcc on the latest Xubuntu, I believe.

Can't build tutorial 49

Hello,

I'm on Ubuntu and here is what I get when I run /tutorial49/build.sh:

tutorial49.cpp: In constructor ‘Tutorial49::Tutorial49()’:
tutorial49.cpp:85:16: error: ‘class BasicMesh’ has no member named ‘GetOrientation’
   85 |         m_quad.GetOrientation().m_scale    = Vector3f(50.0f, 100.0f, 100.0f);
      |                ^~~~~~~~~~~~~~
tutorial49.cpp:86:16: error: ‘class BasicMesh’ has no member named ‘GetOrientation’
   86 |         m_quad.GetOrientation().m_pos      = Vector3f(0.0f, 0.0f, 90.0f);
      |                ^~~~~~~~~~~~~~
tutorial49.cpp:87:16: error: ‘class BasicMesh’ has no member named ‘GetOrientation’
   87 |         m_quad.GetOrientation().m_rotation = Vector3f(90.0f, 0.0f, 0.0f);
      |                ^~~~~~~~~~~~~~
tutorial49.cpp: In member function ‘bool Tutorial49::Init()’:
tutorial49.cpp:171:24: error: ‘class Camera’ has no member named ‘AddToATB’
  171 |         m_pGameCamera->AddToATB(bar);
      |                        ^~~~~~~~
tutorial49.cpp:179:20: error: ‘class DirectionalLight’ has no member named ‘AddToATB’
  179 |         m_dirLight.AddToATB(bar);
      |                    ^~~~~~~~
tutorial49.cpp: In member function ‘void Tutorial49::RenderPass()’:
tutorial49.cpp:249:25: error: ‘class BasicMesh’ has no member named ‘GetOrientation’
  249 |         p.Orient(m_quad.GetOrientation());
      |                         ^~~~~~~~~~~~~~

Strange, no?

Small corrections around vkDestroySurfaceKHR

I'm going through the series as a refresher for myself and I noticed some minor issues in the code.
core.cpp#L74 vkDestroySurfaceKHR is called, but the function pulled is store in vkDestroySurface (without the KHR). I think either changing the function to vkDestroySurface or removing the code to get the function can be removed. I've tested both and they both work, but I'm running on linux and I'm not sure if everything works perfectly the same on windows.

And more of a nitpick the OGLDEV_ERROR above reports that "vkDestroyDebugUtilsMessenger" address can't be found, I think that should be changed to "vkDestroySurfaceKHR" to reflect what's actually being grabbed. Assuming that the code is actually kept, changing it will avoid potential confusion while debugging.

Getting build errors on Windows

I opened ogldev_vs_2022.sln and trying to build the solution. But it is giving me few errors.

2>C:\D\Learning\OpenGL\ogldev\Include\ogldev_vulkan.h(28,10): fatal error C1083: Cannot open include file: 'vulkan/vulkan.h': No such file or directory

1>C:\D\Learning\OpenGL\ogldev\Common\ogldev_skydome.cpp(232,19): error C2039: 'SetRotate': is not a member of 'SkydomeTechnique'

1>C:\D\Learning\OpenGL\ogldev\Terrain12\terrain.h(28,10): fatal error C1083: Cannot open include file: 'terrain_technique.h': No such file or directory

1>c1xx : fatal error C1083: Cannot open source file: '......\Terrain12\terrain_demo12.cpp': No such file or directory

1>c1xx : fatal error C1083: Cannot open source file: '......\Terrain12\terrain_technique.cpp': No such file or directory

Am I missing something on my setup?

Thanks

Can't build tutorial 38

Hello,
I'm on Windows and here is what I get when I run /tutorial38:

Shading model 3
Loaded ambient color [0.640000 0.640001 0.640000]
Loaded diffuse color [0.640000 0.640000 0.640000]
Loaded specular color [0.000000 0.000000 0.000000]
Invalid shader program: 'Validation Error: Samplers of different types point to the same texture unit
Validation Error: Samplers of different types point to the same texture unit
Validation Error: Samplers of different types point to the same texture unit
'
!!! Debug callback !!!
Debug message: id 2, API_ID_RECOMPILE_FRAGMENT_SHADER performance warning has been generated. Fragment shader recompiled due to state change.
Message source: API
Error type: Performance
Severity: Medium

Sorry if it is beacause my wrong operatiion, I`m just new to the whole openGL

Tutorial23 mesh lost

Content directory doesn't include Zombie.obj that is used in Tutorial23.cpp line 149. The same as Tutorial23.cpp line 156.

About vs2022 and Vulkan build error on windows

Hello, I get the clone of github on vs2022 and install the vulkan 1.3.275.0 at C:\VulkanSDK\1.3.275.0 on Windows.
I set the project at D:\Desktop\ogldev-master. Then build the solution and find the error.

1709473306625

The Visual Studio 2022 has the guard model upside down and vanishes with mouse movement.

Advanced OpenGL Tutorial – Skeletal Animations with Assimp Tutorial 28 to be specific. When I run on Windows 10 Visual Studio 2022 on a 1080p monitor, an animated upside-down guard can somewhat be seen at the edge of the window, and then completely disappears when the mouse moves. I can see the upside-down guard again if I move my mouse pointer to the bottom mid of the window, but still the guard is upside down and at the bottom of the window.

Error with ogldev_util.cpp

Hello there!
When i want to build and run your Tutorial 16 i get the following errors

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	E0120	return value type does not match the function type	Common	c:\Coding\Studium\Visual Studio\OpenGL_Dev\Common\ogldev_util.cpp	82	
Severity	Code	Description	Project	File	Line	Suppression State
Error	C2440	'return': cannot convert from 'bool' to 'char *'	Common	c:\coding\studium\visual studio\opengl_dev\common\ogldev_util.cpp	82	
Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK1181	cannot open input file 'Common.lib'	Tutorial16 - Basic Texture Mapping	C:\Coding\Studium\Visual Studio\OpenGL_Dev\Windows\ogldev\LINK	1	

they are thrown here

#ifdef WIN32

char* ReadBinaryFile(const char* pFileName, int& size)
{
    HANDLE f = CreateFileA(pFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

    if (f == INVALID_HANDLE_VALUE) {
        OGLDEV_FILE_ERROR(pFileName);
        return false;
    }

    size = GetFileSize(f, NULL);

    if (size == INVALID_FILE_SIZE) {
        OGLDEV_ERROR("Invalid file size %s\n", pFileName);
        return false;
    }

    // wip for tutorial51
    assert(0);

    return true; // here it says: return value type does not match the function type
}

I'm using Visual Studio Enterprise 2017 Version 15.2 (26430.6) Release.
Do you have any idea what the problem here is?

Nothing happened when run Tutorial 25.

Hello)
I compile a tutorial 25 by msys2 on the Windows10.
It is compilig well
I use some libraries from msys2.
However when i am execute the exe file window opening and closing, without errors
Also gdb don't show problems
Where is the problemcan be?

my compiling
g++ -g -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -std=c++11 -c mesh.cpp skybox.cpp skybox_technique.cpp main.cpp "C:\Users\GubaydullinAR\Desktop\local\C\sss\cd\ogldev-source\Common"/*.cpp -I"C:\msys64\mingw64\include" -I"C:\msys64\mingw64\include\ImageMagick-7" -I"C:\Users\GubaydullinAR\Desktop\local\C\sss\cd\ogldev-source\Common\FreetypeGL" -I"C:\msys64\mingw64\include\freetype2" -I"C:\msys64\mingw64\include\assimp" -I"C:\Users\GubaydullinAR\Desktop\local\C\sss\cd\ogldev-source\Include" -I"C:\AntTweakBar\include"

g++ -std=c++11 math_3d.o skybox_technique.o main.o mesh.o skybox.o cubemap_texture.o technique.o ogldev_basic_lighting.o ogldev_util.o pipeline.o glut_backend.o camera.o ogldev_texture.o ogldev_app.o ogldev_atb.o -o main.exe -L"C:\msys64\mingw64\lib" -L"C:\Users\GubaydullinAR\Desktop\local\C\sss\cd\ogldev-source\Lib" -L"C:\AntTweakBar\lib" -lglew32 -lfreeglut -lopengl32 -lassimp -lglu32gdb -llibMagick++-7.Q16HDRI -lAntTweakBar64 -Wl,--subsystem,windows

Thank you!

LNK2019 issue while trying to add to another proj

Hello!

I am trying to use your code from tutorial 31 (on youtube) to select objects in a project I am working on. To do this, I added your header files from the Include folder to mine. I did not add any other code from other folders, just the Include folder and the picking_technique and picking_texture header and cpp files. I also rearranged the assimp folders, deleting assimp5. However, I'm getting LNK2019 errors from your code in the .obj files. I am using VS2017. I tried running the solutions from your project and it worked fine.

There are no red squiggly lines to tell me I've written something wrong, and I don't think I missed anything from your header files. Is there something I didn't consider here?

Errors are below.. Thanks so much in advance!
lnk2019error

Terrain13

When using vs2022 to run the Terrain13 project, the file 3rdparty/meshoptimizer/src/meshoptimizer.h cannot be found.

math3d

The implementation for InitPersProjTransform currently includes:
m[0][0] = 1/tanHalfFOV and m[1][1] = 1.0f/(tanHalfFOV*ar);

Shouldn't m[0][0] be (1/tanHalfFOV) * ar and m[1][1] be 1.0f/tanHalfFOV?

Vulkan Tutorial 1 will not render on Wayland

Not something I am sure you are aware of, given that your development environment is Windows, but the first Vulkan tutorial will not render a window on systems running Wayland. This is due to the fact that

"This is by design. A Wayland window is not shown until a buffer is commited."

Originally posted by @Jjagg in glfw/glfw#1398 (comment)

Perhaps make a note of this somewhere.

tutorial52 vulkan triangle failed

./tutorial52
XCB connection opened
XCB screen 0x55b65c1096f4
Window 2800000 created
Found 18 extensions
Instance extension 0 - VK_KHR_device_group_creation
Instance extension 1 - VK_KHR_external_fence_capabilities
Instance extension 2 - VK_KHR_external_memory_capabilities
Instance extension 3 - VK_KHR_external_semaphore_capabilities
Instance extension 4 - VK_KHR_get_physical_device_properties2
Instance extension 5 - VK_KHR_get_surface_capabilities2
Instance extension 6 - VK_KHR_surface
Instance extension 7 - VK_KHR_surface_protected_capabilities
Instance extension 8 - VK_KHR_wayland_surface
Instance extension 9 - VK_KHR_xcb_surface
Instance extension 10 - VK_KHR_xlib_surface
Instance extension 11 - VK_EXT_debug_report
Instance extension 12 - VK_KHR_display
Instance extension 13 - VK_KHR_get_display_properties2
Instance extension 14 - VK_EXT_acquire_xlib_display
Instance extension 15 - VK_EXT_direct_mode_display
Instance extension 16 - VK_EXT_display_surface_counter
Instance extension 17 - VK_EXT_debug_utils
Surface created
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

Num physical devices 2
Device name: Intel(R) Xe Graphics (TGL GT2)
API version: 1.2.182
Num of family queues: 1
Format 50 color space 0
Format 44 color space 0
Image usage transfer src is supported
Image usage transfer dest is supported
Image usage sampled is supported
Image usage color attachment is supported
Number of presentation modes 4
Num memory types 1
0: (f) DEVICE LOCAL HOST VISIBLE HOST COHERENT HOST CACHED
Num heap types 1
Device name: llvmpipe (LLVM 12.0.0, 256 bits)
API version: 1.1.182
Num of family queues: 1
Format 50 color space 0
Format 44 color space 0
Image usage transfer src is supported
Image usage transfer dest is supported
Image usage sampled is supported
Image usage color attachment is supported
Number of presentation modes 4
Num memory types 1
0: (f) DEVICE LOCAL HOST VISIBLE HOST COHERENT HOST CACHED
Num heap types 1
Family 0 Num queues: 1
GFX Yes, Compute Yes, Transfer Yes, Sparse binding No
Using GFX device 0 and queue family 0
Family 0 Num queues: 1
GFX Yes, Compute Yes, Transfer Yes, Sparse binding No
Device created
tutorial52: tutorial52.cpp:103: void OgldevVulkanApp::CreateSwapChain(): Assertion `NumImages >= SurfaceCaps.minImageCount' failed.
aborted (core dumped)

Bug in `Matrix4f::InitRotationY()`?

First off, thanks for sharing these amazing tutorials.

Should not the signs of the sin() elements be swapped?

Meaning, should it not be:

m[0][2] = sinf(y)

and

m[2][0] = -sinf(y)

instead?

ogldev/Common/math_3d.cpp

Lines 126 to 132 in 72b3ddb

void Matrix4f::InitRotationY(float y)
{
m[0][0] = cosf(y); m[0][1] = 0.0f; m[0][2] = -sinf(y); m[0][3] = 0.0f;
m[1][0] = 0.0f ; m[1][1] = 1.0f; m[1][2] = 0.0f ; m[1][3] = 0.0f;
m[2][0] = sinf(y); m[2][1] = 0.0f; m[2][2] = cosf(y) ; m[2][3] = 0.0f;
m[3][0] = 0.0f ; m[3][1] = 0.0f; m[3][2] = 0.0f ; m[3][3] = 1.0f;
}

Possible undefined behavior on Vector3f.Normalize

Hello

At this line

Vector3f& Vector3f::Normalize()

I observed what I think may be a bug.

If a zeroed Vector3f is normalized it caused a float/float division which is an undefined behavior.
On MSVC++17 it causes the return of a -nan(ind) which causes a cascade effect to the camera mAngleH and then to View projection.

A possible solution would be to verify if the length is zero but this is probably innefficient due to branching in a very commonly used function.
I check glm source code for vec4 (not sure if it is official)
https://github.com/g-truc/glm/blob/0d973b40a49e550b1ea7df22a8573bc5fff84f24/glm/simd/geometric.h#L77
But I guess it is applicable for vec3 as well

It does a different method by using the multiplication of the reciprocal of the square root of the dot product of the vector with itself and the vector itself. By my limited knowledge on computer graphics I assume this removes the length from the denominator thus avoid the branch instruction I mentioned earlier.

Please, could you share your opinion on this ?
I'm just a beginning in all things related to opengl, just trying to find my way through.
Thanks for the awersome ogldev tutorials!!

ogldev_texture.cpp uses GL_CLAMP_TO_EDGE when it shouldn't.

In lines 72 and 73, this file sets texture wrap to clamp to edge, which makes the textures draw incorrectly for Tutorial 36, and probably for other tutorials as well. Simply commenting out those two lines fixes the problem for tutorial 36.

glDrawElementsBaseVertex has generated an error (GL_INVALID_OPERATION)

Hello!
I'm compiling your project on Windows, and on all recent projects I'm getting debug messages that glDrawElementsBaseVertex is generating a GL_INVALID_OPERATION error.
How can I solve this problem?

Here are some details about my hardware:
Radeon RX 580 Series
PCI\VEN_1002&DEV_67DF&SUBSYS_2378148C&REV_E7
PCI\VEN_1002&DEV_67DF&SUBSYS_2378148C
PCI\VEN_1002&DEV_67DF&CC_030000
PCI\VEN_1002&DEV_67DF&CC_0300

Driver date: 12/16/2021

The error message itself:
Debug message: id 1000, glDrawElementsBaseVertex has generated an error (GL_INVALID_OPERATION)
Message source: API
Error type: Error
Severity: High

Missing VS .user Files

For Tutorial 9 to 15 on Windows, the VS projects don't have .user files. Both Enviroment and Working Directory's paths are not set, and so the projects can't be run. It's trivial, but may confuse people not familiar with VS.
Thank you for your work!

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.