1
Graphics / Re: New to lighting - Confused about how to handle drawing
« on: April 20, 2020, 12:41:30 am »
From what I can tell, everything is working as it should now! Thanks for the help and great explanations!
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.
IMPORTANT: remember to clear, draw, and display on the render texture too!
Without that, the previous buffer can be shown and sometimes it's flipped (this isn't necessarily the issue).
Are you using views? The render texture can have the same view as the window to make it more simple.Doing this breaks the positioning... again. I still think I need to do this, and I'm just not doing it correctly. I'm modifying the view coordinates in order to try and put the player at the center of it. This works for the actual camera, but not for the RenderTexture. This again puts the lighting rectangle at the bottom left of the screen, and neither the black RenderTexture nor the white lighting rectangle seem to move at all. My drawing code together with the camera logic looks like the following:
g++ *.cc *.h *.cpp -std=c++14 -lsfml-system -lsfml-graphics -lsfml-window -Wall -Wextra, but it immediatly closes when I try and run it, and gives me that error. I got this error while reworking my main menu code.
First of all, in the original program down i passed it by pointer, forgot to do it here.void show(sf::RenderWindow window)
void getMenuResponse(sf::RenderWindow window)
You need to learn basic C++ before trying to use SFML. If you read the error it is quite clear what the problem is.Quotewhen passing a pointer in a function
You are not passing a pointer...Quote'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
You can not copy the window class, so either pass it as a pointer or reference to your function.
If that works, your code must be bugged.Thats pretty much what i was asking for help for. Like you may have assumed, the example code from the visual studio tutorial did work.
Don't assume, check...Drives updated, still as white as ever. The only thing i recall changing is using the constructor to create the window instead of
Also what did you change if it worked before?
Since you have the debugger running, does it reach the clear statement?Yes, it reaches the clear statement AND the display.
Is your graphics driver installed/uptodate?
1. I never saw that post.Looks like you never changed the value of _gameState to playing.
It's not only weird or something one can change "later", but it's simply wrong. Rendering doesn't belong into the event loop, so don't do it.Ok, thanks for telling me. However, it still doesnt change the color. Its as white as it always was.
I'm not sure if this is directly related to your problem, but your gameloop seems a bit weird to me. Right now you are only clearing and displaying the window if an event happens. Perhaps you want something like this instead?Its supposed to be like that. Later, when i get further in the tutorial, i will do different stuff.Code: [Select]while(_mainWindow.pollEvent(currentEvent))
{
if(currentEvent.type == sf::Event::Closed)
{
_gameState = exiting;
}
}
switch(_gameState)
{
case playing:
_mainWindow.clear(sf::Color::Red);
_mainWindow.display();
}