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

Pages: [1]
1
Network / Need clarification on sf::Packet << char * operator
« on: March 27, 2018, 04:26:11 pm »
I am trying to understand how something works in the SFML library and replicate it outside of the library for learning purposes.

With this operator
Code: [Select]
Packet & operator<< (const char *data)
Does it assume that the data is a null terminated string or can this be used for a buffer of data from a binary file?

I was under the impression that the only way to append raw chunks of data would be to use something like
Code: [Select]
void append (const void *data, std::size_t sizeInBytes)
but I just wanted to get clarification. Thanks so much.


Edit: If the append function is meant to be used, how would a chunk of data be retrieved in the same manner for an incoming packet?

2
Graphics / Getting strange Frames Per Second results (Pics included)
« on: April 03, 2016, 10:33:37 pm »
So, when I insert a Sleep(1) command in my loop that is polling/rendering for my window, I get about 100 fps as shown in this image.




However, when I remove the sleep command, I get about 8,300 FPS as shown in this image.



I am trying to understand why putting Sleep(1) takes my fps from 8300 down to 100. I would think that it would take it down to a bit under 1000 if it is normally 8,300 since there are 1,000 miliseconds in one second and Sleep(1) is only sleeping for 1 milisecond.

This is not a serious problem, but I am just curious as to why this happens if anybody knows. I included the Sleep there because I didn't want to put too much strain on the CPU. I didn't think it would reduce the fps by that much though.



Edit (4:56PM) - Well I just tried it again, and now i'm getting around 1000 fps with Sleep(1). It's just strange because after a few tries my fps will go back down to 100 for a few executions and then it will go back to 1000.


3
General / Weird Vector problem [Video/Source Included]
« on: April 20, 2015, 01:46:41 am »
Solved: I feel so stupid... I was debugging in release and that's why I was getting the unexpected behavior. Thanks for looking at it anyone who did sorry for wasting your time.  :-[

I am really dumbfounded on what is going on. The video explains the issue if you would like to see exactly what i'm encountering. Everything I have is encapsulated inside of my game class as far as rendering/sf objects such as rectangleshapes, texts, lines, etc. I added a
Code: [Select]
std::vector<int> IntegerVector; to my Game class, and the vector is constantly being modified/corrupted it seems. I don't know if it's a SFML thing or what, because I have done similar things using directx instead of SFML and never ran into this issue. (Having vectors inside of the game class randomly changing that is and also having the code randomly jump around)

Video highlighting issue:

You will probably have to select 1080p if it isn't on by default to be able to read the text.

Link to the source solution .rar: http://www.freewebs.com/smurf-job/SFML%20Template.rar

I would really appreciate it if anyone has a clue as to what is going on.

Thanks

4
Does anyone know if this is expected behavior or am I doing something wrong before leaving the scope?

Here is the code i'm using
Code: [Select]
#include <SFML/Audio.hpp>
#include "SFML/Config.hpp"
#include <Windows.h>
#include <iostream>
#include <string>

int main()
{
sf::SoundBuffer Example;
return 0;
}


Here's an image of the exception I get after the function returns once I exit the program. Is there something I should be doing to stop this from happening or is this expected behavior? Also note that I tested this with other objects such as the sf::Sound, sf::SoundBufferRecorder and even more and they all caused the same exception to occur once I exit the program. It is odd to me since I am under the assumption that it is not the destructor causing the issue since the following code does not cause an exception after the scope of the ExampleFunc() function is left. It only causes the exception once the program ends.
Code: [Select]
#include <SFML/Audio.hpp>
#include "SFML/Config.hpp"
#include <Windows.h>
#include <iostream>
#include <string>

void ExampleFunc()
{
sf::SoundBufferRecorder Example;
}

int main()
{
ExampleFunc(); //This executes fine
return 0; //After returning, once the program ends I get the exception
}

5
Audio / Not able to get SoundRecorder Documented example to compile
« on: February 19, 2015, 11:45:11 am »
Just started looking into the audio buffer for SFML 2.1 to try to record from my microphone and play it back in a stream.

However, i'm having issues even getting the basics compiled before even getting to what i'm trying.

I don't have much experience with virtual void functions, but I basically copy/pasted the code from
http://www.sfml-dev.org/documentation/2.1/classsf_1_1SoundRecorder.php
and i'm not having any luck.

A few problems i'm having.
Code: [Select]
if (!recorder.start())start is a void function, so I can't check if it returns true or false since it returns nothing, but the code on the example used it

Code: [Select]
virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount)My compiler isn't recognizing Int16 as a data type. I tried to figure out which header this would be included in, and I wasn't having any luck. I just changed it to UINT16* for now in my code, but i'm not sure if these are the same.

Here is my code
Code: [Select]
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")
#endif // SFML_STATIC

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Window.hpp>
#include <Windows.h>
#include <iostream>
#include <string>

using namespace std;

class CustomRecorder : public sf::SoundRecorder
{
virtual bool onStart() // optional
{
// Initialize whatever has to be done before the capture starts
// Return true to start playing
return true;
}
virtual bool onProcessSamples(const UINT16* samples, std::size_t sampleCount)
{
// Do something with the new chunk of samples (store them, send them, ...)
// Return true to continue playing
return true;
}
virtual void onStop() // optional
{
// Clean up whatever has to be done after the capture ends
}
};


int main()
{
if (CustomRecorder::isAvailable())
{
CustomRecorder recorder; //Error #1
if (!recorder.start()) //Error #2
return -1;
recorder.stop();
}
return 0;
}

Error #1
Quote
   1   IntelliSense: object of abstract class type "CustomRecorder" is not allowed:
            pure virtual function "sf::SoundRecorder::onProcessSamples" has no overrider   c:\Users\Jacob\Documents\Visual Studio 2013\Projects\SFMLGame\SFMLGame\Main.cpp   44   18   SFMLGame

Error #2
Quote
   2   IntelliSense: expression must have bool type (or be convertible to bool)   c:\Users\Jacob\Documents\Visual Studio 2013\Projects\SFMLGame\SFMLGame\Main.cpp   45   8   SFMLGame

Thanks for taking the time to read. Any input is appreciated. I just want to be able to get this compile so I can try to learn how to record and play to/from streamed audio buffers so that I can work on a basic voip later. Just really new to sound buffers and SFML.

Pages: [1]
anything