karansher / computer-graphics-raster-images

Computer Graphics Assignment about Raster Images
1 stars 0 forks source link

How to debug code/check errors? #86

Open SHaiderX opened 1 year ago

SHaiderX commented 1 year ago

All the ppm images are fully black for me when I build. I think I am making some syntax errors since i havent used C++ before, but it isnt showing me what im doing wrong. Even when I make and run the raster file in visual studio it isnt showing me any errors. It justs ouputs the black images.

Where can I check for syntax errors or other errors in my code?

abhimadan commented 1 year ago

Syntax errors would mean your code doesn't compile, so you wouldn't get any output. Do you see any errors when you run make (Mac/Linux) or compile your code in Visual Studio (Windows), or does your code run without any obvious errors but you see incorrect image files? If it's the latter, is your project set up correctly (following the advice in the FAQ), and can you correctly read image files in your code? If everything is set up correctly and you still see this error, then you have a bug in your code.

SHaiderX commented 1 year ago

When I run "cmake .." in the build folder it says:

-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043. -- The compiler C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe has no C++11 support. Please use a different C++ compiler. -- Configuring done -- Generating done -- Build files have been written to ...

I did follow everything from the assignment page when setting up the project. When I run the raster.sln file it does properly open in visual studio, then running that outputs ppm files. Its just that they are all black.

SHaiderX commented 1 year ago

I tried testing by changing the desaturate.cpp so it just outputs the image that it is getting by basically looping:

desaturated[i] = rgb[i];

And even this does not output anything. It is still black, so now im not sure where the problem is.

When I run the windows debugger on the raster file in Visual Studio, this is what says:

Symbols loaded. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_1d.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. The thread 0xcf8 has exited with code 0 (0x0). 'raster.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 'raster.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. The thread 0x350c has exited with code 0 (0x0). The thread 0x5e80 has exited with code 0 (0x0). The program '[6056] raster.exe' has exited with code 0 (0x0).

abhimadan commented 1 year ago

The warning about C++11 is outdated, so as long as you get a sln file at the end, don't worry about it. It looks like your issue isn't related to your project setup and is related to bugs in your code. Start by taking a look at your write_ppm function and verify that it works correctly, since otherwise you can't effectively debug anything else.