Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] Debug works perfectly, Release works halfway?!  (Read 2661 times)

0 Members and 1 Guest are viewing this topic.

LakySimi1

  • Newbie
  • *
  • Posts: 25
    • View Profile
[SOLVED] Debug works perfectly, Release works halfway?!
« on: February 29, 2020, 07:48:49 pm »
Hi everyone!
I'm developing a raycasting game engine in CodeBlocks with SFML, surely it's not perfect but it works well, at least the Debug executable AND in "Debug mode" in CodeBlocks as you can see here:
(click to show/hide)

But in Release executable and "release mode" of CodeBlocks it works half way, in fact the wall rendering works perfectly and the framerate doubles but floor and ceil isn't rendered, to be precise
its rendered only maybe ten pixel height stripe in the middle of the window:
(click to show/hide)

Searching around i read that can depend on which libraries are are used, here's mine:
(click to show/hide)
Previously the first five was followed by "-d" (for "debug" i think) but it works the same without too.
There's no other libraries in the linker of "build options.." of the project.


I will be very glad if someone can help me to make a working Release!

PS
Please don't mind the swastika, i'm using, for testing, the textures of the old PC game "Wolfenstein 3D" by "id software"!
« Last Edit: March 04, 2020, 02:23:09 am by LakySimi1 »

Fx8qkaoy

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Debug works perfectly, Release works halfway?!
« Reply #1 on: March 01, 2020, 08:17:19 am »
Hi everyone!
I'm developing a raycasting game engine in CodeBlocks with SFML, surely it's not perfect but it works well, at least the Debug executable AND in "Debug mode" in CodeBlocks as you can see here:
(click to show/hide)

But in Release executable and "release mode" of CodeBlocks it works half way, in fact the wall rendering works perfectly and the framerate doubles but floor and ceil isn't rendered, to be precise
its rendered only maybe ten pixel height stripe in the middle of the window:
(click to show/hide)

Searching around i read that can depend on which libraries are are used, here's mine:
(click to show/hide)
Previously the first five was followed by "-d" (for "debug" i think) but it works the same without too.
There's no other libraries in the linker of "build options.." of the project.


I will be very glad if someone can help me to make a working Release!

PS
Please don't mind the swastika, i'm using, for testing, the textures of the old PC game "Wolfenstein 3D" by "id software"!

Do use the "-d" libraries only for debug. Even if they work viceversa as u said, it's still a good practice to use the right ones, otherwise sometimes out of nowhere things don't work anymore

Make sure the libs are the right ones, then take a look at the console, it could show u what failed

LakySimi1

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Debug works perfectly, Release works halfway?!
« Reply #2 on: March 01, 2020, 12:27:53 pm »
Thank you, you're right, just corrected the libraries  ;), but i'm not sure these are the right libraries for a release, i think that's the point.

The build log doesn't show anything strange or related.

There's a strange behaviour: in Release the ceil and floor are rendered but only for 10/15 pixels hight orizzontal stripe, indipendently from player's field of view or resolution and the rest is filled with the color of the pixel which i stand (of the floor/ceil texture).
It seems like the compiler change its way to read my algorithm passing from Debug to Release, which i don't think is possible.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Debug works perfectly, Release works halfway?!
« Reply #3 on: March 03, 2020, 02:47:13 pm »
The release lib are those without the "-d". Make sure you link correctly to those.

You are right in saying your compiler cannot change the way it reads your algorithm, however if your code has undefined behaviour, and other bugs, the compiler can do a lot of stuff that maybe you don't want. My guess if the libraries are fine, is that you might have some bug that doesn't show in debug because of the debug is built, but it does show in release. Without the code, kinda hard to know for sure though, and at this point, I'd suggest to build release with debug info and go with a debugger.

Otherwise, try to make a minimal reproducible and complete code for us to help you.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

LakySimi1

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Debug works perfectly, Release works halfway?!
« Reply #4 on: March 04, 2020, 12:45:36 am »
...
 I'd suggest to build release with debug info and go with a debugger.
...

What do you mean pricisely?

I think i found the part of the code that cause the problem, and i don't think anymore is SFML foult:
the algorithm to draw floor and ceil uses a lot of times the trigonometric tangent, i'm actually using the function "tan(float)" of "math.h".

In the Debug the tan function gives cerrect values in Release it isn't at all, which is however strange, i will experiment on this part and let you know  :)

LakySimi1

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Debug works perfectly, Release works halfway?!
« Reply #5 on: March 04, 2020, 02:02:20 am »
SOLVED!!

I was right, the problem was the algorithm to calculate the tangent, actually i precalculate them at the beginning (the values don't change if the player moves or looks around) saving them in an array and i think i was saving them entering with a negative index, or maybe reading them with negative index, not sure about that.
I rewrite this part of the code and now it works perfectly for ceil and floor! :D

By the way, i make the game run in the same condition, both release and debug mode with framerate cap to 30fps and these are the results, CPU usage is more constant,think they can be intersting:
(click to show/hide)
*Actually the release CPU was more around 22/23%

Thanks anyway guys :)!
« Last Edit: March 04, 2020, 02:03:54 am by LakySimi1 »

 

anything