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

Author Topic: Access Violation?  (Read 12681 times)

0 Members and 1 Guest are viewing this topic.

Robotsandstuff

  • Newbie
  • *
  • Posts: 1
    • View Profile
Access Violation?
« on: October 12, 2016, 07:22:27 am »
Using the 32bit binaries from your site,and DMD 2.071.2

With your example below I get an error.

Code: [Select]
object.Error@(0): Access Violation
0x0041B3B9
0x004038FB
0x004037FC
0x004035F0
0x75767c04 in BaseThreadInitThunk
0x7719Ad1F in RtlInitializeExceptionChain
0x7719ACEA in RtInitializeExceptionChain

module main;

import dsfml.graphics;

void main(string[] args)
{
    auto window = new RenderWindow(VideoMode(800,600),"Hello DSFML!");

    auto head = new CircleShape(100);
    head.fillColor = Color.Green;
    head.position = Vector2f(300,100);

    auto leftEye = new CircleShape(10);
    leftEye.fillColor = Color.Blue;
    leftEye.position = Vector2f(350,150);

    auto rightEye = new CircleShape(10);
    rightEye.fillColor = Color.Blue;
    rightEye.position = Vector2f(430,150);

    auto smile = new CircleShape(30);
    smile.fillColor = Color.Red;
    smile.position = Vector2f(368,200);

    auto smileCover = new RectangleShape(Vector2f(60,30));
    smileCover.fillColor = Color.Green;
    smileCover.position = Vector2f(368,200);

    while (window.isOpen())
    {
        Event event;

        while(window.pollEvent(event))
        {
            if(event.type == event.EventType.Closed)
            {
                window.close();
            }
        }

        window.clear();

        window.draw(head);
        window.draw(leftEye);
        window.draw(rightEye);
        window.draw(smile);
        window.draw(smileCover);

        window.display();
    }
}
 

I imagine I'm doing something wrong as this doesn't seem like a wide-spread issue.
Any help or advice is appreciated, thanks.

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: Access Violation?
« Reply #1 on: October 13, 2016, 08:36:33 pm »
This does seem suspicious.

Can you give me a little more information? What platform are you on and what version of DSFML are you using? Anything else you might think is relevant would be useful too.
DSFML - SFML for the D Programming Language.

Scroph

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Access Violation?
« Reply #2 on: October 20, 2016, 02:29:01 am »
I ran into a similar problem on Windows 7 32 bits with dmd v2.071.2 and "dsfml": "~>2.1.1".

I narrowed the issue down to the window.draw call :

int main(string[] args)
{
        auto window = new RenderWindow(VideoMode(640, 480), "Cave");
        auto brick = new Texture();
        if(!brick.loadFromFile("img\\brick_texture.png"))
                return 1; //nope
        auto sprite = new Sprite(brick);
        writeln(sprite is null); //false
        writeln(brick is null); //false
        while(window.isOpen)
        {
                Event evt;
                while(window.pollEvent(evt))
                {
                        window.clear(Color.Black);
                        window.draw(sprite); //Access violation
                        window.display();
                        if(evt.type == evt.EventType.Closed || Keyboard.isKeyPressed(Keyboard.Key.Escape))
                        {
                                window.close();
                        }
                }
        }
        return 0;
}
 

Scroph

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Access Violation?
« Reply #3 on: October 20, 2016, 06:10:20 pm »
I put a bunch of writeln calls in renderwindow.d and sprite.d to see where it crashes. It turns out window.draw(sprite) calls sprite.draw(window, states) which in turn calls the overload of window.draw that takes an array of vertices, a primitive type and render states. The code then crashes after the sfRenderWindow_drawPrimitives call. sfRenderWindow_drawPrimitives is an extern(C) function so that leads me to believe the issue is in the dfmlc-graphics.lib file. I built DSFML 2.1.1 using dub but it didn't include the dsfmlc-*.lib files, so I downloaded those from here : http://dsfml.com/downloads.html

You think those could be outdated ?

Here's the output of the writeln calls :

Code: [Select]
renderwindow.d:517 : dsfml.graphics.sprite.Sprite.draw(dsfml.graphics.renderwindow.RenderWindow, RenderStates(Alpha, , Rebindable!(const(Texture))(#{overlap original, stripped}), Rebindable!(const(Shader))(#{overlap original, stripped})));

sprite.d:200: draw(dsfml.graphics.renderwindow.RenderWindow, RenderStates(Alpha, Rebindable!(const(Texture))(#{overlap original, stripped}), Rebindable!(const(Shader))(#{overlap original, stripped})));

sprite.d:206 dsfml.graphics.renderwindow.RenderWindow.draw([Vertex(X: 0 Y: 0, R: 255 G: 255 B: 255 A: 255, X: 0 Y: 0), Vertex(X: 0 Y: 145, R: 255 G: 255 B: 255 A: 255, X: 0 Y: 145), Vertex(X: 277 Y: 145, R: 255 G: 255 B: 255 A: 255, X: 277 Y: 145), Vertex(X: 277 Y: 0, R: 255 G: 255 B: 255 A: 255, X: 277 Y: 0)], Quads, RenderStates(Alpha, , Rebindable!(const(Texture))(#{overlap original, stripped}), Rebindable!(const(Shader))(#{overlap original, stripped})));

renderwindow.d:533 draw([const(Vertex)(X: 0 Y: 0, R: 255 G: 255 B: 255 A: 255, X: 0 Y: 0), const(Vertex)(X: 0 Y: 145, R: 255 G: 255 B: 255 A: 255, X: 0 Y: 145), const(Vertex)(X: 277 Y: 145, R: 255 G: 255 B: 255 A: 255, X: 277 Y: 145), const(Vertex)(X: 277 Y: 0, R: 255 G: 255 B: 255 A: 255, X: 277 Y: 0)], Quads, RenderStates(Alpha, , Rebindable!(const(Texture))(#{overlap original, stripped}), Rebindable!(const(Shader))(#{overlap original, stripped})));

renderwindow.d:546 : sfRenderWindow_drawPrimitives(7CC9C8, 19D307C, 4, Quads, Alpha, 12FC90, 7CC608, 7CC988);


object.Error@(0): Access Violation
----------------