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

Pages: [1]
1
I'm trying to draw a day sky (blue) and during the evening, I want to slowly blend in another image/texture which is the dusk (orangish blue).

How can I do this? People mentioned using mix() and lerp (which is a HLSL term). I want to adjust my opacity as it blends in, as the time changes.

2
Graphics / Rotate and translate shader output sprite
« on: December 07, 2012, 04:32:45 am »
I have an issue that i have a tilemap where i want it to be rendered only in multiples of 16, even if the screen is not as such. So as a result, i have a 4 px (900 % 16 == 4) result on the top. I wanted to move the tilemap up 4 px to hide that..how do i do this?

i tried:

    sf::Transform transform;
    transform.rotate(50.0f);
    sf::RenderStates state;
    state.shader = &m_shader;
    state.transform = transform;
    m_window->draw(m_tileMapFinalSprite, state);
 

hoping that it could rotate the result, but that doesn't work. which means that it won't be able to translate the y value either..

so, i need to move the output up. I tried moving the sprite, but this results in cutting it off, not actually moving anything..

3
I'm not sure where this is, but the only thing i can think of the problem existing in, is within the fragment shader. i pass it a row of 16x16 textures whcih are the tile_types_super_texture, and then a pixel representation of that tilemap. but my tilemap is actually visibly a couple pixels below (y) of where it should be. here's a screenshot http://wstaw.org/m/2012/12/05/plasma-desktopI21411.png

the crosshair is fine and is locked at 16x16 increments. i thought perhaps my view is off by 2 pixels or something..but that strikes me as odd as well/not possible.

i wanted to try and render the result and save that as an image, to see if the shader is in fact the issue..but i wasn't sure how to do that.

and just to make sure it wasn't my crosshair's alignment, i pushed the tilemap all the way to the top, and there's a 2px remaining from what is a tile that should be off the screen (above the top of the screen).

is there some issue here with me casting to integer, do you think? i'm kind of lost, and a bit disheartened because i thought my tile map was working perfectly, and here it's some odd problem.

i'm not even sure if it's not a driver issue..if somebody could also test this out, it probalby only builds on linux, but should be pretty easy to build there since it uses cmake. sfml 2.0 of course: https://github.com/sreich/buildarrhea

or maybe you can suggest something?

#version 130

//for a 1600x900 screen, this results in an image of 50x100 with each pixel representing a tile
uniform sampler2D tilemap_pixels;
//a runtime generated spritesheet of all tiles we know, each tile being 16x16 (so 48x16 if there are 3 tile types)
uniform sampler2D tile_types_super_texture;

//FIXME: stop hardcoding ..
ivec2 TILE_SIZE = ivec2(16, 16);

void main()
{

    ivec2 tilemap_size = textureSize(tile_types_super_texture, 0);

    ivec2 screen_coordinates = ivec2(gl_FragCoord.x, gl_FragCoord.y);

    // find the pixel (RGBA) values in the tilemap pixel representation that is what we're
    // currently interested in.
    vec4 currentPixel = texelFetch(tilemap_pixels, screen_coordinates / TILE_SIZE, 0);

    ivec2 tileCoordinate;
    tileCoordinate.x = (int(currentPixel.r * 255.0) ) * TILE_SIZE.x + (screen_coordinates.x % TILE_SIZE.x);
    tileCoordinate.y = screen_coordinates.y % TILE_SIZE.y;

    vec4 tileColor = texelFetch(tile_types_super_texture, tileCoordinate, 0);

    gl_FragColor = tileColor;
}

4
Graphics / SFML 2.0 equivalent of SFML 1 Image::LoadFromPixels?
« on: December 03, 2012, 02:46:22 am »
same as my previous topic, but need a loadfrompixels equivalent. kthxbai

5
Graphics / SFML 2.0 equivalent of SFML 1 PreserveGLStates?
« on: December 03, 2012, 02:14:59 am »
as the title says, i'm porting 1.x code to 2.x, and i ran into this amongst its opengl code and have no idea what to do with it.

6
i spent way, way too many days trying to learn opengl shaders with sfml and what not. only to find out that i was doing:

m_shader.setparam()
//many lines of blah
m_shader.load
m_shader.setsomeotherparam()

needless to say, as you'd expect, there's no way that could work ;)

it'd be nice if sfml would just assert on that scenario, since that's 110% lib user fault that should yell at the programmer asap.

even if only for this scenario, and not for if you load a shader, set a param then load another shader into it..since that's not possible to check of course.

7

the tilemap_pixels is a 50x100 image of every pixel being color.r = 150, as you can see. the saved image on disk confirms that as well..the result from the shader is an all-green image though. and i tried playing with the coordinates and all kinds of things. it leads me to believe that it simply isn't sending it like it should. i'm not getting any warnings like it isn't being loaded or anything, and this method is in fact being run...

shader code: http://pastie.org/5375234

what i set in my game..
            image.setPixel(x, y, sf::Color(150, 0,0));
            ++x;
        }
        ++y;
        x = 0;
    }

    image.saveToFile("test999999.png");
    std::cout << "image size, width: " << image.getSize().x << " height: " << image.getSize().y << "\n";
    sf::Texture texture;
    texture.loadFromImage(image);
    m_shader->setParameter("tilemap_pixels", texture);
 

here's a gltrace from glsldevil, that's the best kind of "debugging" i can find...
http://fpaste.org/WIoZ/

