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

Pages: [1]
1
Graphics / Re: Mix RenderWindow with OpenGL
« on: January 30, 2021, 07:27:39 pm »
I know the threads seem very convoluted and even complicate things, but that's the way the program I am making runs everything.  I was about to find a solution over on this thread: https://en.sfml-dev.org/forums/index.php?topic=24081.0 Where after my while loop that ends around line 217 in the second thread, I needed to add

glBindVertexArray(0);
window->pushGLStates();
 

I needed to do additional clean up before returning out of Thread B.  But those lines did fix the problem.

2
Graphics / [SOLVED] Mix RenderWindow with OpenGL
« on: January 28, 2021, 07:48:19 am »
Hello everyone,

I am working on programming a game in which there are two threads, Thread A (which renders using SFML based calls to draw) and Thread B (which uses direct OpenGL based calls).  What happens is that I draw some text on screen in Thread A, then pause and switch to Thread B where I draw a Purple Triangle with a blue background.  When it switches back from Thread B to Thread A and tries to draw using SFML again, the purple triangle persists and the text does not appear.  This triangle then stays on screen forever and nothing overrides it.  I am using a RenderWindow when creating my window for the game.  I believe that I am missing some call that is needed to switch from OpenGL back to SFML but I am not sure what it is.  Maybe it is something else I am missing.

I went and created a fresh .cpp file that contains only the base code needed to run this example.  Each Thread runs for 3 seconds then switches (mostly documented in code) and if you run the code, the ESC key is a kill key as it runs in full screen.

(click to show/hide)

I am using the latest version of SFML and GLEW to run this .cpp example file.  I have attached the .cpp file (which is the code in the spoiler above)

Please let me know if there is something that I missed in my code that causes it to not be able to switch back from OpenGL drawing to SFML drawing.

3
Graphics / Re: Unicode Text Appearing as Boxes With Question Marks
« on: September 13, 2020, 05:33:37 pm »
A new font seemed to fix it.  Thank you.

4
Graphics / Re: Unicode Text Appearing as Boxes With Question Marks
« on: September 13, 2020, 05:26:54 pm »
I think your font doesn't support japanese characters. 🤔
https://docs.microsoft.com/en-us/typography/font-list/consolas

Interesting...I'm surprised that it worked when displaying in the command prompt then.  I'll try a different font and see if that fixes anything.

5
Graphics / Unicode Text Appearing as Boxes With Question Marks
« on: September 13, 2020, 05:02:11 pm »
Hello,

I am trying to get unicode characters working inside of my sfml based program written in C++.  I have tried using a wide string but when it draws on screen, it appears as a box with a question mark inside of it.  I am using the Consolas font when drawing the text.  I have my console set to use the same font and it draws the characters fine, but can't when drawn on screen.

Here is a simplified version of the code I am running:

// Creating of the render window
sf::RenderWindow gameWindow(sf::VideoMode(1920, 1080), "Game", sf::Style::Fullscreen);

// gameWindow is passed over to a thread so now I have a reference via pointer

// Load the font
sf::Font basicFont;
if (!basicFont.loadFromFile("Fonts/consola.ttf")) {
        wcerr << L"Can't load text" << endl;
        return;
}

// Create the basic text
sf::Text test;
test.setFont(basicFont);
test.setString(L"君の魂");
test.setPosition(500.f,500.f);
test.setCharacterSize(40);
test.setFillColor(sf::Color::White);
gameWindow->draw(test);
 
The font is loaded successfully and that return statement never called.

I have also attached the consola.ttf since maybe there is a problem with that.

I'm not sure exactly why it is unable to draw those characters.

6
Audio / Music getPlayingOffset() more accurate?
« on: February 20, 2020, 11:40:05 pm »
I am working on a rhythm style game and am using sf::Music to load and play my song files.  However, when I try to use the getPlayingOffset().asMilliseconds() function, it only is producing updates to the number every 20 milliseconds. For example:

// Create and open a song file
sf::Music song;
song.openFromFile(gameState.getSongPlaying().getAudioFilePath());

song.play();

// Test by outputting the offset.
while(1) {
    cout << song.getPlayingOffset().asMilliseconds() << endl;
}
 

I would expect that it would output something continouous like 1, 2, 3, 4, ... but instead get 0, 0, ..., 0, 20, 20 and repeat by 20s.

Is there a way to make it so that the offset is more accurately outputting to the millisecond instead of 20? Would that involve modifying a compiling a custom copy of the audio.dll?  Or would you have a better suggestion to get the current millisecond since the start of the song (i.e. would output 1000 if the song has been going for 1 second)?

EDIT: Would it be better to load the song into a sound buffer and then play using sf::Sound instead? Would the reduce the update delay?

Pages: [1]