Git Product home page Git Product logo

Comments (13)

Thumperrr avatar Thumperrr commented on August 10, 2024

I'll write up a tutorial in the next few hours that everyone can use for future reference.

-Stephen Hall

On Dec 23, 2013, at 10:25 PM, "Jared Ready" [email protected] wrote:

So, I'm not sure how best to add resources into the grapics.json file. And then once they're there, what's the best to load said resources? I see there's TextureManager and ResourceManager classes, are we supposed to use those? Is using direct SFML to load resources not the right way?


Reply to this email directly or view it on GitHub.

from chessplusplus.

Thumperrr avatar Thumperrr commented on August 10, 2024

See this:
https://gist.github.com/Thumperrr/bd3b872038e2eb05796d#file-chesspp_graphics-md

It might be worth putting that into the repo somewhere. I'm out of time for now, though.

from chessplusplus.

LB-- avatar LB-- commented on August 10, 2024

We have a wiki for a reason:
https://github.com/cpluspluscom/ChessPlusPlus/wiki/Graphics-and-You
Also, you put cpp and not C++ after the triple ticks for C++ syntax highlighting ;)

EDIT: Oh, and JSON supports spaces! Away with your ugly underscores :)

from chessplusplus.

Thumperrr avatar Thumperrr commented on August 10, 2024

Ah, thanks LB.
And yeah, my GitHub flavored markdown is rusty.
I'll leave this issue open for ResidentBiscuit to close, in the event that questions are still unanswered.

from chessplusplus.

jaredready avatar jaredready commented on August 10, 2024

Alright so here's what I have, it's not working though. Images are not getting loaded, Just getting the 'missing' image instead.

graphics.json

{
    "chesspp":
    {
        "logo":    "res/img/logo.png",
        "menu":
        {
            "background":   "res/img/main_menu_background.png"
        },
...

StartMenuState

StartMenuState::StartMenuState(Application &app, sf::RenderWindow &display) : AppState(display), app(app)
    {
        // Load and initialize resources
        menuBackgroundTexture = TextureManager::instance().load(gfx_config.spritePath("chesspp", "menu", "background"));
        menuBackground.setTexture(menuBackgroundTexture);

        logoTexture = TextureManager::instance().load(gfx_config.spritePath("chesspp", "logo"));
        logo.setTexture(logoTexture, true);
...

Any idea what I'm doing wrong here?

from chessplusplus.

Thumperrr avatar Thumperrr commented on August 10, 2024
  • Are the images in the location you say they are?
  • Is the program running at all? I.e., are you seeing white blocks instead of the images?
  • Are your textures references to an sf::Texture?
  • Check the log, in it contains information about what textures are loaded successfully and what ones aren't. Might shed light on why.

you can also check src/gfx/graphics.cpp to see how that deals with images.

from chessplusplus.

jaredready avatar jaredready commented on August 10, 2024

It's just displaying the 'missing' X instead of my images.

My sf::Textures are not references. Didn't see they were supposed to.

On Tue, Dec 24, 2013 at 9:58 AM, Thumperrr [email protected] wrote:

  • Are the images in the location you say they are?
  • Is the program running at all? I.e., are you seeing white blocks
    instead of the images?
  • Are your textures references to an sf::Texture?
  • Check the log, in it contains information about what textures are
    loaded successfully and what ones aren't. Might shed light on why.


Reply to this email directly or view it on GitHubhttps://github.com//issues/66#issuecomment-31176132
.

from chessplusplus.

LB-- avatar LB-- commented on August 10, 2024

You can't copy textures, you need to take the return of .load() by reference.

from chessplusplus.

jaredready avatar jaredready commented on August 10, 2024

Got this working. Made a note on the wiki. The spritePath() method already
appends a "chesspp" to the beginning of the path, so if you pass that in
also you get an invalid path.

On Tue, Dec 24, 2013 at 10:27 AM, LB-- [email protected] wrote:

You can't copy textures, you need to take the return of .load() by
reference.


Reply to this email directly or view it on GitHubhttps://github.com//issues/66#issuecomment-31177096
.

from chessplusplus.

Thumperrr avatar Thumperrr commented on August 10, 2024

I think having spritePath() append "chesspp" to the beginning is counterintuitive and introduces hidden behavior that can be confusing. I'll open an issue for this.

from chessplusplus.

LB-- avatar LB-- commented on August 10, 2024

@Thumperrr it's in the chesspp namespace, if it were in the global namespace it would be counter-intuitive. But we can discuss in the issue.

from chessplusplus.

Thumperrr avatar Thumperrr commented on August 10, 2024

Even so we should specify it in a call to spritePath. see #67

from chessplusplus.

Thumperrr avatar Thumperrr commented on August 10, 2024

As far as I'm aware, this issue has been resolved, so i'll go ahead and close it.

from chessplusplus.

Related Issues (20)

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.