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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - joe5513

Pages: [1]
1
Graphics / Re: Unhandled exception at cleanupUnsharedResources
« on: March 18, 2023, 05:35:25 pm »
The global destruction order is undefined (...)

This make sence, thanks.


2
Graphics / Re: Unhandled exception at cleanupUnsharedResources
« on: March 17, 2023, 07:06:33 pm »
Release of unique_ptr after return from main tries to dereference end list iterator.
This seems like bug to me and can be reproduced with the code above..
Can someone confirm? :'(

3
Graphics / Re: Changing vertices
« on: March 17, 2023, 12:39:22 pm »
You can create function that takes two vectors as parameters which are start and end of the line.
Then simply pass sf::Vertex array with vertices constructed from provided start and end positions to window's draw method

void draw_line(const sf::Vector2f& a, const sf::Vector2f&b)
{
    sf::Vertex line[]=
        {
            sf::Vertex(a),
            sf::Vertex(b)
        };

    window.draw(line ... )
}

-----

draw_line(sf::Vector2f(0, 0), sf::Vector2f(10, 10));
 

4
Graphics / Unhandled exception at cleanupUnsharedResources [SOLVED]
« on: March 15, 2023, 07:50:43 pm »
I'm using a sfml compiled from master branch.
And i get Access violation reading location exeption at program end:
//main.cpp
#include <SFML/Graphics.hpp>
#include <memory>

std::unique_ptr<sf::RenderWindow> w;

int main(int argc, char const* argv[])
{
    sf::Texture t;
    t.loadFromFile("texture.png");

    w = std::make_unique<sf::RenderWindow>(sf::VideoMode(sf::Vector2u(320, 240)), "12",
                         sf::Style::Default);

    return 0;
}

Callsatack:
vtm.exe!std::_List_const_iterator<std::_List_val<std::_List_simple_types<std::pair<void (*const)(void *),void *>>>>::operator*() Line 148 (c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\list:148)
vtm.exe!std::_List_iterator<std::_List_val<std::_List_simple_types<std::pair<void (*const)(void *),void *>>>>::operator*() Line 239 (c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\list:239)
vtm.exe!sf::priv::GlContext::cleanupUnsharedResources() Line 753 (***\sfml\src\SFML\Window\GlContext.cpp:753)
vtm.exe!sf::priv::WglContext::~WglContext() Line 152 (***\sfml\src\SFML\Window\Win32\WglContext.cpp:152)
vtm.exe!sf::priv::WglContext::~WglContext() Line 150 (***\sfml\src\SFML\Window\Win32\WglContext.cpp:150)
vtm.exe!std::default_delete<sf::priv::WglContext>::operator()(sf::priv::WglContext * _Ptr) Line 3142 (c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\memory:3142)
vtm.exe!std::unique_ptr<sf::priv::WglContext,std::default_delete<sf::priv::WglContext>>::~unique_ptr() Line 3254 (c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\memory:3254)
vtm.exe!`anonymous namespace&#39;::GlContextImpl::`dynamic atexit destructor for &#39;sharedContext&#39;() Line 182 (***\sfml\src\SFML\Window\GlContext.cpp:182)
ucrtbased.dll!00007fff5a124957() (Unknown Source:0)
ucrtbased.dll!00007fff5a124365() (Unknown Source:0)
ucrtbased.dll!00007fff5a12449a() (Unknown Source:0)
ucrtbased.dll!00007fff5a124b01() (Unknown Source:0)
ucrtbased.dll!00007fff5a123cd1() (Unknown Source:0)
ucrtbased.dll!00007fff5a123b7d() (Unknown Source:0)
ucrtbased.dll!00007fff5a123bea() (Unknown Source:0)
ucrtbased.dll!00007fff5a123e64() (Unknown Source:0)
ucrtbased.dll!00007fff5a1241f6() (Unknown Source:0)
vtm.exe!__scrt_common_main_seh() Line 297 (d:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:297)
vtm.exe!__scrt_common_main() Line 331 (d:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331)
vtm.exe!mainCRTStartup(void * __formal) Line 17 (d:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17)

Am i doing something stupid?

ADD: should i post an issue on github instead this forum?

