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

Pages: [1]
1
SFML projects / SFML Shape SAXT Example
« on: July 10, 2017, 09:12:13 am »
Hey guys I'm sorry for the inactivity lately. The current state of the world is depressing, aint it?  ;D

I finally got around to uploading some code I wrote a while ago on how to implement separating axis theorem using SFML's internal shape classes. I think it'd be a great way for people to get started writing their own collision code, especially if they want something a little more complex than AABB collision detection, without having to add another dependency to their projects. Hope it benefits someone!

https://github.com/ricanteja/SFML-SeparatingAxisTheorem

2
SFML website / Correction on tutorial page
« on: March 02, 2017, 05:07:10 am »
The problem can be found near the top of the tutorial page titled SFML and Linux (http://www.sfml-dev.org/tutorials/2.4/start-linux.php)

This is the problem:
Quote
Option 1 is the preferred one; if the version of SFML that you want to install is available in the official repository, then install it using your package manager. For example, on Debian you would do:

sudo apt-get install libsfml-dev
Option 3 requires more work: you need to ensure all of SFML's dependencies including their development headers are available, make sure CMake is installed, and manually execute some commands. This will result in a package which is tailored to your system.
If you want to go this way, there's a dedicated tutorial on building SFML yourself.

Finally, option 2 is a good choice for quick installation if SFML is not available as an official package. Download the SDK from the download page, unpack it and copy the files to your preferred location: either a separate path in your personal folder (like /home/me/sfml), or a standard path (like /usr/local).

If you already had an older version of SFML installed, make sure that it won't conflict with the new version!



This is the solution:
Quote
Option 1 is the preferred one; if the version of SFML that you want to install is available in the official repository, then install it using your package manager. For example, on Debian you would do:

sudo apt-get install libsfml-dev
Option 2 requires more work: you need to ensure all of SFML's dependencies including their development headers are available, make sure CMake is installed, and manually execute some commands. This will result in a package which is tailored to your system.
If you want to go this way, there's a dedicated tutorial on building SFML yourself.

Finally, option 3 is a good choice for quick installation if SFML is not available as an official package. Download the SDK from the download page, unpack it and copy the files to your preferred location: either a separate path in your personal folder (like /home/me/sfml), or a standard path (like /usr/local).

If you already had an older version of SFML installed, make sure that it won't conflict with the new version!

This way of wording things makes more sense given the numbers.

3
SFML projects / Alt Ctrl Jam 2016 Entry
« on: September 28, 2016, 11:16:35 pm »
Hey all. I made something pretty cool using SFML. I created a simple controller with the Arduino and got it talking to SFML. Here is a link to the Github page.

Here is the link to the game on Itch https://itch.io/jam/altctrl2016/rate/87690


http://youtu.be/Zrh4ZZVeD1w

4
General discussions / New Blog - New Host!
« on: August 10, 2016, 08:35:18 am »
Hello SFML family. Lately I've had a lot of time on my hands so I decided to start a blog! Blog is going to have general technology stuff I find interesting and also SFML tutorials. I just finished a tutorial on how to make a Picking Sticks game. The blog is not for teaching beginners in C++ how to code C++ or build SFML or any of that setup stuff. It's just for quick simple little projects and show something new and cool to do with SFML.

Some ideas, comments and criticisms are always welcomed!

https://ricanteja.wordpress.com/
https://ricanteja.github.io/index.html

5
Window / Fullscreen when using OpenGL
« on: November 01, 2015, 07:51:02 am »
Hello all,

I recently started learning OpenGL and I'm having a problem when I want to toggle fullscreen on my sf::Window. I'm following the tutorials from open.gl and everything has been going smoothly but today I ran into this issue and haven't been able to solve it.

Here is the offending code:
#define GLEW_STATIC

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

#include "Render/RenderUtils.h"
#include "Log.h"


using namespace moony;

int main()
{
    sf::VideoMode videoMode = sf::VideoMode(800, 600, 24);
    sf::ContextSettings contextSettings = sf::ContextSettings(24, 8, 2);
    sf::Window window(videoMode, "SFML OpenGL", sf::Style::Close, contextSettings);

    sf::Clock clock;

    bool isRunning = true;
    bool isFullscreen = false;

    // Initialize GLEW
    glewExperimental = GL_TRUE;
    glewInit();

    // Create the VertexArrayObject
    GLuint vertexArrayObject;
    glGenVertexArrays(1, &vertexArrayObject);
    glBindVertexArray(vertexArrayObject);

    // Create the VertexBufferObject
    GLuint vertexBufferObject;
    glGenBuffers(1, &vertexBufferObject);

    // Define a Polygon pos3 col3 tex2
    float vertices[] =
            {
                    -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, // Top-Left
                    0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // Top-Right
                    0.5f, -0.5f, 0.0f,  0.0f, 0.0f, 1.0f, 1.0f, 1.0f, // Bottom-Right
                    -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f // Bottom-Left
            };

    // Bind VertexBufferObject and send Polygon data
    glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    GLuint elementBufferObject;
    glGenBuffers(1, &elementBufferObject);

    GLuint elements[] =
            {
                    0, 1, 2,
                    2, 3, 0
            };

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferObject);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW);

    GLuint shaderProgram = loadShaderProgram("./shaders/shader.vert", "./shaders/shader.frag");

    if(!shaderProgram)
        return -1;

    GLint attribPosition = glGetAttribLocation(shaderProgram, "position");
    glEnableVertexAttribArray(attribPosition);
    glVertexAttribPointer(attribPosition, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), 0);

    GLint attribColor = glGetAttribLocation(shaderProgram, "color");
    glEnableVertexAttribArray(attribColor);
    glVertexAttribPointer(attribColor, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(3 * sizeof(GLfloat)));

    GLint attribTexcoord = glGetAttribLocation(shaderProgram, "texcoord");
    glEnableVertexAttribArray(attribTexcoord);
    glVertexAttribPointer(attribTexcoord, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(6 * sizeof(GLfloat)));

    GLint uniformTime = glGetUniformLocation(shaderProgram, "time");

    GLuint textureObjects;
    glGenTextures(1, &textureObjects);
    glBindTexture(GL_TEXTURE_2D, textureObjects);

    sf::Image image_a;

    if(!image_a.loadFromFile("./textures/sample.png"))
        return -1;

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_a.getSize().x, image_a.getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_a.getPixelsPtr());

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glUniform1i(glGetUniformLocation(shaderProgram, "texture_a"), 0);

    while(isRunning)
    {
        sf::Event event;

        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed : isRunning = false; break;
                default: break;
            }
        }

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::F))
        {
            isFullscreen = !isFullscreen;

            if(isFullscreen)
                window.create(sf::VideoMode::getFullscreenModes()[0], "", sf::Style::Fullscreen, contextSettings);
            else
                window.create(videoMode, "SFML OpenGL", sf::Style::Close, contextSettings);
        }

        window.setActive(true);

        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glUniform1f(uniformTime, clock.getElapsedTime().asSeconds());

        //glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); // Comment this and all goes well.

        window.display();
    }

    glDeleteProgram(shaderProgram);
    glDeleteBuffers(1, &elementBufferObject);
    glDeleteBuffers(1, &vertexBufferObject);
    glDeleteVertexArrays(1, &vertexArrayObject);

    window.close();

    return 0;
}

