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

Pages: [1]
1
General discussions / I don't understand how you implemented android
« on: January 01, 2017, 12:05:03 am »
Hello,
I was looking at the sfml source code trying to understand how it works

But i am having hard time to figure out how you implemented android
Normally you need a native activity, and you need to get an 'android_app' struct like shown in the doc:
https://developer.android.com/reference/android/app/NativeActivity.html

you need to specify a function for handling inputs, and commands to the 'android_app'

I am researching through your github code and I cannot find any trace of 'android_app' or responding to commands like losing focus, gaining focus. You need the reinit the context when you regain focus, (APP_CMD_GAINED_FOCUS command) , reload textures because they can be lost to when it goes to idle.

Where did you hide these stuff ?  ???

2
Thanks, it was that.

Now I moved the pollEvent loop at the end of the main loop, so drawing process will always be done BEFORE closing the window.

3
I have justed tested this code from open.gl:
http://open.gl/content/code/c2_triangle_elements.txt

I had the same issue.
It only happens with glDrawElements not with glDrawArrays.

So the problem does not come from the code but something else :/

4
General / OpenGL & SFML, crash at exit when using glDrawElements();
« on: May 16, 2014, 09:26:10 pm »
Hello,

I'am learning OpenGL and I am experimenting with glDrawElements, I use SFML for window system.

I've generated a 3d cube VAO using VBO and index buffer object, it renders well and correctly, but when I close the window I have an error message:
"Unhandled exception at 0x69761CB7 (nvoglv32.dll) in Opengl.exe: 0xC0000005: Access violation reading location 0x00000000."

And it shows me this line :
"window.display();"

VAO generation part:
GLuint createCube()
{
        const float vertices[] = {
                0.25f, 0.25f, -1.25f, 1.0f,
                0.25f, -0.25f, -1.25f, 1.0f,
                -0.25f, 0.25f, -1.25f, 1.0f,
                -0.25f, -0.25f, -1.25f, 1.0f,
                0.25f, 0.25f, -2.75f, 1.0f,
                -0.25f, 0.25f, -2.75f, 1.0f,
                0.25f, -0.25f, -2.75f, 1.0f,
                -0.25f, -0.25f, -2.75f, 1.0f,


                0.0f, 0.0f, 1.0f, 1.0f,
                0.8f, 0.8f, 0.8f, 1.0f,
                1.0f, 0.0f, 0.0f, 1.0f,
                0.0f, 1.0f, 0.0f, 1.0f,
                0.5f, 0.5f, 0.0f, 1.0f,
                0.0f, 1.0f, 1.0f, 1.0f,
                0.0f, 1.0f, 0.0f, 1.0f,
                0.5f, 0.5f, 0.0f, 1.0f,
        };

        const GLshort indexData[]
        {
                        0, 1, 2,
                        1, 3, 2,
                        4, 5, 6,
                        6, 5, 7,
                        2, 3, 7,
                        2, 7, 5,
                        0, 6, 1,
                        0, 4, 6,
                        4, 0, 2,
                        4, 2, 5,
                        6, 3, 1,
                        6, 7, 3,
        };

        GLuint vao;
        glGenVertexArrays(1, &vao);
       
        GLuint vbo;
        glGenBuffers(1, &vbo);

        GLuint indexObjectBuffer;
        glGenBuffers(1, &indexObjectBuffer);

        glBindVertexArray(vao);

        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

       
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexObjectBuffer);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, 36*4, indexData, GL_STATIC_DRAW);

        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);

        glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); // vertices
        glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (void*)128); // color

        glBindVertexArray(0);

        return vao;
}

Drawing:
        glUseProgram(program);
        glBindVertexArray(vao);
       
        // (...)
 
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                        {
                                window.close();
                        }
                }
 
               // (...)
 
                glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
                glClear(GL_COLOR_BUFFER_BIT);
 
 
                glUniform3f(offsetUniform, offsetX, offsetY, offsetZ);
 
                glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);
 
                window.display();
        }


The entire code:
http://pastebin.com/uhRRbKNr

Thanks,

5
SFML projects / Re: Eleutheromania - 2D RPG - Work in progress
« on: May 11, 2014, 01:46:25 pm »
that's impressive !

I was working on a similar project but I had problems with perspective when a player was between two tiles

how did you manage perspective ?

do you draw every tile in a loop or they are attached together and drown in one call ? do you use the sf::sprite class for tiles or vertices ?
thanks

6
SFML projects / Re: quadtree
« on: April 26, 2014, 09:32:07 pm »
Update:
-I've done most of things you said, now the class is composed of Boundable objects instead of template class.
-It now handles collisions and sends you a collision set

Quadtree.h : http://pastebin.com/R07dXQJK
Quadtree.cpp : http://pastebin.com/hPBCLReD
Boundable.h : http://pastebin.com/1W2fbPP7

And I've made a little demo for testing, you can download it here:
https://www.dropbox.com/s/gtlhyv5xedhywhm/Quadtree.rar

Mouse wheel -> changes the limit of objects in quadtrees
Left mouse button -> Adds one object
E key -> Adds 100 objects
R -> Activates / Deactivates random size objects
X -> Clear the quadtree
C -> Activates / Deactivates collision

the performance is not perfect but it's OK

7
SFML projects / Re: quadtree
« on: April 26, 2014, 12:58:18 am »
thanks for your thoughts

1 ) I agree

2 ) Yeah it could give more possibilities as you said. I choosed template class because I thought it would be easier to implement for the user, they would just have to add one method to their drawable object and they could use it.