5
General / Re: Working from sources. Add custom module to SFML
« on: March 05, 2018, 03:31:30 pm »
You can't create dynamic SFML libraries with statically linked runtime library. SFML's CMake script will just return an error.

Yeah i got it, but what i mean is that when i link SFML dinamically, that means that std libs will be linked dinamically too, right? So i need to put std libs alongside executable or it will be searched and linked automatically under the hood?

Sorry if that question sounds stupid.
Knowledge is power.

Thanks!

6
General / Re: Working from sources. Add custom module to SFML
« on: March 05, 2018, 02:57:43 pm »
Saying 'SFML module' was a bad choise, but what i mean is that i want to create library which will be based on SFML and can be linked with actual SFML, to extend its functionality. So there is no problem with that, i got it :)
Sorry for been unclear with that.

And a thing about CMake.

(Windows 10)
When generating project files for dinamic linking, there is a flag SFML_USE_STATIC_STD_LIBS. What libs is that? MSVCRT.DLL?
When dinamically linking SFML, MSVCRT.DLL should be next to the executable as well? Or that done automatically?

Thanks!

7
General / Working from sources. Add custom module to SFML
« on: March 05, 2018, 01:17:55 pm »
Hi all.

I am working with SFML for quite some time now, and really enjoy it.

Last couple of months im writing my own simple game library, 100% based on manually builded SFML from master branch.
And i wondering how can i add 'custom' module to SFML? Like sfml-editor.lib for example.
Currently i have typical SFML project where my 'editor' module is. It contains scene, graph, nodes and all that stuff, with ability to save and load it from disk.

So the answer is that i need to build .lib file from my project and then link it alongside core SFML?
What is correct way to create custom module, that will behave like SFML module?

8
General / Re: returned value / temporary lifetime ?
« on: October 23, 2017, 03:39:51 pm »
Thank you so much! With your suggestions i found some information about that and NOW i can say i finally got it!

Just return the IntRect as value.

This is a solution for this particular problem.

9
General / Re: returned value / temporary lifetime ?
« on: October 23, 2017, 03:14:21 pm »
What do you mean by "invalid" IntRect?

I mean in second example returned IntRect is random value, i understand it now, because reference to local are illegal

So i should explicitly create temporary variable and return it instead as const reference:

const IntRect& Animation::getFrame() const
{
        auto frame = IntRect();
        return getEmpty() ? frame : m_frames.at(m_index);
}

It working now, thanks!


10
General / returned value / temporary lifetime ?
« on: October 23, 2017, 01:49:01 pm »
I'm trying to figure why:

// m_vector is a std::vector<IntRect>
const IntRect& Animation::getFrame() const
{
return getEmpty() ? IntRect() : m_vector.at( *valid index in range from 0 to m_vector.size() - 1* );
}

// Assuming that Animation.getEmpty() returns false ...
//
// 1 this is working
Animation* animation = some_object.getAnimation();
IntRect f = animation->getFrame();
some_object.setTextureRect(f); // valid IntRect passed
//
// 2 but this is not
some_object.setTextureRect(some_object.getAnimation()->getFrame()); // invalid IntRect passed

Ive read about lvalues and rvalues but at this moment cant apply that knowlege to this particular problem.

So i hope someone can breefly explain me what difference is in provided examples and what i did wrong



11
General / Tilemap implementation
« on: October 18, 2017, 03:11:53 pm »
Hello everyone!

Ive been working with sfml (and with C++ in general) for a few month now, and have some questions.

Im trying to implement Tilemap with chunks, and things goes pretty fine, but as it is my first attempt to make something like this, i wonder if im doing it right.

So can someone review my sources and point me to what i did wrong and what my common mistakes are.

https://github.com/joe5513/fragment

In short:

Grid is the class that represents a whole tilemap;
Chunk is the class that represents a part of tilemap, and contains Cells data and vertices;
Cell is the value struct that representing its type;

Grid is allocating Chunks and stores them in std::vector<Chunk*>;
Chunk is allocating Cells (aka tiles) and store them in Cell* pointer;
Grid object have some functionality to set and get Cells, to map them into  'world' coordinates and vice versa, and to draw Chunks;

Pages: [1]