The commented line is the problem. When I run it and get to glDrawElements(...); I get a SIGSEGV but when I comment it out no problems toggling fullscreen. I'm new to OpenGL so if I've missed something obvious be patient with me. Thanks in advance.

6
SFML projects / Moony Texture Packer - Quick and Simple Texture Atlas
« on: October 22, 2015, 08:45:24 am »
Hello everyone, it's been a while. I've been working on a tool for packing textures and sprite batching. Here is the repo: https://github.com/ricanteja/MoonySpriteBatch.

How To Use

The library is made up of just 2 headers (Log.h is a bonus). Those are SpriteBatch.h and TextureAtlas.h. These files know everything about loading texture atlases created by the Texture Packer and how to draw sprites.

Texture Packer

Once built you can drop the Texture Packer tool in any directory you want but it is most useful when usd from the commandline. When you run it without any args by default it will sniff around it's current directory for any images to pack. Texture pack files are named after the folder they were created in and texture pack images begin with ta_[NUMBER][FOLDER], for instance: ta_0myimages.png.

Here are the options you can pass to the tool:

-h : Prints a help message with the list of options
-b : Tells the tool not to produce seperate atlas image files but rather compress the raw color data and pack everything into the .mtpf texture pack file
-f [FOLDER] : Designate a folder you specifically want the tool to work in
-r : Recursivley search through all directories under the starting directory. This can be used together with the -f flag
-d [COUNT]: Produce [COUNT] # of debug textures.
-v : Outputs more messages.

Example

The moony::TextureManager class is in charge of loading your texture atlases you made with the tool. You should only need one instance of this object since it can load multiple texture atlases. You can search for the exact texture you want to assign to your sprite by searching by it's original name.

moony::TextureManager textureman;

textureman.loadFromFile("pack.mtpf");

moony::Sprite sprite(textureman.findSubTexture("happytree.png"));

To draw a sprie you need a moony::RenderManager class. It works fairly similar to SFML's own Drawable class (mostly because it inherits from it). Again you should really only need one instance of this class.

moony::RenderManager renderman;

...

window.clear(sf::Color::Black);

renderman.clear();
renderman.draw(sprite);
renderman.batch();

window.draw(renderman);
window.display();

