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.


Topics - Jalfor

Pages: [1] 2
1
Window / OpenGL Access Violation
« on: May 18, 2013, 11:20:38 am »
I'm not entirely sure this is an SFML problem, but I think it is. Pretty much, it crashes the moment I try to generate a buffer giving the error:

First-chance exception at 0x00000000 in OpenGLThing.exe: 0xC0000005: Access violation at location 0x0000000000000000.
Unhandled exception at 0x00000000 in OpenGLThing.exe: 0xC0000005: Access violation at location 0x0000000000000000.

Anyway, here is a simple program that gives gives the error.

#define GL_GLEXT_PROTOTYPES

#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>

int main()
{
        sf::ContextSettings contextSettings;
    contextSettings.depthBits = 32;
    contextSettings.stencilBits = 8;
    contextSettings.antialiasingLevel = 4;
    contextSettings.majorVersion = 3;
    contextSettings.minorVersion = 3;
       
        sf::Window window(sf::VideoMode(800, 600, 32), "OpenGL Triangle", sf::Style::Default, contextSettings);

        GLuint positionBuffer;
        glGenBuffers(1, &positionBuffer);

        window.close();
        return 0;
}

2
Window / OS X OpenGL Failure
« on: March 11, 2013, 01:17:31 pm »
SFML Works when I don't use OpenGL but when I do I get this error:

Undefined symbols for architecture x86_64:
  "_glClear", referenced from:
      _main in main.o
  "_glViewport", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am using the default template with XCode 4.6 (although I've switched off C++11 because that made it break) and I used the example code from the "A typical OpenGL-with-SFML program" here: http://sfml-dev.org/tutorials/2.0/window-opengl.php

Thanks for any help

3
Graphics / SFML 2 Vertex Miscalibration?
« on: November 24, 2012, 08:36:24 am »
The x values with sf::Vertex seem to be one off what they are meant to be.

This shows nothing:

#include <SFML/Graphics.hpp>

int main()
{
        //The Window
        sf::RenderWindow window(sf::VideoMode(600, 400), "SFML works!");
        sf::Vertex line[2];

        while (window.isOpen())
        {
                line[0].position.x = 0;
                line[0].position.y = 0;

                line[1].position.x = 0;
                line[1].position.y = 100;

                window.clear();
                window.draw(line, 2, sf::Lines);
                window.display();
        }

        return 0;
}

while this shows a line going across the top of the window

#include <SFML/Graphics.hpp>

int main()
{
        //The Window
        sf::RenderWindow window(sf::VideoMode(600, 400), "SFML works!");
        sf::Vertex line[2];

        while (window.isOpen())
        {
                line[0].position.x = 0;
                line[0].position.y = 0;

                line[1].position.x = 100;
                line[1].position.y = 0;

                window.clear();
                window.draw(line, 2, sf::Lines);
                window.display();
        }

        return 0;
}

4
Graphics / sf::Sprite.getGlobalBounds().width or height
« on: October 10, 2012, 01:11:48 pm »
I've worked out that sf::Sprite.getGlobalBounds().left and top get the left most and the top most parts of the sprite after transformations, though what does width and height do? Does it get the distance from the left most corner to the right most corner / the top most corner to the bottom most corner or something else? Thanks.

5
Graphics / Origin Scaling
« on: October 07, 2012, 04:23:29 pm »
I'm unsure as to whether this was intentional or not, but when scaling anything in SFML 2, it also scales the origin. This for example -
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Origin Scaling");
    sf::RectangleShape rectangle;
    rectangle.setSize(sf::Vector2f(100, 50));
    rectangle.setScale(0.25, 0.25);
    rectangle.setOrigin(-300, -300);

    while (1)
    {
        window.draw(rectangle);
        window.display();
    }
}
 
will not move the rectangle 300 pixels away from the left and 300 from the top, but rather a quarter of that.

6
SFML website / Missing 'sf::' in Documentation
« on: October 04, 2012, 08:46:25 am »
In the example in http://www.sfml-dev.org/documentation/2.0/classsf_1_1Drawable.php I think
virtual void draw(sf::RenderTarget& target, RenderStates states) const
should be
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
That's all  ;)

7
Graphics / Set Size of Texture
« on: October 03, 2012, 12:31:35 pm »
Hi,

