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

Author Topic: SFML Light System - Let There Be Light  (Read 259124 times)

0 Members and 3 Guests are viewing this topic.

ThreeDumps

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #270 on: September 25, 2013, 03:10:28 am »
It's not LTBL fault. You have to make one big shape.

But what if you can't? LTBL requires convex shapes so all scene will never be one big shape.

Estivo

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: SFML Light System - Let There Be Light
« Reply #271 on: September 25, 2013, 07:07:21 am »
Yes, but Convex !〓 Concave. Make a big quads.

Mlikaon

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #272 on: September 29, 2013, 08:54:48 pm »
Hello everybody!

I've been really excited when i saw this project, but i must admit i'm now losing my faith trying to add it into my SFML project.

Please help me someone! ^_

Let me try to explain my situation :

I'm using VS11(2012) and i already succeeded in including and using SFML 2.1.
My project is actually working, but i now want to add lights into it.

So :
-I downloaded LTBL 1.5
-I read the .pdf many times
-I pasted the Source directory into my project directory (in order to access to headers)
-I added all the .cpp from Constructs, Light, QuadTree (and the 'utils' one) to my project
-I pasted the example from the .pdf step by step
-I corrected a few changes in my code (for example Light() is no more accepted, i had to use a Light_point())
-I tried to compile and run

Here are the errors VS then returns :

Erreur  4       error C2039: 'unbind' : n'est pas membre de 'sf::Shader'        C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    732     1       SFML TEST
Erreur  3       error C2660: '
sf::Shader::bind' : la fonction ne prend pas 0 arguments  C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    717     1       SFML TEST
Erreur  1       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\EmissiveLight.cpp  58      1       SFML TEST
Erreur  2       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    267     1       SFML TEST
Erreur  5       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    777     1       SFML TEST
Erreur  6       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    795     1       SFML TEST
Erreur  7       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    820     1       SFML TEST
Erreur  8       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    845     1       SFML TEST
Erreur  9       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    870     1       SFML TEST
Erreur  10      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    898     1       SFML TEST
Erreur  11      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    965     1       SFML TEST
Erreur  12      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    979     1       SFML TEST

Can someone help me please?
I think there are few changes that have not been updated, and i'm not able to find them.

Estivo

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: SFML Light System - Let There Be Light
« Reply #273 on: September 29, 2013, 11:20:46 pm »
Really? Are you new user of sfml or you couldn't read? You have to change some lines. Read errors and documentation of actual API w.

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #274 on: September 30, 2013, 09:57:19 am »
Erreur  4       error C2039: 'unbind' : n'est pas membre de 'sf::Shader'        C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    732     1       SFML TEST
Erreur  3       error C2660: '
sf::Shader::bind' : la fonction ne prend pas 0 arguments  C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    717     1       SFML TEST
Erreur  1       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\EmissiveLight.cpp  58      1       SFML TEST
Erreur  2       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    267     1       SFML TEST
Erreur  5       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    777     1       SFML TEST
Erreur  6       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    795     1       SFML TEST
Erreur  7       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    820     1       SFML TEST
Erreur  8       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    845     1       SFML TEST
Erreur  9       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    870     1       SFML TEST
Erreur  10      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    898     1       SFML TEST
Erreur  11      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    965     1       SFML TEST
Erreur  12      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    979     1       SFML TEST

Do you think everyone speaks your language to understand what the error says? Anyways read here

Quote from: 'Grey Wolf'
The function prototype dose not match the function definition

SFML API has changed and LTBL doesn't comply with the API so you must rewrite/update the LTBL code if you want to use it with the latest SFML version :)

Mlikaon

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #275 on: September 30, 2013, 10:01:05 am »
Well, i'm actually a new user,  yes.
I tried SFML a week ago for the first time.

And I actually read the documentation about Textures and other classes, but my code is still not working.

Here is where i need a few help precisely:

(in the LightSystem.cpp, for example)

m_softShadowTexture->bind();

