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

Author Topic: Shader set a Float Uniforms causes to Crash  (Read 8761 times)

0 Members and 1 Guest are viewing this topic.

MOP

  • Newbie
  • *
  • Posts: 19
  • Expect the progress
    • View Profile
Shader set a Float Uniforms causes to Crash
« on: November 01, 2017, 10:23:10 pm »
Hello folks,

iam currently working on my Snake Project, actually trying to implement some Item Stuff. I applied for every Item(Food, Speedups, Healthups) a file, which contains simplify a Struct. In this Struct are some propertys saved and Path Names to Shader and Textures. For every Item i load Stuff.

Actually i have the Problem, if i "out-comment" this line here:
(in CSFMLGameClock.c)
Code: [Select]
// Set GameTime to Item Shaders
    if(GameItem.GI_Is_Init)
    {
        size_t it;
        for(it = 0; it<GameItem.GI_Items_Count; it++)
        {
            if(GameItem.GI_Coordinates_Setted[it] && GameItem.GI_Placed[it])
            {
                //sfShader_setFloatUniform(GameItem.GI_Shaders[it], "Time", GameClock.GC_Time); // <- This
            }
        }
    }

On Start, it works fine, if i move my Snake then with a key, it directly lead to a crash. Iam not sure, where's the problem. Maybe you can give me some tip.
If it outcommentated, it works fine.

I applied fast a github repo, if you want to see the full code.
You can see it here: https://github.com/MasterOfPenetrator/SnakeGame

Greetz
My Github Repo:
Snake
Deep Deep Deep in Development

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Shader set a Float Uniforms causes to Crash
« Reply #1 on: November 02, 2017, 12:42:30 am »
Use a debugger and inspect the values and stack trace when the game crashes.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MOP

  • Newbie
  • *
  • Posts: 19
  • Expect the progress
    • View Profile
Re: Shader set a Float Uniforms causes to Crash
« Reply #2 on: November 03, 2017, 08:43:05 am »
I did this. But in the Debugger it doesn't crash :o

I found another way to check the problem. I found it and resolve it.

My shader array of pointers got a bug, element 0 and element 1 got the same pointer address, which cause to segmentation fault.
« Last Edit: November 03, 2017, 06:14:27 pm by MOP »
My Github Repo:
Snake
Deep Deep Deep in Development