Is there any way of creating or resizing a texture to a certain size. I know there is the scale function though that multiplies the size by the given amount instead of setting it to something.

Thanks

8
General / SFML-2.0 Immediate Crash
« on: June 25, 2012, 03:20:19 pm »
I've decided to try out SFML 2.0, and I've come across an issue which I have no idea how to fix.

I'm using: Code::Blocks SVN Build. Win7-64. MinGW.

I've followed the tutorial on the tutorial section and I'm pretty sure I've done everything. It compiles, but the moment I execute it under either Debug or Release, it opens up a console, then crashes. Here is the error information that Windows provides if it helps at all:

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:   SFML 2.0 Project.exe
  Application Version:   0.0.0.0
  Application Timestamp:   4fe8656f
  Fault Module Name:   SFML 2.0 Project.exe
  Fault Module Version:   0.0.0.0
  Fault Module Timestamp:   4fe8656f
  Exception Code:   c0000005
  Exception Offset:   000b10ff
  OS Version:   6.1.7601.2.1.0.256.4
  Locale ID:   3081
  Additional Information 1:   0a9e
  Additional Information 2:   0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:   0a9e
  Additional Information 4:   0a9e372d3b4ad19135b953a78882e789

9
Feature requests / Pixel Manipulation
« on: December 08, 2011, 05:08:19 am »
I'm not sure if you consider this too high level, though it would certainly be nice to have something that would do this as I can think of quite a few examples of where it would be useful.

Thanks

10
System / Linux Threading Issue
« on: December 03, 2011, 12:44:40 pm »
Just grabbed some code I've been working on from my Windows machine and loaded it onto Linux and it isn't working. The error message suggests that it is on SFML's end, not mine, though when I tried the minimal threading example from the tutorials, it worked fine.

The error message is:

Code: [Select]
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
ElectroToy: ../../src/xcb_io.c:273: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted

Process returned 134 (0x86)   execution time : 0.232 s
Press ENTER to continue.


My code (I haven't worked on it for long yet so don't judge :p)

Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>

#define WIDTH 800
#define HEIGHT 600

sf::RenderWindow App();
sf::Uint8 *pixels = new sf::Uint8[WIDTH * HEIGHT * 4];

void draw(int x, int y, int r, int g, int b)
{
    pixels[(x + WIDTH * y) * 4 + 0] = r;
    pixels[(x + WIDTH * y) * 4 + 1] = g;
    pixels[(x + WIDTH * y) * 4 + 2] = b;
    pixels[(x + WIDTH * y) * 4 + 3] = 255;
}

void display(void *UserData)
{
    sf::RenderWindow App(sf::VideoMode(WIDTH, HEIGHT, 32), "Speed Test");
    sf::Image screen(WIDTH, HEIGHT);
    sf::Sprite sprite;
    while (1)
    {
        screen.LoadFromPixels(WIDTH, HEIGHT, pixels);
        sprite.SetImage(screen);
        App.Clear();
        App.Draw(sprite);
        App.Display();
    }
}

int main()
{
    sf::RenderWindow App(sf::VideoMode(WIDTH, HEIGHT, 32), "Speed Test");
    sf::Thread graphics(&display);
    sf::Clock clock;
    const sf::Input & Input = App.GetInput();
    bool mouseX = Input.GetMouseX();
    bool mouseY = Input.GetMouseY();
    bool leftMouse = Input.IsMouseButtonDown(sf::Mouse::Left);
    bool rightMouse = Input.IsMouseButtonDown(sf::Mouse::Right);
    graphics.Launch();
    while (1)
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }
        if (leftMouse)
            draw(mouseX, mouseY, 255, 255, 255);
    }
}

11
General / OpenGL Flickering
« on: September 23, 2011, 12:27:31 pm »
I'm trying to make an electronics simulator kind of thing which needs to be quite fast to allow really bit simulations to run fast on it. When I draw something just once, and leave it there it flickers and I would really rather not go through all the pixels every frame as that would be rather slow being a pixel based thing so it would need to draw each one individually.

Thanks for any help :)

12
General / Direction Working out
« on: August 30, 2011, 06:12:19 am »
I know...title is awful though I couldn't think of anything better.

