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

Pages: [1]
1
General / Drawing different views with the same tileset.
« on: May 26, 2023, 02:50:24 pm »
Hello,

I have a class with essentially the following drawable function:
Code: [Select]
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const{
    states.transform*=getTransform();
    states.texture=&m_tileset;
    target.draw(m_vertices, states);
}

I want to be able to change the "m_vertices" between two different views where the tiles shown in one view remain unchanged after each draw but the other the tile placements can change. As far as I can tell, I can't change the draw function to have an option to select different "m_vertices" at draw time. I think that I could run set two instances of the class for each view but then I would have to load the tileset twice when initializing or set a separate function that sets a flag that changes the "m_vertices" before the tiles are drawn. Are these the only options or is there another way to adjust the drawable for the class?


2
Window / Re: window.draw() and window.display are slow
« on: May 22, 2023, 05:30:55 pm »
Thanks, I managed to get the hardware acceleration to work now (still with vcxsrv, too afraid to mess with my setup for ROOT browser). It runs at a reasonable speed now. I do however get a
Quote
Segmentation fault
when exiting the window but I don't think that is currently an issue to worry about.

3
Window / Re: window.draw() and window.display are slow
« on: May 22, 2023, 03:59:20 pm »
I am using X11 VcXsrv to produce the gui window. I am not sure if vGPU driver is installed (Set up the VcXsrv a while ago). I would guess its not installed for either my intel cpu or nvidia gpu's graphics setups.

4
Window / window.draw() and window.display are slow
« on: May 22, 2023, 03:36:28 pm »
Please bear with me, this is my first post.

I have been having issues with how slow my window polls events. My could main function is as follows:
Quote
#include <iostream>
  2
  3 #include <SFML/Graphics.hpp>
  4
  5
  6 int main(){
  7      sf::ContextSettings settings;
  8      settings.depthBits          = 24;
  9      settings.stencilBits        = 8;
 10     settings.antialiasingLevel  = 4;
 11     settings.majorVersion       = 4;
 12     settings.minorVersion       = 6;
 13
 14     sf::RenderWindow  window(sf::VideoMode(200, 200), "SFML works!", sf::Style::Default, settings);
 15     sf::CircleShape shape(100.f);
 16     shape.setFillColor(sf::Color::Green);
 17
 18     std::cout<<"OpenGL version: "<<settings.majorVersion<<"."<<settings.minorVersion<<std::endl;
 19
 20     while(window.isOpen()){
 21     ¦   sf::Event event;
 22     ¦   while(window.pollEvent(event)){
 23     ¦   ¦   switch(event.type){
 24     ¦   ¦   ¦   case sf::Event::Closed:
 25     ¦   ¦   ¦   ¦   window.close();
 26     ¦   ¦   ¦   ¦   break;
 27     ¦   ¦   ¦   case sf::Event::KeyPressed:
 28     ¦   ¦   ¦   ¦   if(event.key.code==sf::Keyboard::Escape){
 29     ¦   ¦   ¦   ¦   ¦   window.close();
 30     ¦   ¦   ¦   ¦   ¦   std::cout<<"closing window: Esc pressed\n";
 31     ¦   ¦   ¦   ¦   }
 32     ¦   ¦   ¦   ¦   break;
 33     ¦   ¦   ¦   default:
 34     ¦   ¦   ¦   ¦   break;
 35     ¦   ¦   }
 36     ¦   ¦
 37     ¦   }
 38     ¦   window.clear();
 39     ¦   window.draw(shape);
 40     ¦   window.display();
 41     }
 42     return 0;
 43 }

It seems to take a while to read the event type (usually I press the ```esc``` key just to close the window). When I comment out lines 39 and 40, the event is read rather quickly and closes the window. If they are commented out, it seems to take a rather large time (>10s) before it seems to recognize that the window should be closed.

I run on windows 10 using wsl2 from the Ubuntu 20.04 LTS environment. Is it possible the issue is related to WSL2?

In the terminal, I see the following output:
Quote
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 4.6 ; depth bits = 24 ; stencil bits = 8 ; AA level = 4 ; core = false ; debug = false ; sRGB = false
Created: version = 0.0 ; depth bits = 24 ; stencil bits = 8 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
Setting vertical sync not supported
sfml-graphics requires support for OpenGL 1.1 or greater
Ensure that hardware acceleration is enabled if available
OpenGL version: 4.6

I am not sure if it is related to the current problem or not but thought it might be helpful to include as well. I have an Intel(R) i7-6700HQ CPU and NVIDIA GeForce GTX 1060.

Pages: [1]
anything