KGL Clipping Issue

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
bogglez
Moderator
Moderator
Posts: 576
Joined: Sun Apr 20, 2014 9:45 am
Has liked: 0
Been liked: 0

Re: KGL Clipping Issue

Post by bogglez » Fri Jul 15, 2016 9:18 am

111 wrote:
bogglez wrote:Is this more like what you expected?
aside from missing texture filtering - yes.
I commented that out, because it's invalid OpenGL (those constants don't exist). Seems like KGL accepts this, although it shouldn't..

The correct way to specify the texture filter would be:

Code: Select all

    texture[0] = glTextureLoadPVR("/rd/crate.pvr", 0, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    texture[1] = glTextureLoadPVR("/rd/ground.pvr", 0, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
("lvl.obj" is still rendered incorrectly though, no clipping issues, it is just does not look the way it should)
Yeah, something seems to be weird about the clipping code, still.

Here is the code to get the result in the binary.
objloader_fix_code.7z
(4.11 KiB) Downloaded 17 times
Basically I enabled near z clipping and switched to vertex arrays.

Ph3nom:
1. I think you tried to replicate the PVR's texture filtering constants in OpenGL. You really shouldn't do this, as it defeats the purpose of a cross-platform graphics library.
2. I was not able to change the face culling in KGL, so I would always see the inside of the box. In my libgl15 this worked fine.
3. I don't have support for clipping in libgl15, so I couldn't compare that, sadly. I think you're only clipping against the near plane, because the PVR does the horizontal clipping by fragment. Maybe you need to clip against the other planes as well? Haven't put much thought into it. Also, have you tested the algorithm with large polygons or just small polygons?
3. enabling near z clipping didn't work for me with glBegin, but maybe I did something wrong. worked with vertex arrays.
4. I think near z clipping should really be on by default. turning it off is a performance optimization that can only be used when the user checks the required conditions.
5. Your example code uses invalid OpenGL constants. Maybe you want to use the gl.h I have in my library which uses only standard constants, and remove the invalid ones from your code.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
111
DCEmu Junior
DCEmu Junior
Posts: 37
Joined: Thu Jul 07, 2016 7:11 pm
Has liked: 0
Been liked: 0

Re: KGL Clipping Issue

Post by 111 » Fri Jul 15, 2016 5:16 pm

bogglez wrote: I commented that out, because it's invalid OpenGL (those constants don't exist). Seems like KGL accepts this, although it shouldn't..
it works just fine though. I did not do this on purpose really, it was copy-pasted from the examples. And since I did not receive any compilation errors, I just left that as is.
Basically I enabled near z clipping and switched to vertex arrays.
for some reason, doing this actually fixed the issue for me this time. Which is weird, I'm sure I've tried arrays before (maybe because I mixed that with immediate mode or something).
Thank you very much.

3. ... Also, have you tested the algorithm with large polygons or just small polygons?
both. It is not really that noticeable with smaller ones. With larger polygons though, the result is an ugly mess most of the time.
5. Your example code uses invalid OpenGL constants. Maybe you want to use the gl.h I have in my library which uses only standard constants, and remove the invalid ones from your code.
maybe, but I don't really think I have to do it right now. If I ever run into another mystical problem though, I'll definitely try this first.


All in all, does that mean I should just avoid using immediate mode for the time being?


PS: I apologize for ranting before. I just want to make a damn game, instead of spending time fighting with the tools I use (it is very counterproductive, discouraging, time-consuming and frustrating, to say the least).
nymus
DC Developer
DC Developer
Posts: 955
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has liked: 0
Been liked: 1 time

Re: KGL Clipping Issue

Post by nymus » Sat Jul 16, 2016 7:11 am

Indeed, tools that don't function as expected are definitely frustrating so it's nice that your issue was resolved. The great thing about asking/reporting is that now others will be able to troubleshoot and fix a similar problem.

Thanks to all.

Just a quick question, since opengl-es 1 was designed for immediate-mode GPUs, would using Khronos' reference implementation be a viable method of providing a complete and standard library?
behold the mind
inspired by Dreamcast
User avatar
bogglez
Moderator
Moderator
Posts: 576
Joined: Sun Apr 20, 2014 9:45 am
Has liked: 0
Been liked: 0

Re: KGL Clipping Issue

Post by bogglez » Sat Jul 16, 2016 11:56 am

Nymus, i think you mean fixed function pipeline gpus, not immediate mode. Immediate mode is not part of GL ES (glBegin etc).
Generally speaking GL ES 1 is a good match, but it misses stuff like drawing lines and quads, among other features I don't quite remember which are commonly used in existing software which was written for opengl 1.x. So kgl basically implements a subset of opengl 1.5 and just leaves out the stuff nobody uses anyway (so it's kind of a GL ES 1)
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
Post Reply