8
Graphics / sf::Shader (GLSL) and texture2DArray?
« on: November 09, 2012, 12:44:16 am »
I have a set of texture tiles...> 256 of them (i'm future-proofing here..), and it'd be nice if i could just push to my fragment shader directly to a texture2Darray...as opposed to having either 1 big spritesheet (which would be runtime generated because i fucking hate spritesheets), or something.

that way the the shader could just look them up easily in the texture2d array and be all like "i need tile type 24", *goes to index 23*.

thoughts?


edit: feel free to move to GRAPHICS cat

9
Graphics / sf::View Position?
« on: November 05, 2012, 03:59:13 am »
how can i get the position the view is at? i find it misleading..maybe i'm using it incorrectly, but my view is always centered on the player and so i always move() it. the issue is, after a while of move()ing it, i now need to know where it is so that i can see if my tile map's blocks are visible (so it requires some coordinates conversions..)

ideas?

10
General / Handling lowercase tilde? (`) accent key?
« on: November 01, 2012, 03:07:06 am »
I can't find any handling for: the ` key, to the left of the 1 which contains Tilde as well on a US keyboard.

http://www.sfml-dev.org/documentation/2.0/classsf_1_1Keyboard.php#acb4cacd7cc5802dec45724cf3314a142a401a183dcfde0a06cb60fe6c91fa1e39

I guess it's called the accent key. Is this not available in the API?

11
Hey, trying to convert the event.text.unicode value into something printable, preferably std::string related...

(SFML 2.0)

http://www.sfml-dev.org/documentation/2.0/structsf_1_1Event_1_1TextEvent.php
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Utf_3_0132_01_4.php#ae274c5057c343ba353253bd2c531a283


    std::string str = "";
    sf::Utf32::encodeAnsi(event->text.unicode, std::back_inserter(str), 'e');
    std::cout << str << std::endl;

However, the codepoints seem to be way off for my locale or something. e.g. i slam on A-Z and i get out blank spaces. I hit the forwardslash (/) and it returns 4. I hit enter and it returns ":" (colon).

what's up?

12
Graphics / Moving sprite in direction of rotation.
« on: August 03, 2008, 06:25:19 pm »
Hello, I was wondering, because I cannot figure out how to get this to work correctly, when I was using XNA the rotation it had was not in degrees but i believe went from 0 to 6 or something, and was a floatational value (I know, it's the dumbest thing I've ever heard). But now that SFML uses 360 float (much better), it appears that the method I had used previously, does not work. I don't know if I did something wrong with the XNA-SFML conversion, but it is completely irregular (i.e. I will turn a small amount and it will reverse (or random) to a direction).

This is the code I had used in XNA.....

Code: [Select]

/*if (Keyboard.GetState().IsKeyDown(Keys.W) |
                                                                         Keyboard.GetState().IsKeyDown(Keys.S))
                                                                         {
                                                                         //Had to swap the cos, with the sin, and make the cos negative
                                                                         //otherwise it would be walking the left side of the player,
                                                                         //which just wouldn't make any sense.
                                                                         PlayerVelocityAdditive.Y = -(float) Math.Cos(Player_CurrentRotation);
                                                                         PlayerVelocityAdditive.X = (float) Math.Sin(Player_CurrentRotation);
                                                                         PlayerVelocityAdditive *= Player_VelocityAccelerationMultiplier;
                                                                         //modelVelocityAdd.X *= PlayerVelocityAccelerationMultiplier;
                                                                         if (Keyboard.GetState().IsKeyDown(Keys.W))
                                                                             {
                                                                             Player_CurrentVelocity += PlayerVelocityAdditive;
                                                                             }
                                                                         else //else its S
                                                                             {
                                                                             Player_CurrentVelocity -= PlayerVelocityAdditive;
                                                                             }
                                                                         }*/

//...............
//                Player_CurrentPosition += Player_CurrentVelocity;//add the current velocity, to the current pos.





And this is the code that I have converted to SFML....

Code: [Select]

  sf::Vector2f Car_Velocity_Additive ;
                            Car_Velocity_Additive.y =  -(float) cos (Sprite.GetRotation() )*3;
                            Car_Velocity_Additive.x = (float) sin(Sprite.GetRotation() )*3;
                            if (App.GetInput().IsKeyDown (sf::Key::W))
                            {
                                          //Car_Velocity.y += 10;
                                          Car_Velocity += Car_Velocity_Additive;

                            }

                            if (App.GetInput().IsKeyDown (sf::Key::S))
                            {
                                          // Car_Velocity.y -= 10;
                                          Car_Velocity -= Car_Velocity_Additive;
                            }
                            //Sprite.Move (0, -100 * ElapsedTime);
                            Sprite.Move (Car_Velocity.x *ElapsedTime, Car_Velocity.y*ElapsedTime);



Hopefully I didn't make a mistake in copy-paste. But anyways, I don't know why it's not working... I've tried swapping cos/sin, and using a negative in a diff place (or not at all(or both places)). Very confused I am(heh).

Anyways, hopefully you guys can help me, as this is really annoying, I do recall having the same problem with XNA, but it was because of me needing to swap the math functions or something to that degree.

I'm not entirely sure why we use these math functions, or how they do exactly (or should) what they do, however.

13
Graphics / [Solved] Crapping the Framerate?
« on: June 28, 2008, 06:48:35 pm »
Hi, I'm completely new to SFML, and was wondering if it is native and possible to cap the frame rate. I read somewhere in the forums about somebody mentioning a function for it, but I found no such function in the documentation.

Pages: [1]
anything