<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Schrift ins OpenGL fenster, ohne Listen, geht das?]]></title><description><![CDATA[<p>hi leute hab mal ne frage bekomm ich ganz einfachen text ohne listen in eine OpenGL anwendung? wenn ja wie?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/160637/schrift-ins-opengl-fenster-ohne-listen-geht-das</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 19:24:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/160637.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 Sep 2006 19:22:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schrift ins OpenGL fenster, ohne Listen, geht das? on Wed, 27 Sep 2006 19:22:14 GMT]]></title><description><![CDATA[<p>hi leute hab mal ne frage bekomm ich ganz einfachen text ohne listen in eine OpenGL anwendung? wenn ja wie?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1145671</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1145671</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Wed, 27 Sep 2006 19:22:14 GMT</pubDate></item><item><title><![CDATA[Reply to Schrift ins OpenGL fenster, ohne Listen, geht das? on Wed, 27 Sep 2006 19:36:29 GMT]]></title><description><![CDATA[<p>du kannst alternativ eine Textur benuzten auf der alle Zeichen abgebildet sind:</p>
<pre><code class="language-cpp">#ifndef Vertexwahn_Util_Font_h
#define Vertexwahn_Util_Font_h

#include &lt;windows.h&gt;
#include &lt;cstdio&gt;
#include &lt;gl/gl.h&gt;
#include &lt;iostream&gt;
using namespace std;

namespace Vertexwahn
{
    namespace Util
    {
		class Texture
		{
		public:
			Texture();
			Texture(char * filename);
			void load(char * filename);
			void bind();
		private:

			Texture(const Texture&amp; src) 
			{
				cout&lt;&lt;&quot;texture copy&quot;&lt;&lt;endl;
			}

			friend bool LoadTGA(Texture *texture, char *filename);

			GLubyte	*imageData;							// Image Data (Up To 32 Bits)
			GLuint	bpp;								// Image Color Depth In Bits Per Pixel.
			GLuint	width;								// Image Width
			GLuint	height;								// Image Height
			GLuint	texID;								// Texture ID Used To Select A Texture
		};

		bool LoadTGA(Texture *texture, char *filename);

        class Font
        {
        public:

			Font(char *filename);
			void load(char *file);

			void drawChar(char c, int tx);

			void drawText(char * Text);

		private:
			Texture fontTexture;
        };
    }
}

#endif
</code></pre>
<pre><code class="language-cpp">#include &quot;Font.h&quot;

//#include &quot;..\..\..\Vertexwahn\Imaging\DevIL\include\IL\il.h&quot;
//#include &quot;..\..\..\Vertexwahn\Imaging\DevIL\include\IL\ilu.h&quot;
//#include &quot;..\..\..\Vertexwahn\Imaging\DevIL\include\IL\ilut.h&quot;

namespace Vertexwahn
{
	namespace Util
	{

			Texture::Texture()
			{
			}
			Texture::Texture(char * filename)
			{
				//LoadTGA(this, filename);
			}

			void Texture::load(char * filename)
			{
				//ilInit();
				//iluInit();
				 //ilutRenderer(ILUT_OPENGL);

				 //this-&gt;texID = ilutGLLoadImage(filename);

				LoadTGA(this, filename);
			}
			void Texture::bind()
			{
				glBindTexture(GL_TEXTURE_2D, this-&gt;texID);
			}

		bool LoadTGA(Texture *texture, char *filename)				// Loads A TGA File Into Memory
		{    
			GLubyte		TGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0};		// Uncompressed TGA Header
			GLubyte		TGAcompare[12];						// Used To Compare TGA Header
			GLubyte		header[6];						// First 6 Useful Bytes From The Header
			GLuint		bytesPerPixel;						// Holds Number Of Bytes Per Pixel Used In The TGA File
			GLuint		imageSize;						// Used To Store The Image Size When Setting Aside Ram
			GLuint		temp;							// Temporary Variable
			GLuint		type=GL_RGBA;						// Set The Default GL Mode To RBGA (32 BPP)

			FILE *file = fopen(filename, &quot;rb&quot;);					// Open The TGA File

			if(	file==NULL ||							// Does File Even Exist?
				fread(TGAcompare,1,sizeof(TGAcompare),file)!=sizeof(TGAcompare) ||	// Are There 12 Bytes To Read?
				memcmp(TGAheader,TGAcompare,sizeof(TGAheader))!=0 ||		// Does The Header Match What We Want?
				fread(header,1,sizeof(header),file)!=sizeof(header))		// If So Read Next 6 Header Bytes
			{
				if (file == NULL)						// Does The File Even Exist? *Added Jim Strong*
					return FALSE;						// Return False
				else								// Otherwise
				{
					fclose(file);						// If Anything Failed, Close The File
					return FALSE;						// Return False
				}
			}

			texture-&gt;width  = header[1] * 256 + header[0];				// Determine The TGA Width	(highbyte*256+lowbyte)
			texture-&gt;height = header[3] * 256 + header[2];				// Determine The TGA Height	(highbyte*256+lowbyte)

 			if(	texture-&gt;width	&lt;=0 ||						// Is The Width Less Than Or Equal To Zero
				texture-&gt;height	&lt;=0 ||						// Is The Height Less Than Or Equal To Zero
				(header[4]!=24 &amp;&amp; header[4]!=32))				// Is The TGA 24 or 32 Bit?
			{
				fclose(file);							// If Anything Failed, Close The File
				return FALSE;							// Return False
			}

			texture-&gt;bpp	= header[4];						// Grab The TGA's Bits Per Pixel (24 or 32)
			bytesPerPixel	= texture-&gt;bpp/8;					// Divide By 8 To Get The Bytes Per Pixel
			imageSize		= texture-&gt;width*texture-&gt;height*bytesPerPixel;	// Calculate The Memory Required For The TGA Data

			texture-&gt;imageData=(GLubyte *)malloc(imageSize);			// Reserve Memory To Hold The TGA Data

			if(	texture-&gt;imageData==NULL ||					// Does The Storage Memory Exist?
				fread(texture-&gt;imageData, 1, imageSize, file)!=imageSize)	// Does The Image Size Match The Memory Reserved?
			{
				if(texture-&gt;imageData!=NULL)					// Was Image Data Loaded
					free(texture-&gt;imageData);				// If So, Release The Image Data

				fclose(file);							// Close The File
				return FALSE;							// Return False
			}

			for(GLuint i=0; i&lt;int(imageSize); i+=bytesPerPixel)			// Loop Through The Image Data
			{									// Swaps The 1st And 3rd Bytes ('R'ed and 'B'lue)
				temp=texture-&gt;imageData[i];					// Temporarily Store The Value At Image Data 'i'
				texture-&gt;imageData[i] = texture-&gt;imageData[i + 2];		// Set The 1st Byte To The Value Of The 3rd Byte
				texture-&gt;imageData[i + 2] = temp;				// Set The 3rd Byte To The Value In 'temp' (1st Byte Value)
			}

			fclose (file);								// Close The File

			// Build A Texture From The Data
			glGenTextures(1, &amp;texture[0].texID);					// Generate OpenGL texture IDs

			glBindTexture(GL_TEXTURE_2D, texture[0].texID);				// Bind Our Texture
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);	// Linear Filtered
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	// Linear Filtered

			if (texture[0].bpp==24)							// Was The TGA 24 Bits
			{
				type=GL_RGB;							// If So Set The 'type' To GL_RGB
			}

			glTexImage2D(GL_TEXTURE_2D, 0, type, texture[0].width, texture[0].height, 0, type, GL_UNSIGNED_BYTE, texture[0].imageData);

			return true;								// Texture Building Went Ok, Return True
		}

			Font::Font(char *filename) : fontTexture(filename)
			{

			}

			void Font::load(char *file)
			{
				fontTexture.load(file);
			}

			void Font::drawChar(char c, int tx)
			{
				float x = 1*(16.0f/256.0f);
				float y = 2*(16.0f/256.0f);

				// A = 65

				// Jetzt A = 33
				y = 15-(c-32)/16;
				x = (c-32)%16;
				y *= (16.0f/256.0f);
				x *= (16.0f/256.0f);

				glBegin(GL_QUADS);					// Use A Quad For Each Character
					glTexCoord2f(x,            y);				    glVertex2f(tx+0, 0);
					glTexCoord2f(x, y+16.0f/256.0f);				glVertex2f(tx+0, 16);
					glTexCoord2f(x+16.0f/256.0f, y+16.0f/256.0f);	glVertex2f(tx+16, 16);
					glTexCoord2f(x+16.0f/256.0f, y);				glVertex2f(tx+16, 0);
				glEnd();						// Done Building Our Quad (Character)

			}

			void Font::drawText(char * Text)
			{

				fontTexture.bind();

				glMatrixMode(GL_PROJECTION);					// Select The Projection Matrix
				glPushMatrix();									// Store The Projection Matrix
				glLoadIdentity();								// Reset The Projection Matrix
				glOrtho(0,640,0,480,-1,1);	// Set Up An Ortho Screen

				glMatrixMode(GL_MODELVIEW);						// Select The Modelview Matrix
				glPushMatrix();									// Model View Matrix retten
				glLoadIdentity();

				// Z-Buffer aus
				glEnable(GL_BLEND);		// Turn Blending On
				glDisable(GL_DEPTH_TEST);
				// draw...

				//int loop = 65;
				//float cx=float(loop%16)/256.0f;					// X Position Of Current Character
				//float cy=float(loop/16)/256.0f;					// Y Position Of Current Character

				for(int i = 0; Text[i] != 0; i++)
					drawChar(Text[i],16*i);

				glDisable(GL_BLEND);		// Turn Blending On
				glEnable(GL_DEPTH_TEST); // Z-Buffer wieder an

				glPopMatrix();									// Modleview Matrix wiederherstellen
				glMatrixMode(GL_PROJECTION);					// Select The Projection Matrix
				glPopMatrix();									// Projektionsmatrix wiederherstellen
				glMatrixMode(GL_MODELVIEW);						// Wieder Modelviewmatrix einstellen

			}

	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1145680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1145680</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Wed, 27 Sep 2006 19:36:29 GMT</pubDate></item><item><title><![CDATA[Reply to Schrift ins OpenGL fenster, ohne Listen, geht das? on Thu, 28 Sep 2006 18:36:37 GMT]]></title><description><![CDATA[<p>ahja ok und einfacher gehts net oder was?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1146119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1146119</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Thu, 28 Sep 2006 18:36:37 GMT</pubDate></item><item><title><![CDATA[Reply to Schrift ins OpenGL fenster, ohne Listen, geht das? on Sun, 01 Oct 2006 12:05:38 GMT]]></title><description><![CDATA[<p>was verstehst du nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1147361</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1147361</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sun, 01 Oct 2006 12:05:38 GMT</pubDate></item><item><title><![CDATA[Reply to Schrift ins OpenGL fenster, ohne Listen, geht das? on Sun, 01 Oct 2006 13:56:19 GMT]]></title><description><![CDATA[<p>Boah ist das grauenvoller Code! Net mal TGA wird anständig geladen! using namespace in einem Header?! OMFG!</p>
<p>Aber acuh noch GL_QUADS! Jung, das ist doch so dermaßen lam. Benutz doch bitte VBOs wenn du schon so viel falsch machst.</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1147403</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1147403</guid><dc:creator><![CDATA[OpenGLler]]></dc:creator><pubDate>Sun, 01 Oct 2006 13:56:19 GMT</pubDate></item><item><title><![CDATA[Reply to Schrift ins OpenGL fenster, ohne Listen, geht das? on Mon, 02 Oct 2006 12:24:52 GMT]]></title><description><![CDATA[<blockquote>
<p>Net mal TGA wird anständig geladen!</p>
</blockquote>
<p>wo siehst du da einen Fehler?</p>
<blockquote>
<p>using namespace in einem Header?!</p>
</blockquote>
<p>aso du meinst</p>
<pre><code class="language-cpp">using namespace std;
</code></pre>
<p>ja - das ist wirklich nicht schön</p>
<blockquote>
<p>Aber acuh noch GL_QUADS! Jung, das ist doch so dermaßen lam. Benutz doch bitte VBOs wenn du schon so viel falsch machst.</p>
</blockquote>
<p>mir ist schon klar das VBOs schneller sind - bin aber erstmal damit zufrieden, das es überhaupt funktioniert</p>
<blockquote>
<p>Boah ist das grauenvoller Code!</p>
</blockquote>
<p>was soll ich noch anders machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1147950</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1147950</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Mon, 02 Oct 2006 12:24:52 GMT</pubDate></item></channel></rss>