Only the lowest level of support

Member
Posts: 131
Joined: 2010.08
Post: #31
(Oct 16, 2010 04:37 PM)OneSadCookie Wrote:  QUADS will work fine instead of POLYGON there. So will TRIANGLE_FAN for that matter.

QUADS and TRIANGLE_FAN can not be filled, so only the pixels in the text that are on their edges are drawn if I try them.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #32
(Oct 17, 2010 03:23 AM)Miglu Wrote:  QUADS and TRIANGLE_FAN can not be filled, so only the pixels in the text that are on their edges are drawn if I try them.

I'm quite curious to know how you came to this conclusion.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #33
(Oct 17, 2010 03:23 AM)Miglu Wrote:  QUADS and TRIANGLE_FAN can not be filled, so only the pixels in the text that are on their edges are drawn if I try them.

You ain't doing something right if they aren't filled.

Look, don't use GL_POLYGON, ever. In fact, you shouldn't even be using GL_QUADS since that's not available on iPhone, nor is immediate mode drawing (anything using glBegin/End). That means you should use GL_TRIANGLE_FAN or GL_TRIANGLE_STRIP with glDrawArrays or glDrawElements. But since that might be confusing to you right now, at the very least, use GL_QUADS or GL_TRIANGLE_FAN.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #34
Why should GL_POLYGON never be used?
(Oct 16, 2010 05:50 PM)skyhawk Wrote:  I migrated to Unity3D until I realized that making 3D stuff is harder than 2D stuff... and to not rely on an artist (for now) is sublime.
Is an artist necessary for making games with Unity3D? A person who can do 3D models should suffice.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #35
(Oct 17, 2010 08:19 AM)Miglu Wrote:  Why should GL_POLYGON never be used?

Because polygons have to be tessellated before they can be drawn because the hardware only knows how to draw triangles. In some hardware/API combos, apparently GL_POLYGON doesn't get hardware acceleration at all, for whatever reason.

Besides, there is no case where you can't use a triangle fan or strip or individual triangles instead of polygon. It just isn't ever necessary to use, and at worst can be bad for performance.

(Oct 17, 2010 08:19 AM)Miglu Wrote:  Is an artist necessary for making games with Unity3D? A person who can do 3D models should suffice.

Looks like you asked and answered your own question right there. A person who can do 3D models is considered an "artist".

[edit]"In some hardware/API combos, apparently GL_POLYGON doesn't get hardware acceleration at all, for whatever reason."

I could swear I read that somewhere, but I can't seem to find any examples of it, so disregard that statement. There are some older examples where some primitives don't work with VAR on older Macs with ATI cards in them, but that's stretching the definition of "acceleration" IMHO, and we don't care about VAR anymore anyway.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #36
I am again going to ask a question about drawing text. Please do not get angry. I read chapters 8 and 9 from the Red Book, but could not find an answer.
Code:
//This is called once
            view = ConvenienceCreateNSTextView(
                                               300.0f,
                                                300.0f,
                                               "Arial",
                                               100.0f,
                                               0,
                                               "Hello");
            glGenTextures(1, &texture);
            glBindTexture(GL_TEXTURE_2D, texture);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            TexImageNSView(GL_TEXTURE_2D, view);

//This is in the drawRect method
            glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
            glEnable(GL_BLEND);
            glEnable(GL_TEXTURE_2D);
            glBindTexture(GL_TEXTURE_2D, texture);
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            
            glBegin(GL_POLYGON);
            glTexCoord2f(0.0f, 1.0f);
            glVertex2f(-0.2f, -0.2f);
            glTexCoord2f(1.0f, 1.0f);
            glVertex2f( 0.2f, -0.2f);
            glTexCoord2f(1.0f, 0.0f);
            glVertex2f( 0.2f,  0.2f);
            glTexCoord2f(0.0f, 0.0f);
            glVertex2f(-0.2f,  0.2f);
            glEnd();
This stops anything else being drawn, so that only the text on the background color is drawn. However, if the third argument to glTexParameteri is anything else than GL_LINEAR, the other stuff is drawn, but using thick lines and no alias, and the text is not drawn. What is the problem?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #37
There isn't enough code there for us to know. I suppose I could speculate that maybe the other objects in your scene aren't textured but you left glEnable(GL_TEXTURE_2D); on?

Are your matrix push/pops balanced?

This is why it's hard to help those learning OpenGL since there are so many things that could be going wrong, and it only takes one little detail to screw everything up. It's up to *you* to make sure your state is what you expect it to be.

See the section on "How to Debug": http://www.idevgames.com/forums/thread-1927.html
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #38
glDisable(GL_TEXTURE_2D) works, but the other stuff is still drawn with no antialias, and GL_LINES are drawn thick. What is the problem?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #39
I don't know man, my eyes are really getting strained while staring this hard into my crystal ball. Rasp

What was your state before you drew the text? What parts of the state did you change?

You're talking about anti-aliasing, so I can only guess that maybe you set the glBlendFunc to something that doesn't work with line smoothing? You'll probably need to set it to GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA for line smoothing to work, if that is in fact what you're trying to do.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #40
Indeed. Thanks.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #41
(Oct 17, 2010 10:37 AM)AnotherJake Wrote:  I don't know man, my eyes are really getting strained while staring this hard into my crystal ball. Rasp

ummm, can I borrow this crystal ball for my own coding problems?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #42
Sure thing! Feel free to PM me with your shipping address, and I'll send it to you after I receive your check for ONE HUNDRED THOUSAND DOLLARS.
Quote this message in a reply
Post Reply