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 - mayday556

Pages: [1]
1
General / Re: Can't Render Across DLL Boundary
« on: June 09, 2021, 05:21:07 pm »
I see, I had no idea linking statically was so different from linking dynamically. Thanks a ton for the help here, cheers!  :)

2
General / Re: Can't Render Across DLL Boundary
« on: June 09, 2021, 03:37:10 pm »
You got me curious with that last reply, so I linked both the DLL and the exe dynamically and it works perfectly now... Do you know the reason why this doesn't work when linked statically? If there is a way to have SFML linked statically and have it still work that'd be preferable, but this works just as well, thanks for the hint!

3
General / Re: Can't Render Across DLL Boundary
« on: June 09, 2021, 03:01:07 pm »
You haven't mentioned the most important part, how are you linking SFML in your DLL and in your executable?

My apologies, in both instances, SFML is linked statically.

4
General / Can't Render Across DLL Boundary
« on: June 09, 2021, 01:24:05 am »
I've set up my project to be split up into two parts - a DLL project which acts as the game engine, and the normal project which compiles to an .exe and relies on the DLL to run.

The issue I've come across, is that if I pass a sprite from the .exe frontend to a function in the DLL that renders sprites, the sprite doesn't render. I've already ensured I setup SFML properly, as when I create a window and render to that window all from the frontend, it works fine, and the same goes for if I put the sprite, texture, and window all in DLL.

I made a very small representation of this and put it up on Github, since I know it's annoying to setup a solution to have multiple projects and link them all together, etc. in Visual Studio: https://github.com/Bounty556/BrokenDLL Note I am using the latest version of Visual Studio 2019.

The code is as follows:
Main.cpp - in the frontend .exe
#include <Test.h>

#include <SFML/Graphics.hpp>

int main()
{
        Test test;

        sf::Context context;

        sf::Texture texture;
        texture.loadFromFile("res/test.png");
        sf::Sprite sprite(texture);

        test.startWindowAndDraw(sprite);

        return 0;
}

Test.h - in the DLL
#pragma once

#include <SFML/Graphics.hpp>

class __declspec(dllexport) Test
{
public:
        Test();
        void startWindowAndDraw(sf::Sprite& sprite);

private:
        sf::RenderWindow m_Window;
};
 

Test.cpp
#include "Test.h"

Test::Test() :
        m_Window(sf::VideoMode(640, 480), "Test", sf::Style::Close)
{
}

void Test::startWindowAndDraw(sf::Sprite& sprite)
{
    while (m_Window.isOpen())
    {
        sf::Event event;
        while (m_Window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                m_Window.close();
        }

        m_Window.clear();
        m_Window.draw(sprite);
        m_Window.display();
    }
}

One thing I noticed is that even though I am creating a window before loading the texture, I still have to create a context, otherwise I get lots of rendering errors. Another thing is, if I don't instantiate Test until after I've loaded the texture, the sprite renders as a blank white rectangle, rather than the image it should be.

It doesn't make sense to me that passing anything from the frontend to the DLL would cause anything weird to happen, since DLLs are essentially part of the program at runtime. If anyone has any insight into this, I would be extremely grateful, as I've been racking my brain on this for quite some time now. Thanks!

Edit:
I forgot some contextual details to go along with this:
OS: Windows 10
Graphics Card: AMD Radeon RX 5700XT
SFML Version: Originally I was using 2.5.1, but upgraded to the latest snapshot release today.

The errors I get in console if I don't create a context before loading the texture are as follows:
An internal OpenGL call failed in RenderWindow.cpp(96).
Expression:
   GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, m_defaultFrameBuffer)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in Texture.cpp(778).
Expression:
   glBindTexture(GL_TEXTURE_2D, 0)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in Texture.cpp(781).
Expression:
   glMatrixMode(GL_TEXTURE)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in Texture.cpp(782).
Expression:
   glLoadIdentity()
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in Texture.cpp(785).
Expression:
   glMatrixMode(GL_MODELVIEW)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in RenderTarget.cpp(175).
Expression:
   glClearColor(color.r / 255.f, color.g / 255.f, color.b / 255.f, color.a / 255.f)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in RenderTarget.cpp(176).
Expression:
   glClear(GL_COLOR_BUFFER_BIT)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

5
Graphics / Re: GL_INVALID_VALUE generated from glClearColor()?
« on: June 11, 2014, 07:26:12 pm »
Do you realize you just bumped a 6+ year old thread? The OP hasn't even logged in for 6 years also. You should really start a new thread and post a complete and minimal example there.  ;)

Sorry, I just figured it out anyways... I just tried some really heavy debugging for 8 hours straight and finally figured it out... I forgot to divide a number by 2

6
Graphics / Re: GL_INVALID_VALUE generated from glClearColor()?
« on: June 11, 2014, 06:33:12 am »
I figured out the issue. It's too embarrassingly obvious so I'm not going to say what it was lol.

This was not SFML's fault.

Im having the same problem... can ya please tell me what is causing this, it's been bugging me for nearly a month now and it's threatening a deletion of one of my projects

7
Graphics / Using a for loop with RectangleShapes
« on: December 05, 2013, 12:59:53 am »
I've been working on a secret project lately, and I needed a couple Rectangle Shapes for hidden reasons. I thought I could just use an array of Rectangle Shapes, because I needed to manipulate all of them using the same code, but when initializing their size, color, data, etc. I get an error saying:

A buffer overrun has occurred in SFML.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

The code I am using to initialize them is as follows:

const short bodyCount = 4;

sf::RectangleShape wolfBody[bodyCount];
for (int i = 0; i < bodyCount; i++)
{
        wolfBody[i].setSize(sf::Vector2f(32, 32));
        wolfBody[i].setFillColor(sf::Color::Red);
        wolfBody[i].setOrigin(16, 16);
}

Does anyone know what is wrong with this?

8
General / Re: Rotation According To Joystick Direction
« on: December 04, 2013, 12:37:06 am »
Use the atan2 math function on what resulting radians

Pages: [1]