Only the lowest level of support
Yes, that code. If you can't understand it, given the documentation in the header file, I can't help you.
You could help by saying if having
called once should create a view that draws a text until the view is deallocated. If not, could you explain what should be done.
Code:
view = ConvenienceCreateNSTextView(
256,
256,
"Apple Chancery",
24.0f,
1,
"Hello");
TexImageNSView(GL_TEXTURE_2D, view);
The code doesn't just explain what should be done, it shows what should be done.
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.
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.
Thanks for answering with more than one line. I tried to adapt the example like this:
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?
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);
[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!
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!
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?
What are the advantages of persisting through problems and not using a 3rd party game engine?
GL_POLYGON isn't ever the answer to anything
One counterexample is needed to prove a theory false. My code is a counterexample.
You haven't posted any code including GL_POLYGON...
Here is the text-drawing code from the drawRect method:
Thanks for providing the NSViewTexture code.
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();
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.
QUADS will work fine instead of POLYGON there. So will TRIANGLE_FAN for that matter.
(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.
(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

