The most difficut problem in OPENGL! (Try it)

Hi, I’m not an experienced programmer in OpenGL or even in the language, but couldn’t you just clip the triangle and continue on the othere side of the screen but with the values mirrored?

This question doesn’t seem that easy to solve to me, it’s obvious that rendering two triangle is a solution, but it isn’t a generic solution, and even duplicating all the geometry isn’t a good solution.

The point is this isn’t really a 3d question (and must not be solved with 3d math), this behaviour is typical of software rendering, where exceeding the screen size doesn’t mean exceeding the linear frame buffer, and the result is to see the SAME triangle showing on the other side of the screen, one pixel lower.
The ONLY way (IMHO) to simulate this behaviour of software rendering is to use a render to texture method.
And please, it isn’t absolutely a dumb question, the idea to use two triangle is the worse way to solve this problem.

rIO.sK

Why is using two triangles “the worst way to solve this problem”? It seems simple and elegant to me, especially compared to the complexity of rendering to texture. Just render two triangles spaced screenwidth units apart, translate gradually along x and when you’ve translated screenwidth units reset the scene. Continue ad infinitum. Or if you really want to see the pixels of a single triangle rendered, use a triangle texture and scroll that with a texture wrap mode of GL_REPEAT.

Because with using the “two triangle method” u solve just this exact situation, that IMHO (maybe I’m wrong) it’s just a sample of what the method needs to do.
Using the double geometry to solve a GENERIC “screen wrap” (?) it’s obviously wrong.
I just interpreted the triangle question as an example, “How can we render a geometry that can wrap against screen borders ? Let’s use a single triangle as an example.”

Of course if the question was related ONLY to a single triangle implementing a render to texture is wrong, but I hope the professor just used the triangle as a sample.
Otherwise excuse me for the previous post, and freely say to the prof he is a dumb!

rIO.sK

render in a bigger viewport then copy the buffer by hand to the result to screen :slight_smile:

(btw, I dont know what the result would be when you render in a viewport bigger than screen)

I think he made fun of you and/or needed the code for himself.

Rio, if it is a 3D question then yes it is more difficult, but it is described about as badly as can be imagined in that case. The solution for the 3D problem (with a rotating triangle around the viewer) has also been posted.

I learned years ago not to accept challenges like this from someone with control over your grade. I accepted a similar challenge when I was caught goofing off after finishing my assignment, the prof said, “do the last assigment in the book to prove you are that fast, that should keep you busy for a WEEK.” I told him I’d have it on his desk the next day, he laughed. I had it on his desk by the end of the day (worked through another class shhhhhhhhhhh), because he laughed at me. Turned out he got his job as instructer because he solved it in 2 full days work, about 24 man hours… I did it in 6 man hours and had to walk carefully for the next 10 weeks till end of class…

Dorbie has the correct solution, though difficult to code. I could probably code up a hack that emulates cylindrical projection only, my mind hurts if I think spherical.

And dorbie is correct, almost any “feature” is an emulation. After all, are you really moving that texel in physical computer space? what is physical computer space and how did I fit inside both my tower system and my laptop? (ahhhh compression!! that is why my laptop is slower!!).

seriously though, most techniques are emulations, bump mapping doesn’t “add” detail, it simulates detail, etc. Until we synthesize physical geometry from a computer program, it is all just pretty pictures, and if one implementation looks the same as the other, why is one wrong? I saw nowhere in the description that it demanded a spherical display buffer.

Though if I solved it, just to be annoying; I would probably render to a buffer larger than the screen area and wrap the overlapping portions of the buffer around the screen area. If the overlap area is the size of half the triangle’s size no one would know. X movement would be based on a simulation of radial movement around a cylinder, at 359.0 it is mostly on the left side, part on the right; at 1.0 degrees it is mostly on the right partially on the left, doesn’t matter which side of the buffer writes to the other with only one object, it masks easily.

you’ve emulated it based on changing your xy mapping, not on changing your view. This was the same way I wrote the old 2D sprite games. (egad!! I just admitted my age) Buffer the edges equal to half the size of your sprites, write your buffers back across the edge of the screen on each side. Your only error is when there are more than one object at the edges and you have to deal with which object is in front of the other.

