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

Pages: [1]
1
Graphics / Re: GetPixel, any faster method of access?
« on: August 04, 2013, 08:27:32 pm »
Thank you for quick answer.
How it works: data is transfered from CPU to GPU during
 texture.getTexture().copyToImage()
or when getPixel is called?

2
Graphics / GetPixel, any faster method of access?
« on: August 04, 2013, 08:10:27 pm »
Hi,
I want to compare images using SFML I tried to do using shaders (http://en.sfml-dev.org/forums/index.php?topic=12239.0) and now I want to make non-shader version.
Currently i have something like this:
                // drawing some polygons on texture

                texture.display();
                sf::Image& generatedImage = texture.getTexture().copyToImage();

               
                long double diff = 0;
                int j = 0;
                for(int j = 0; j<300; j++)
                {
                        for(int i = 0; i<300; i++)
                        {
                                diff += std::abs(generatedImage.getPixel(j,i).r - originalImage.getPixel(j,i).r) +
                                std::abs(generatedImage.getPixel(j,i).g - originalImage.getPixel(j,i).g) +
                                std::abs(generatedImage.getPixel(j,i).b - originalImage.getPixel(j,i).b);
                        }
                }
 

as you can see I'm using
sf::Image& generatedImage = texture.getTexture().copyToImage();

and then when I want access pixel values:
generatedImage.getPixel(x,y).r

I have run profiler and it shows that program spend almost whole time in getPixel() insted of copyToImage(). I thpught that when i call .getTexture.copyToImage() the whole image will be copied from GPU to CPU and then accessing pixels will be very quick. Maybe I do something wrong? Can anyone help me?

3
Graphics / Re: Compare images using shaders
« on: July 18, 2013, 04:49:52 pm »
Using SFML the value is between 0-1, SFML doesn't support different texture formats yet *frowns in Laurent's general direction*

That means that if I will write my own "reading from GPU" code (using OpenGL) I can use more values than 255 for each channel(0-1f)?

4
Graphics / Re: Compare images using shaders
« on: July 16, 2013, 01:59:51 pm »
During computing difference between images I recive quite big numbers: it is possible to store my original result number in 1x1 texture or I have to scale it to 0-1 range?

5
Graphics / Re: Compare images using shaders
« on: July 16, 2013, 09:53:55 am »
Thanks :)   I have another question, after all my calculations I will be interested in reading difference result from GPU to CPU. It will be one number only and I want to to make reading very fast, could you please give me hint how to do correctly? I thought about following solution (in las shader): shader will be run on 1x1 texture and will have  texture parameter (1x height) - it will "sum" all pixels from texture parameter and then write result to 1x1 texture. Then i will read 1x1 texture to CPU using SFML. It will be fast solution or there are any better?

6
Graphics / Re: Compare images using shaders
« on: July 16, 2013, 07:20:22 am »
Thank you :)
It is possible to use more than one shader during drawing sprite in SFML?

7
Graphics / Re: Compare images using shaders
« on: July 15, 2013, 09:49:51 pm »
I'm glad to hear that :) Could you please give me any hint how to achieve my aim(it will be easier to start looking for something particular instead of "HDR open gl" ;))>

8
Graphics / Compare images using shaders
« on: July 15, 2013, 09:34:29 pm »
Hallo,
I has following problem to solve:
I want to compare (pixel-per-pixel) two textures (first generated from many draw shapes, second read from disc) using fragment shader. Unfortunately i'm new in graphics and open gl and i need some help. My idea was:
  • Draw some SFML shapes on texture
  • Fill second texture with .bmp from disc
  • Run fragment shader which will be run on generated texture (.bmp texture will be shader parameter) and will store information about difference for example in alpha channel ((r1-r2)^2+(g1-g2)^2+(b1-b2)^2)
  • Run second pixel shader which will sum differences in rows
  • Run third shader which will sum "partial sums"
I believe that in result I will have one number - difference between two images.
But I have few questions:
  • It is good conception of comparing two images using gpu?
  • it is possible to run three different pixel shaders using SFML?
  • How can I read my final difference from shader (reading texture values will be probably very slow?)?
  • Is there any option for "output" parameter from pixel shader?

I will appreciate any help :)

9
Audio / onProcessSamples every 10ms
« on: November 16, 2012, 10:23:14 am »
Hello,
in sfml documentation i found that:
" .. You only have a single virtual function to override in your derived class: onProcessSamples. It is called everytime a new chunk of audio samples is captured, so this is where you implement your specific stuff.
Audio samples are provided to the onProcessSamples function every 100 ms. This is currently hard-coded into SFML and you can't change that (unless you modify SFML itself). This may change in the future. .."


this means that only line i have to change for custom time of calling onProcessSamples is in this function:
void SoundRecorder::record()
{
    while (m_isCapturing)
    {
        // Process available samples
        processCapturedSamples();

        // Don't bother the CPU while waiting for more captured data
        sleep(milliseconds(100));
    }

    // Capture is finished : clean up everything
    cleanup();

    // Notify derived class
    onStop();
}
 
?

Pages: [1]
anything