4, 6, 5, 7, 8 ) you're right

9 ) By "implementing" I meaned, modifying the class (I used the wrong word I guess). You could add a method which iterates through all children an checks collisions between objects and insert them in a set of pair.


(sorry for my english)

8
SFML projects / quadtree
« on: April 25, 2014, 11:20:16 pm »
Hello,
I have build a region quadtree class which manages itself, without having to insert objects to it every frame.
This is the first time I build a Quadtree, also my first template class in C++.

It tracks objects bounding rect every frame and update their position in the quadtree.
The quadtree has infinite levels.

Quadtree.h
http://pastebin.com/0LjAHgM7

Qtree.inl
http://pastebin.com/S6vHFCyk

I've tried to make it the fastest possible.
It only updates objects positions, and remove wrecks when a quadtree is marked for removal.

If you want to use this quadtree:
-You simply need a class which has "getBoundingRect()" method which returns a floatrect.
-you insert your objects once, and call "manage()" method every frame

know that the quadtree has probably some bugs, I did not test it to much.

there is no collision system yet, you have to implement it yourself

------------------

My goal is to make the Quadtree 99% self managed, I mean we only insert objects, and update it, then we do not care about it.

When I delete an object, I have also to remove it from the quadtree.
I'd like that the quadtree checks every frame if every of his objects still points to something, if not it removes it automatically.
So we won't have to remove ourselves.
I've heard that we can do this combining shared_ptr and weak_ptr but it seems complex...

your advices are welcome

UPDATE:
-no more template
-It now handles collisions and sends you a collision set

Quadtree.h : http://pastebin.com/R07dXQJK
Quadtree.cpp : http://pastebin.com/hPBCLReD
Boundable.h : http://pastebin.com/1W2fbPP7

And I've made a little demo for testing, you can download it here:
https://www.dropbox.com/s/gtlhyv5xedhywhm/Quadtree.rar

Mouse wheel -> changes the limit of objects in quadtrees
Left mouse button -> Adds one object
E key -> Adds 100 objects
R -> Activates / Deactivates random size objects
X -> Clear the quadtree
C -> Activates / Deactivates collision

the performance is not perfect but it's OK

9
General / Re: sfml scenegraph and world transformations issue
« on: March 05, 2014, 09:33:43 pm »
That's what I do, I call getWorldTransform(), here for SpriteNode's boundingRect :
http://pastebin.com/jvqTRdrT

sf::FloatRect SpriteNode::getBoundingRect()
{
        return getWorldTransform().transformRect(mSprite.getGlobalBounds());
}

And I output getBoundingRect.left here in Obstacle.cpp:
http://pastebin.com/xhPtNMc2

 // MChildren.at(0) is one of the SpriteNode's attached to the TubeObstacle Entity
std::cout << mChildren.at(0)->getBoundingRect().left << std::endl; // output is always 0, but his Parent is moving to left




10
General / sfml scenegraph and world transformations issue
« on: March 05, 2014, 08:09:36 pm »
Hello,

I've built a SceneGraph almost same as the SFML game development book scenegraph

and I'm having trouble with transformations : I have a "TubeObstacle" class, inherited from Entity, which is composed of 2 SpriteNode

I set the velocity to (-300,0), everything moves fine, but when I try to get one of the SpriteNodes X position the output is always 0 :/


Obstacle.h http://pastebin.com/nhyP44yH cpp http://pastebin.com/xhPtNMc2
SpriteNode.h http://pastebin.com/TR4awU6E cpp http://pastebin.com/jvqTRdrT

Scenenode: https://github.com/SFML/SFML-Game-Development-Book/blob/master/08_Graphics/Include/Book/SceneNode.hpp

thanks

11
General discussions / Re: SFML Game Development -- A book on SFML
« on: March 04, 2014, 01:27:00 pm »
Hello,
Thanks for this awesome book

Question to authors:
How many years of experience you guys have ?
Did you design the all SceneNode/Game system yourself or you get inspired from other existing structures ?

I just can't imagine a similar structure myself, I've always have to copy your code in all my games... :(


sorry for my english

12
Quote
They are defined, mostly in SceneNode itself. Otherwise the code wouldn't link...

yeah it seems that it works with no pure virtuals but I use pure virtuals with "=0;" (in Scenenode) so it wasn't working for me ( I mean I can't use it as is )

I have a MouseArea class which is derived from SpriteNode.

I initialize it like this (in a class constructor) : mouseArea = MouseArea::Ptr (new MouseArea(mouseAreaTexture));

MouseArea has no constructor but SpriteNode has.
I have this error message:
no instance of constructor "MouseArea::MouseArea" matches the argument list
            argument types are: (sf::Texture)

how do I use SpriteNode's constructor if it's possible to use it with a derived class as you said?

sorry i'am a newbie

edit:
And one question about this SceneNode system. So they are Scenenodes and they all have childrens we can only update and draw them ..
But what if I want to sent an information to a specific child ? For example I want to send mousePosition every frame to MouseArea but it's a child of my map.

13
Hello

https://github.com/SFML/SFML-Game-Development-Book/blob/master/10_Network/Include/Book/SpriteNode.hpp

I don't see the utility of this class
where is it used ?

you can't use it as is because all of the virtual methods (from SceneNode) aren't defined, so you have to make a class which derives from it I guess ?

but if I make a class which derives from SpriteNode i'll not be able to use SpriteNode's constructor, am I ?

Pages: [1]