This function is no more accepted, and so i have to change it.
So i look at the documentation, as usual, and see the Texture class have a bind() public method :

static void    bind (const Texture *texture, CoordinateType coordinateType=Normalized)
    Bind a texture for rendering.


I tried to replace with something like :
sf::Texture::bind(&m_softShadowTexture);

No more errors, but no lights appear!

Can somebody tell me where i am wrong please?


Edit : sorry for the lack of traduction, i didn't notice in time
« Last Edit: September 30, 2013, 03:22:17 pm by Mlikaon »

0-Guillaume-0

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #276 on: October 02, 2013, 07:13:32 pm »
Hi everyone,

I'm actually a new sfml user too, and i wanted to use "let there be light" library as well, but i've got the same problem as Mlikaon, at the exact same places.

It comes from some functions like "bind()", "unbind()" (this last one doesen't seem to exist anymore in the library).
VisualStudio tells me that "the function doesn't accept 0 arguments", it takes an argument witch type is "const sf::Texture *texture"

I began to search for solutions, trying some variables, rewrite some lines, but i didn't find anything that goes on.

I'd like to have some help on this problem too.

I read that maybe we should make an update of the library or rewrite some parts of it, it sounds good but actually i've no ideas of which part to rewrite, or how i should update it.

If someone has solved this problem before, i think it would be helpfull for everyone in the same situation to have a little tutorial about it, and if i find a solution with one of you, maybe i'll write one.

This library seems really powerfull, even though it's not easy to put it in place, if someone found a solution or has a little more explainations about this setup, please contact me or just post there, it will be really helpfull!

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #277 on: October 02, 2013, 07:54:27 pm »
unbind() is sf::Texture::bind(NULL); now.

Estivo

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: SFML Light System - Let There Be Light
« Reply #278 on: October 02, 2013, 07:55:49 pm »
Try this
m_softShadowTexture->bind(&m_softShadowTexture);
m_softShadowTexture->bind(nullptr);

It's working for me perfectly.

LTBL is not powerful ;) Is simple, easy to use. If you want powerful light library try GLLight by lolz123 (author of LTBL).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML Light System - Let There Be Light
« Reply #279 on: October 02, 2013, 08:41:55 pm »
The bind function is static, no need to use an instance to call it.
Laurent Gomila - SFML developer

polkom21

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #280 on: November 11, 2013, 08:57:51 pm »
Hi everyone!

I'm writing to you because I have problem with LTBL. So when I compiling my project with example I have error's:
Code: [Select]
obj\Debug\main.o||In function `main':|
gmail.com\ltbl\main.cpp|23|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `AABB::AABB(Vec2f const&, Vec2f const&)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `ltbl::LightSystem::LightSystem(AABB const&, sf::RenderWindow*, std::string const&, std::string const&)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `ltbl::LightSystem::~LightSystem()'|
gmail.com\ltbl\main.cpp|32|undefined reference to `ltbl::Light_Point::Light_Point()'|
gmail.com\ltbl\main.cpp|23|undefined reference to `ltbl::LightSystem::~LightSystem()'|
gmail.com\ltbl\main.cpp|33|undefined reference to `ltbl::LightSystem::AddLight(ltbl::Light*)'|
gmail.com\ltbl\main.cpp|35|undefined reference to `ltbl::ConvexHull::ConvexHull()'|
gmail.com\ltbl\main.cpp|36|undefined reference to `ltbl::ConvexHull::LoadShape(char const*)'|
gmail.com\ltbl\main.cpp|39|undefined reference to `ltbl::ConvexHull::CalculateNormals()'|
gmail.com\ltbl\main.cpp|40|undefined reference to `ltbl::ConvexHull::CalculateAABB()'|
gmail.com\ltbl\main.cpp|41|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|41|undefined reference to `ltbl::ConvexHull::SetWorldCenter(Vec2f const&)'|
gmail.com\ltbl\main.cpp|42|undefined reference to `ltbl::LightSystem::AddConvexHull(ltbl::ConvexHull*)'|
gmail.com\ltbl\main.cpp|56|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|56|undefined reference to `ltbl::Light::SetCenter(Vec2f)'|
gmail.com\ltbl\main.cpp|61|undefined reference to `ltbl::LightSystem::RenderLights()'|
gmail.com\ltbl\main.cpp|62|undefined reference to `ltbl::LightSystem::RenderLightTexture()'|
gmail.com\ltbl\main.cpp|66|undefined reference to `ltbl::LightSystem::~LightSystem()'|
gmail.com\ltbl\main.cpp|66|undefined reference to `ltbl::LightSystem::~LightSystem()'|
What I have to do to LTBL work in my project?

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #281 on: November 11, 2013, 09:40:59 pm »
Add LTBL sources to your project.. When they compile right you should stop having undefined reference errors