I need some help trying to get this little thing for my program working. There are a number of problems I am having. Firstly, I want the center to actually stay in the center. Secondly, I need the thing that will actually work out the new position of the thing after it has gone in a certain direction a certain amount. Before you start flaming me for not being able to work out a formula properly when I don't really even understand what half the commands are doing  exactly (Could you please tell me?) and that I'm a self taught 13 year old...

Anyway, here it is:

Code: [Select]
#include <SFML\Graphics.hpp>
using namespace sf;
RenderWindow App(VideoMode(800,600), "Space Game");

int main()
{
sf::Image Image;
Image.LoadFromFile("./arrow-upload-icone-9348-48.png");
Sprite SpaceShip(Image);
SpaceShip.SetCenter(110, 120);
sf::Vector2f shipPosition;
shipPosition.x = 110;
shipPosition.y = 120;
while (App.IsOpened())
{
shipPosition = SpaceShip.GetPosition();
float shipRotation = SpaceShip.GetRotation();
shipPosition.x += std::sin(shipRotation);
shipPosition.y -= std::cos(shipRotation);
App.Clear();
App.Draw(SpaceShip);
App.Display();
}
return EXIT_SUCCESS;
}


Thanks

13
General / A few Questions
« on: August 10, 2011, 05:54:44 am »
The first and biggest thing that I'm asking is that when anyone other than me and one other person runs a file that I made, it comes up with the following error. I have checked everything that I can think of, I'm really out of ideas.

The procedure entry point_invalid_parameter_noinfo_noreturn could not be located in the dynamic link library MSVCR100.dll.

While I'm here, I'll ask a couple of other questions. Firstly, how do you make parts of sprites transparent. e.g. You have a ball or something and you don't want it going around as a ball inside a white square.

Lastly, is there a way to somehow set the edges of, say a spaceship without having to put it in manually, and saying if the stuff is this far in this and not this far this way and so on.

Thanks :D

EDIT: I just had a look and with the sprites, could someone actually explain it to me, the functions that people write for it, although short, I have no clue what they are doing. For a start, what is alpha?

14
General / Program not starting
« on: July 13, 2011, 06:04:39 am »
Well, I have cut down the code as much as I possibly can and I have spent...a long time trying to work out what the problem is. I'm not quite sure if this is a C++ problem or an SFML problem. Anyway, here is the cut down version that doesn't work. It's saying it has an access violation at <massive bunch of number>. Tell me if you need the massive bunch of numbers or the exact output of the error thing.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int main()
{
int gridx = 10;
int gridy = 10;
int x1 = 120;
int y1 = 100;
int x2 = 100;
int y2 = 80;
sf::Shape grid[10][10]; //The grid on which everything is drawn
    sf::RenderWindow App(sf::VideoMode(800, 600), "Snake");
 
while (App.IsOpened())
{
int xdot = gridx;
int ydot = gridy;

//Draw it
for (xdot = gridx; xdot > 0; xdot--)
for (ydot = gridy; ydot > 0; ydot--)
{
grid[xdot][ydot] = sf::Shape::Rectangle(x1 + xdot * 22, y1 + ydot * 22, x2 + xdot * 22, y2 + ydot * 22, sf::Color::Red);
App.Draw(grid[xdot][ydot]);
}
App.Display();
}
return EXIT_SUCCESS;
}

15
General / Displaying Arrays
« on: July 02, 2011, 09:13:45 am »
How would I go about displaying an array of shapes. I am trying to make a game of snake and I need to create a grid which can be individually color changeable for obvious reasons. Here is the code with all the irrelevant bits cut out.

 
Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>

int main()
{
int count = 0;
        int count1 = 0;
sf::Shape grid[10][10];

int x1 = 120;
int y1 = 100;
int x2 = 100;
int y2 = 80;

    sf::RenderWindow App(sf::VideoMode(800, 600), "Snake");

    while (App.IsOpened())
{
       
App.Clear();

for(int xdot = 0; xdot < 10; xdot++)
for(int ydot = 0; ydot < 10; ydot++)
{
grid[xdot][ydot] = sf::Shape::Rectangle(x1 + xdot * 22, y1 + ydot * 22, x2 + xdot * 22, y2 + 22, sf::Color::Red);
}

       
App.Draw(grid);    //That's really what I want to do though it's giving me a syntax error
App.Display();
    }

    return EXIT_SUCCESS;
}

Pages: [1] 2