<?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[sepperate extern &amp;quot;c&amp;quot; funktionen per Objekt]]></title><description><![CDATA[<p>Ich habe eine auf SDL2 aufbauende Lib gebastelt die alle OpenGL Funktionen läd. (alle mir bekannten libs wie GLEW sind zu verbugt und SDL2 eigene Implementierung ist nicht vollständig)</p>
<p>So schaut es bisher aus und funktioniert wunderbar (leicht gekürzt da es über 2800 Funktionen sind):</p>
<pre><code>#ifndef GLFUNCTIONS_HPP
#define GLFUNCTIONS_HPP
//#include &quot;glTypes.hpp&quot;
typedef int GLenum;
typedef float GLfloat;

typedef void  (*PFNGLACCUMPROC)(GLenum op, GLfloat value);

extern &quot;C&quot; PFNGLACCUMPROC glAccum;

void loadFunctionPointers();

#endif
</code></pre>
<pre><code>#include &quot;glFunctions.hpp&quot;
//#include &quot;SDL_video.h&quot;

PFNGLACCUMPROC glAccum;

void loadFunctionPointers()
{
    glAccum = reinterpret_cast&lt;PFNGLACCUMPROC&gt;(NULL/*SDL_GL_GetProcAddress(&quot;glAccum&quot;)*/);
}
</code></pre>
<p>Unter Windows kann nun jeder OpenGL Context sepperate Funktionszeiger haben. Und nun suche ich einen Weg wie ich die Funktionen schön in Objekte verpacken könnte.<br />
Man kann keine extern &quot;C&quot; in Klassen definieren, auch Funktionszeiger kann man nur statisch definieren. Und daher bin ich mir nicht sicher ob es überhaupt möglich ist.</p>
<p>In meine Wunschvorstellung sehe die zukünftige Benutzung dann folgendermaßen aus:</p>
<pre><code>glFunctionClass glf1, glf2;

void thread1
{
    createGlContext();
    glf1.loadFunctionPointers();
    glf1.glAccum(GL_ACCUM, 0.0f);
}
void thread2
{
    createGlContext();
    glf2.loadFunctionPointers();
    glf2.glAccum(GL_ACCUM, 0.0f);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/327410/sepperate-extern-quot-c-quot-funktionen-per-objekt</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 07:12:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/327410.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 Aug 2014 13:53:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sepperate extern &amp;quot;c&amp;quot; funktionen per Objekt on Sun, 10 Aug 2014 13:53:13 GMT]]></title><description><![CDATA[<p>Ich habe eine auf SDL2 aufbauende Lib gebastelt die alle OpenGL Funktionen läd. (alle mir bekannten libs wie GLEW sind zu verbugt und SDL2 eigene Implementierung ist nicht vollständig)</p>
<p>So schaut es bisher aus und funktioniert wunderbar (leicht gekürzt da es über 2800 Funktionen sind):</p>
<pre><code>#ifndef GLFUNCTIONS_HPP
#define GLFUNCTIONS_HPP
//#include &quot;glTypes.hpp&quot;
typedef int GLenum;
typedef float GLfloat;

typedef void  (*PFNGLACCUMPROC)(GLenum op, GLfloat value);

extern &quot;C&quot; PFNGLACCUMPROC glAccum;

void loadFunctionPointers();

#endif
</code></pre>
<pre><code>#include &quot;glFunctions.hpp&quot;
//#include &quot;SDL_video.h&quot;

PFNGLACCUMPROC glAccum;

void loadFunctionPointers()
{
    glAccum = reinterpret_cast&lt;PFNGLACCUMPROC&gt;(NULL/*SDL_GL_GetProcAddress(&quot;glAccum&quot;)*/);
}
</code></pre>
<p>Unter Windows kann nun jeder OpenGL Context sepperate Funktionszeiger haben. Und nun suche ich einen Weg wie ich die Funktionen schön in Objekte verpacken könnte.<br />
Man kann keine extern &quot;C&quot; in Klassen definieren, auch Funktionszeiger kann man nur statisch definieren. Und daher bin ich mir nicht sicher ob es überhaupt möglich ist.</p>
<p>In meine Wunschvorstellung sehe die zukünftige Benutzung dann folgendermaßen aus:</p>
<pre><code>glFunctionClass glf1, glf2;

void thread1
{
    createGlContext();
    glf1.loadFunctionPointers();
    glf1.glAccum(GL_ACCUM, 0.0f);
}
void thread2
{
    createGlContext();
    glf2.loadFunctionPointers();
    glf2.glAccum(GL_ACCUM, 0.0f);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2412822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2412822</guid><dc:creator><![CDATA[Osbios]]></dc:creator><pubDate>Sun, 10 Aug 2014 13:53:13 GMT</pubDate></item><item><title><![CDATA[Reply to sepperate extern &amp;quot;c&amp;quot; funktionen per Objekt on Sun, 10 Aug 2014 14:12:29 GMT]]></title><description><![CDATA[<p>Du hast keine extern &quot;C&quot; Funktionen, du hast einen extern &quot;C&quot; Funktionszeiger.<br />
Und Funktionszeiger kannste problemlos in Klassen packen.<br />
Alternativ kannste auch einfach die ganzen Funktionszeiger als thread_local markieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2412825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2412825</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 10 Aug 2014 14:12:29 GMT</pubDate></item><item><title><![CDATA[Reply to sepperate extern &amp;quot;c&amp;quot; funktionen per Objekt on Sun, 10 Aug 2014 14:34:33 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Du hast keine extern &quot;C&quot; Funktionen, du hast einen extern &quot;C&quot; Funktionszeiger.<br />
Und Funktionszeiger kannste problemlos in Klassen packen.</p>
</blockquote>
<p>Hört sich vielversprechend an.<br />
Folgender Code lässt sich leider nicht compilen:</p>
<pre><code>#ifndef GLFUNCTIONS_HPP
#define GLFUNCTIONS_HPP
//#include &quot;glTypes.hpp&quot;
typedef int GLenum;
typedef float GLfloat;

typedef void  (*PFNGLACCUMPROC)(GLenum op, GLfloat value);

class glFunctionClass
{
    void loadFunctionPointers();
    extern &quot;C&quot; PFNGLACCUMPROC glAccum;
};

#endif
</code></pre>
<pre><code>#include &quot;glFunctions.hpp&quot;
//#include &quot;SDL_video.h&quot;

PFNGLACCUMPROC glFunctionClass::glAccum;

void glFunctionClass::loadFunctionPointers()
{
    glAccum = reinterpret_cast&lt;PFNGLACCUMPROC&gt;(NULL/*SDL_GL_GetProcAddress(&quot;glAccum&quot;)*/);
}
</code></pre>
<pre><code>In file included from /home/osbios/dev/glBase/testIt/glFunctions.cpp:1:0:
/home/osbios/dev/glBase/testIt/glFunctions.hpp:12:12: error: expected unqualified-id before string constant
     extern &quot;C&quot; PFNGLACCUMPROC glAccum;
            ^
/home/osbios/dev/glBase/testIt/glFunctions.cpp:4:33: error: ‘void (* glFunctionClass::glAccum)(GLenum, GLfloat)’ is not a static member of ‘class glFunctionClass’
 PFNGLACCUMPROC glFunctionClass::glAccum;
                                 ^
/home/osbios/dev/glBase/testIt/glFunctions.cpp: In member function ‘void glFunctionClass::loadFunctionPointers()’:
/home/osbios/dev/glBase/testIt/glFunctions.cpp:8:5: error: ‘glAccum’ was not declared in this scope
     glAccum = reinterpret_cast&lt;PFNGLACCUMPROC&gt;(NULL/*SDL_GL_GetProcAddress(&quot;glAccum&quot;)*/);
     ^
/home/osbios/dev/glBase/testIt/glFunctions.cpp:8:48: error: ‘NULL’ was not declared in this scope
     glAccum = reinterpret_cast&lt;PFNGLACCUMPROC&gt;(NULL/*SDL_GL_GetProcAddress(&quot;glAccum&quot;)*/);
                                                ^
make[2]: *** [CMakeFiles/testIt.dir/glFunctions.cpp.o] Fehler 1
make[1]: *** [CMakeFiles/testIt.dir/all] Fehler 2
make: *** [all] Fehler 2
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2412828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2412828</guid><dc:creator><![CDATA[Osbios]]></dc:creator><pubDate>Sun, 10 Aug 2014 14:34:33 GMT</pubDate></item><item><title><![CDATA[Reply to sepperate extern &amp;quot;c&amp;quot; funktionen per Objekt on Sun, 10 Aug 2014 15:02:32 GMT]]></title><description><![CDATA[<pre><code>typedef int GLenum;
typedef float GLfloat;

extern &quot;C&quot; typedef void  ( *PFNGLACCUMPROC )( GLenum op, GLfloat value );

class glFunctionClass
{
    PFNGLACCUMPROC glAccum;

	public:
		void loadFunctionPointers();
};

void glFunctionClass::loadFunctionPointers()
{
    glAccum = reinterpret_cast&lt; PFNGLACCUMPROC &gt;( nullptr /* SDL_GL_GetProcAddress( &quot;glAccum&quot; ) */ );
}

int main()
{
	glFunctionClass gl;
	gl.loadFunctionPointers();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2412835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2412835</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 10 Aug 2014 15:02:32 GMT</pubDate></item><item><title><![CDATA[Reply to sepperate extern &amp;quot;c&amp;quot; funktionen per Objekt on Sun, 10 Aug 2014 16:25:48 GMT]]></title><description><![CDATA[<p>Funktioniert wunderbar! Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2412849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2412849</guid><dc:creator><![CDATA[Osbios]]></dc:creator><pubDate>Sun, 10 Aug 2014 16:25:48 GMT</pubDate></item></channel></rss>