Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML does not allocates depth buffer  (Read 4303 times)

0 Members and 1 Guest are viewing this topic.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
SFML does not allocates depth buffer
« on: October 10, 2015, 06:11:28 pm »
hello

i am making an OpenGL app - SFML for window and context management but i got incorrect depth testing but when i made framebuufer myself with renderbuffer as depth buffer everything became fine - that means that SFML does not allocates depthbuffer. And i have tried this:
context.depthBits = 24
and it didn't work.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11029
    • View Profile
    • development blog
    • Email
Re: SFML does not allocates depth buffer
« Reply #1 on: October 10, 2015, 11:31:32 pm »
"it didn't work" is not a problem description.

Provide a minimal example, explain what you want to achieve and how you checked if it worked or not.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: SFML does not allocates depth buffer
« Reply #2 on: October 15, 2015, 11:19:10 am »
i checked with this: with SFML framebuffer depth does not works(everything displays with painters algorithm) but when i create framebuffer myself with attchments to GL_DPETHBUFFER_ATACHMENT it works (mine of course)

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: SFML does not allocates depth buffer
« Reply #3 on: October 15, 2015, 01:00:24 pm »
You misunderstood expl0it3r:

You don't have to try to explain what's happening, if it's obvious.

Create a simple one-file program to show the issue (i.e. what you're describing), then put that either within [code]...[/code] tags or link it using a service such as Pastebin or GitHub's Gists.

In short: Provide us some code so we can just try it within minutes and which allows us to see whether it's indeed a bug or some wrong usage.

Otherwise, taking me as an example: I'd first have to look it up how to do that etc. then I'd have to implement it, and possibly I wouldn't know whether it's indeed working right or not (and I could make other mistakes you didn't).

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: SFML does not allocates depth buffer
« Reply #4 on: October 15, 2015, 05:22:14 pm »
i render two rectangles first with 1 z coordinate another with -1 coordinate, and draw them in that order: first one with 1 z coordibate and second with -1 z coordinate. But in result(with SFML default franebuffer) it appears to be drawn with painters algorithm(no z testing) but when i doo everything myself(allocate framebuffer)- z testing works fine. :(

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: SFML does not allocates depth buffer
« Reply #5 on: October 16, 2015, 03:15:17 am »
Give us the code you are using. Telling us what you are doing wont get you anywhere  unless you provide code with your explaination.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: SFML does not allocates depth buffer
« Reply #6 on: October 16, 2015, 08:39:40 am »
lets imagine, that i use two rectangles with these vertices:
0,0, -1,
0,-1,-1,
1,-1,-1
1,0,-1
and another
-1,-1,1
-1,1,1
1,1,1
1,-1,1
the first has green colour and second has red color.
and i create a SFML context like this:
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.antialiasingLevel = 4;
settings.majorVersion = 3;
settings.minorVersion = 0;

sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, settings);
and i draw everyrhing using gl-functiins(e.g. glClear)
as result i want to see green rectangle on top of red rectangle (that how must work depth testing) but i see only red rectangle(because without depth testing everything you s draw  in painters algorithm - the last drawn thing is on top of previous draw stuff
i draw everything with this code
while(window.isOpen()){
//process events
glClear(glColorBuffetBit | glDepthBufferBit);
//draw rectangle green first and then red
window.display();
}
 
but when i make everything myself (e.g. setup context, allocate framebuffer) depth testing works - green rectangle overlaps red rectangle.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: SFML does not allocates depth buffer
« Reply #7 on: October 16, 2015, 09:51:41 am »
Is it really that hard to write 60 lines of code we can build for ourselves? We know how all the stuff you say works, just give us something to test. If you want a mechanic to fix your broken car, you aren't going to stand in front of them and spend 2 hours telling them how to drive a car are you? At some point they will just ignore you and go do something more useful.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: SFML does not allocates depth buffer
« Reply #8 on: October 16, 2015, 11:07:03 am »
 okey-dokey in 2 hours.

lefreut

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: SFML does not allocates depth buffer
« Reply #9 on: October 16, 2015, 02:53:50 pm »
Do you call glEnable(GL_DEPTH_TEST) ? I think it's disabled by default.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: SFML does not allocates depth buffer
« Reply #10 on: October 16, 2015, 03:09:31 pm »
Yes, of course :( i call it, but still no result.

 

anything