polkom21

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #282 on: November 11, 2013, 09:55:40 pm »
I include all source to my project who are needed

#include <LTBL/Light/LightSystem.h>
#include <LTBL/Light/Light_Point.h>
#include <LTBL/Utils.h>
#include <assert.h>
#include <SFML/Graphics.hpp>
int main(int argc, char* args[])
{
    sf::VideoMode vidMode;
    vidMode.width = 800;
    vidMode.height = 600;
    vidMode.bitsPerPixel = 32;
    assert(vidMode.isValid());
    sf::RenderWindow win;
    win.create(vidMode, "Let there be Light - Demo");
    // ---------------------- Background Image ---------------------
    sf::Texture backgroundImage;
    assert(backgroundImage.loadFromFile("data/background.png"));
    // Tiling background
    backgroundImage.setRepeated(true);
    sf::Sprite backgroundSprite(backgroundImage);
    backgroundSprite.setTextureRect(sf::IntRect(0, 0, vidMode.width, vidMode.height));
    // --------------------- Light System Setup ---------------------
    ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &win, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");
    // Create a light
    /*ltbl::Light* testLight = new ltbl::Light();
    testLight->m_center = Vec2f(200.0f, 200.0f);
    testLight->m_radius = 500.0f;
    testLight->m_size = 30.0f;
    //testLight->m_spreadAngle = 2.0f * static_cast<float>(M_PI);
    //testLight->m_softSpreadAngle = 0.0f;
    testLight->CalculateAABB();*/

    ltbl::Light_Point * testLight = new ltbl::Light_Point();
    ls.AddLight(testLight);
    // Create a hull by loading it from a file
    ltbl::ConvexHull* testHull = new ltbl::ConvexHull();
    if(!testHull->LoadShape("data/testShape.txt"))
    abort();
    // Pre-calculate certain aspects
    testHull->CalculateNormals();
    testHull->CalculateAABB();
    testHull->SetWorldCenter(Vec2f(300.0f, 300.0f));
    ls.AddConvexHull(testHull);
    // ------------------------- Game Loop --------------------------
    sf::Event eventStructure;
    bool quit = false;
    while(!quit)
    {
        while(win.pollEvent(eventStructure))
            if(eventStructure.type == sf::Event::Closed)
            {
                quit = true;
                break;
            }
        sf::Vector2i mousePos = sf::Mouse::getPosition(win);
        // Update light
        testLight->SetCenter(Vec2f(static_cast<float>(mousePos.x), static_cast<float>(vidMode.height - mousePos.y)));
        win.clear();
        // Draw the background
        win.draw(backgroundSprite);

        ls.RenderLights();
        ls.RenderLightTexture();

        win.display();
    }
    win.close();
}
 

Estivo

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: SFML Light System - Let There Be Light
« Reply #283 on: November 11, 2013, 10:04:52 pm »
eh if you have linked in project (added as your file) you shouldn't use < >. Use " " for #include.

polkom21

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #284 on: November 11, 2013, 10:13:28 pm »
All source files are added to mingw folder so I use <>

 

anything