Only the lowest level of support

Luminary
Posts: 5,143
Joined: 2002.04
Post: #16
Yes, that code. If you can't understand it, given the documentation in the header file, I can't help you.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #17
You could help by saying if having
Code:
            view = ConvenienceCreateNSTextView(
                                               256,
                                               256,
                                               "Apple Chancery",
                                               24.0f,
                                               1,
                                               "Hello");
            TexImageNSView(GL_TEXTURE_2D, view);
called once should create a view that draws a text until the view is deallocated. If not, could you explain what should be done.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #18
The code doesn't just explain what should be done, it shows what should be done.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #19
I don't think Miglu understands the basic theory behind how it works.

The Cocoa view is used to render text normally, like you would in a Mac app, but not on-screen. Once it has been rendered, a copy of the image of that rendered text is then uploaded to OpenGL as a texture. Both the view and the texture stay around until you release/delete them. Does this make more sense?

Rendering the text takes a little time, so you'll want to avoid changing it too often. Once it has been uploaded as a texture though, until it is changed again, it is drawn really fast by the GL.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #20
Thanks for answering with more than one line. I tried to adapt the example like this:
Code:
//This is called once
        view = ConvenienceCreateNSTextView(
                                               10,
                                               10,
                                               "Apple Chancery",
                                               24.0f,
                                               1,
                                               "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
            glBindTexture(GL_TEXTURE_2D, texture);
            glEnable(GL_TEXTURE_2D);
The text is not drawn. Also, this prevents drawing anything else to the view, so that only the background can be seen. What is the problem?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #21
The problem is that you don't understand C or OpenGL. You'll find programming OpenGL in C difficult given that.

Start at the Beginning.

You achieve nothing but wasting others' time and engendering ill-will by repeatedly asking trivial questions that you can't hope to understand the answers to.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #22
[chuckle] that's OneSadCookie's way of encouraging you to "try harder, grasshopper".

Miglu, honestly, I sympathize with you, because this isn't easy stuff to learn (really, it isn't). That said, you're going to have to "step it up" to move forward past this point. This is also where 99% of the class suddenly realizes how amazing a 3rd party game engine is... and that's a rational decision!
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #23
I got it to work. The parameter to glBegin to should be GL_POLYGON instead of GL_QUADS like in the example, and the polygon mode should be GL_FILL.
What are the advantages of persisting through problems and not using a 3rd party game engine?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #24
GL_POLYGON isn't ever the answer to anything Rasp
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #25
One counterexample is needed to prove a theory false. My code is a counterexample.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #26
You haven't posted any code including GL_POLYGON...
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #27
Here is the text-drawing code from the drawRect method:
Code:
            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();
Thanks for providing the NSViewTexture code.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #28
You don't need to set PolygonMode to FILL if you haven't changed it elsewhere (and if you did change it elsewhere, I'd consider setting it back when you're done in the other place, rather than leaving it set to something weird so you confuse yourself).

QUADS will work fine instead of POLYGON there. So will TRIANGLE_FAN for that matter.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #29
(Oct 16, 2010 02:57 PM)Miglu Wrote:  What are the advantages of persisting through problems and not using a 3rd party game engine?

Not many:
- you get to learn a whole bunch of stuff, if you're into learning stuff
- you have flexibility to explore different things, which may be outside the support range of a 3rd party solution. I am currently exploring time manipulation, which I doubt I would be able to do with a 3rd party engine.
- if there's a bug, you don't have to wait for them to fix it (of course, the converse is that you have to fix it yourself)
- you can potentially port your code over to whatever platform you please
- you could potentially license your own engine

I would say that pretty much, those of us who still do things from scratch are doing so because we started doing this back when there weren't any 3rd party solutions, at least not on the Mac, and at least not very good ones. A lot (most?) of the other folks who also started when we did have long since migrated to Unity3D. If it weren't for my 2D requirements, I probably would have do that too already.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #30
(Oct 16, 2010 05:40 PM)AnotherJake Wrote:  A lot (most?) of the other folks who also started when we did have long since migrated to Unity3D. If it weren't for my 2D requirements, I probably would have do that too already.

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.

Thus I use cocos2d for now. Doesn't mean I don't get nitty gritty, but to be blunt:
fuck writing engines from scratch Annoyed
Quote this message in a reply
Post Reply