The project has an additional dependency, Zlib, aside from SFML ofcourse. I'm not really good with CMake just yet but I wanted to share it. Maybe someone can use it, learn from it or someone can tell me what I can change and I can learn too.

Everyone loves pictures. Testing that layers indeed work. I didn't upload with the tons of images because it would have been annoying to see all that stuff spinning and doing stuff. But it works so yay!


Here is a picture of what the debug output of the Texture Packer looks like.

7
SFML game jam / Question about development process for game jam
« on: May 14, 2015, 04:20:12 am »
Hi all, really looking forward to this upcoming game jam but I have a question about how the entries should be coded. The question is: is it legal to use game engines (you've made) based on sfml or extension libraries provided by the community (like LTBL, Thor, Tiled TMX Loader etc) in your game making process or is this a game jam of pure SFML without any extras?

8
General / Making sf::RenderWindow fullscreen?
« on: July 18, 2014, 05:27:03 am »
To my knowledge there isn't any other way to fullscreen a window but to completely destroy it and create a new one with the sf::Style::Fullscreen flag set.

Is this really the only way to do it?

9
Hello there!

I have been reworking my collision detection using sfml shapes but I've noticed an issue when getting global
bounding box from non rectangular shapes.

Here is a code sample that reproduces the problem. I commented out the rectangle code because it works, you can uncomment it and comment the triangle shape code to see for yourself the difference.

#include "sfml/graphics.hpp"

int main(void)
{
    sf::RenderWindow m_window(sf::VideoMode(640, 480, 32), "Test Convex Shape", sf::Style::Close);
    m_window.setVerticalSyncEnabled(true);
    sf::Event m_events;

    sf::ConvexShape m_shape;
    /*m_shape.setPointCount(4);
    m_shape.setPoint(0, sf::Vector2f(0, 0));
    m_shape.setPoint(1, sf::Vector2f(0, 32));
    m_shape.setPoint(2, sf::Vector2f(32, 32));
    m_shape.setPoint(3, sf::Vector2f(32, 0));*/


    m_shape.setPointCount(3);
    m_shape.setPoint(0, sf::Vector2f(0, 0));
    m_shape.setPoint(1, sf::Vector2f(0, 32));
    m_shape.setPoint(2, sf::Vector2f(32, 32));

    m_shape.setFillColor(sf::Color::Transparent);
    m_shape.setOutlineColor(sf::Color::Red);
    m_shape.setOutlineThickness(1);

    sf::RectangleShape m_rectangle;
    m_rectangle.setFillColor(sf::Color::Transparent);
    m_rectangle.setOutlineColor(sf::Color::Yellow);
    m_rectangle.setOutlineThickness(1);

    while(m_window.isOpen())
    {
        while(m_window.pollEvent(m_events))
        {
            switch(m_events.type)
            {
                case sf::Event::Closed:
                {
                    m_window.close();
                    break;
                }
                default:
                    break;
            }
        }

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
            m_shape.move(0, -10);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
            m_shape.move(0, 10);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
            m_shape.move(-10, 0);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
            m_shape.move(10, 0);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
            m_shape.rotate(10);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
            m_shape.rotate(-10);

        m_rectangle.setPosition(m_shape.getGlobalBounds().left, m_shape.getGlobalBounds().top);
        m_rectangle.setSize(sf::Vector2f(m_shape.getGlobalBounds().width, m_shape.getGlobalBounds().height));

        m_window.clear();
        m_window.draw(m_rectangle);
        m_window.draw(m_shape);
       

        m_window.display();
    }

    return false;
}

The getGlobalBounds() function should return the bounding space in global coords right? So why the extra space that is not part of the shape included?

Help greatly appreciated!

10
General / making SFML project without using template
« on: February 22, 2013, 11:09:24 pm »
I'd like to be able to make my own project from scratch rather than use the templates provided and have to delete what I don't need (essentially everything)

How can I include the framework into my xcode project? That would include the headers and libs I need right? Or would I have to include each separately.

Currently, trying this without the templates is impossible to even compile because Xcode can't find the SFML headers.

I'd like to have this set up as simple as Codeblocks (adding libs and header search paths) but I don't want it spoon fed to me in the form of pre-made template projects.

I'm sure this feature exists in Xcode as it does in Codeblocks and VisualStudio I just haven't found it.


11
General / Another Mac Issue[SOLVED]
« on: February 21, 2013, 04:35:26 pm »
Hello again,

I'm not able to build anything from Xcode  :D
I am using Xcode 4.5 and I built SFML using cmake unix makefiles
Did sudo make install in terminal, built SFML and copied it into directories.

Ok this is all well and good, example programs run just fine.

I open Xcode and make a new project; select SFML app as the template and that gets the skeleton program infront of me. Problem is I can't build it. The headers are located and the program will compile. The specific problem is it will not link.

I'm using the default compiler is Apple LLVM 4.1 and the standard lib. C++98 with Clang and libstdc++. SFML binaries is set to link the framework.

This is the output I get when I build
Quote
ld: warning: ld: warning: ignoring file /Library/Frameworks/sfml-graphics.framework/sfml-graphics, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /Library/Frameworks/sfml-graphics.framework/sfml-graphicsignoring file /Library/Frameworks/sfml-window.framework/sfml-window, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /Library/Frameworks/sfml-window.framework/sfml-window

ld: warning: ignoring file /Library/Frameworks/sfml-audio.framework/sfml-audio, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /Library/Frameworks/sfml-audio.framework/sfml-audio

ld: warning: ignoring file /Library/Frameworks/sfml-network.framework/sfml-network, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /Library/Frameworks/sfml-network.framework/sfml-network

ld: warning: ignoring file /Library/Frameworks/sfml-system.framework/sfml-system, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /Library/Frameworks/sfml-system.framework/sfml-system
After it ignores the frameworks I get a whole bunch of undefined references.

Any ideas? Thanks guys, I've been really trying hard to figure it out myself but I'm at my wits end  :D

-edit-

When I switch the architecture from "Standard (32/64-bit Intel) to Native I get a different set of errors but I only get 8

Quote
(null): -Wuninitialized is not supported without -O
  "_NSLog", referenced from:

  "_OBJC_CLASS_$_NSAutoreleasePool", referenced from:

  "_OBJC_CLASS_$_NSBundle", referenced from:

  "sf::RenderWindow::RenderWindow(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, sf::ContextSettings const&)", referenced from:

  "___CFConstantStringClassReference", referenced from:

  "_objc_msgSend", referenced from:

  "_objc_msgSend_fixup", referenced from:

-edit-

Issue solved. I'll be uploading snapshots of the steps I took to resolve the issues to help others.
Thanks again guys!

12
General / [SOLVED](Thanks Hiura)Problem with examples on Mac OSX
« on: February 05, 2013, 05:58:20 pm »
Hey all! Long time no see. I've practiced SFML for a long time now on Windows and even Linux. It has even helped me begin to learn OpenGL. I currently have now a Mac at my disposal and I would like very much to learn how to dev on it as well. It is a totally new kettle of fish as I have discovered and XCode is frustratingly different from everything I've done in the past.

I've downloaded SFML 2.0 from the Git repo, installed Cmake and Doxygen and built the source.
I get no errors and it builds fine but the examples that use freetype or sndfile don't work.
The message the terminal gives me is this :
Quote
~ ratejada$ /Users/ratejada/Downloads/SFML-master/examples/opengl/opengl ; exit;
dyld: Library not loaded: @executable_path/../Frameworks/freetype.framework/Versions/A/freetype
Referenced from: /Users/ratejada/Downloads/SFML-master/examples/opengl/opengl
Reason: image not found
Cocoa example doesn't work either. It just opens and closes immediately without even giving an error

However the examples that only use SFML do work, like the window example with the rotating cube.

Any help? Thanks. Also, I am a TOTAL Mac noob. Last time I used it was back in high school to write papers.

Also to Mac SFML devs out there, could I get some pointers on things I should know and should be doing?

-edited typo.

13
General discussions / Who Are You? (the obligatory interview thread)
« on: September 01, 2011, 07:50:03 am »
I've just been curious lately and I often find myself off daydreaming while I'm supposed to be programming or studying..
but I wonder who all of you really are. This has to be the most diverse forum I've ever had the pleasure of being a part of
and I want to know the background of the many skilled programmers we have here, like how did you learn programming
and what made you get into it? Did you go to school to learn or are you an autodidact?
What country are you from and what languages do you speak?

I'm a 19 year old hispanic highschool drop out :? (left school but got diploma and going to college, no worries :wink:)
I program as a hobby and have been studying all programming languages on and off for about 6 years now.
I myself am an autodidact, I've taught myself C and "enough" C++ but am always learning new things.
I regret not knowing more languages since there are people from all over the world here.. everyone in my
house speaks at least 3 languages (English, Spanish and French) with the exception of my uncle and I. He speaks Latin, Greek, Spanish
and French and only knows how to say "Hello" and "My Friend" in English. I know English and Spanish
and a few* words in Dutch but I'm still studying

I want to know.. Who is Laurent Gomila?
Why did he decide to make SFML?
What is his preferred compiler?
What got him into programming in the first place?
Why do I keep saying "he" what if Laurent is a woman? :shock:
How long have you been programming Laurent?
Who taught you? (who ever it was think he can give me some tips?:wink:)

I'd love a detailed "story" reply from you Laurent, the curiosity has been killing me for some time now and I really want to know your background more <3.

And I want to get to know about all of you too :)
A bit of an awkward place to be doing a social activity but if you don't mind tell me a bit about yourselves.

Pages: [1]
anything