The screen drawing is done by drawing the buffer to the screen not the geometry, either texture or draw pixels style (he didn’t say it had to be optimized).

Just me…

[This message has been edited by Jeffry J Brickley (edited 06-19-2002).]

Yeah, riO I agree, it isn’t a general solution. But the more experience I get with programming, the more I value pragamtical solutions. From the Tao of programming 5.3:

[i]A novice programmer was once assigned to code a simple financial package.

The novice worked furiously for many days, but when his Master reviewed his program, he discovered it contained a screen editor, a set of generalized graphics routines, and an
artificial intelligence interface, but not the slightest hint of anything financial.

When the Master asked about this, the novice became indignant.

“Don’t be so impatient,” he said, “I’ll put in the financial stuff eventually.”[/i]

Anyway I never thought I’de get to view patents filed by Angus on spherical projection from reading a thread with a homework question. The good stuff that comes from this forum never ceases to amaze me.

Hey, Jeffry –
I’m wondering what the problem was you showed your professor up on…?

the problem? boring stuff, acounting software was where I started in '85. I don’t recall the exact problem, I remember it involved multiple ledgers, reconciliations and some other stuff, for fun I added an investment predictor with some minor fuzzy logic. Really it was not that complicated design wise, just time consuming coding wise in Cobol or RPG II. I had already coded a 3.5GL pre-processor by 2/3 of the class (yup I am the perfect model for the example a few posts up). It really wasn’t quite a 4GL but it meant I coded in a fraction of the time, that way I could goof off more or write games when no one was looking. Even wrote a full Visicalc compatable spreadsheet with RPG-II, which of course means I really do have brain damage.

Or the long and short of it. I had already changed the rules of the game, he still thought I was hand coding.

Sweet! … I love coding things professors say are impossible to do in such and such amount of time… heh.

JML,

Hey, that’s a good one.

Throw up a large quad plane, and texture it with triangle.

Then animate the texture by scrolling the texture coordinates across.

I do like JML’s solution best too. And since I regularly texture in 2Kx2K textures, I know it would work faster than mine. Depends on how tough the professor is about “drawing” the triangle… It’s the perfect cheat, you draw it once and texture it rapidly ever after. Knowing some of my professors, I probably would have done it my way if only because I am actually “drawing” it every frame; I always respect the letter of the law. Mine would probably be a 10th in frame rate from JML’s. His method should easily pull 200fps on this machine I am on and that is assuming a 1Kx1K texture at 1024x768 rendering, it would still be lightning fast at 2Kx2K for rendering above 1024x768 mode on a Geforce3 or better.

Hello,

the problem is ill-posed. Drawing more than one of anything is a hack/emulation of the problem (and it won’t give the correct answer, anyway).

I belive the original problem isn’t “make the triangle appear on the other side of the screen”, but rather, make a spherical projection.

c.f. http://www.cs.adelaide.edu.au/~john/proj.jpg

on the left is ‘normal’ projection. the proejction of a 3D point is the interesection of the vector through the point p1 and the optical centre of the camera c with the view-plane, v. There will always be such a point, provided c \E v. Since monitors/cameras/eyes are not infinitely large, then only points that project within a bounding rectangle are viewable. This is ‘standard’, planar projection.

The trick is to create a cylindrical or spherical projection. It’s the same idea, but this time the view plane is actually a cylinder (or sphere). In this case, the projection of a point will generate TWO potential values on the view-cylinder; depending on what you want to do wtih the system, you might want to axe the value further away from the original point (p1’ and p2’ for p1 and p2, respectively). ALl that is required now is to construct a cylindrical to planar mapping to display on the montior, ie. a function that maps 0–2pi to 0–resolution. ALl of this can be mathematically expressed and is thus not impossible.

in conclusion;

  • the problem is ill-posed
  • drawing more than one copy of the geometry is a suitable answer for how the question was expressed (but I belive the original question was actually more complicated than described)
  • it isn’t difficult or mathematically impossible!

cheers,
John