View previous topic :: View next topic |
Author |
Message |
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Mon Feb 05, 2007 3:15 am Post subject: Extensions with Schooner's GL |
|
|
How do I use an extension when using Schooner's GL?
In particular I'm trying to use glCompressedTexImage2DARB.
The gl.di file contains a function pointer typedef for it:
Code: |
typedef void(* PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid* data);
|
But I'm not sure how I'm supposed to access it. Do I need to use wgl functions to load the function pointer or something? In Derelict I can use
Code: |
ARBTextureCompression.load("GL_ARB_texture_compression");
|
Thanks for any info. |
|
Back to top |
|
|
Bradley Smith
Joined: 20 Jun 2006 Posts: 60
|
Posted: Mon Feb 05, 2007 10:47 am Post subject: |
|
|
Yes, you should be able to do something like the following, but I have not tested it.
Code: | PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB = cast(PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)
wglGetProcAddress( toStringz("glCompressedTexImage2DARB") );
glCompressedTexImage2DARB(target, level, internalformat, width, height, border, imageSize, data);
|
|
|
Back to top |
|
|
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Mon Feb 05, 2007 3:33 pm Post subject: |
|
|
Bradley Smith wrote: | Yes, you should be able to do something like the following, but I have not tested it.
Code: | PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB = cast(PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)
wglGetProcAddress( toStringz("glCompressedTexImage2DARB") );
glCompressedTexImage2DARB(target, level, internalformat, width, height, border, imageSize, data);
|
|
Ok. Thanks. I just didn't see any wgl functions in Schooner on first inspection, but maybe I wasn't looking in the right place.
I'll give it a try. |
|
Back to top |
|
|
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Fri Feb 16, 2007 8:59 pm Post subject: Got it working |
|
|
Got it working with the following version/import mojo:
Code: |
version (useDerelict) {
import derelict.opengl.extension.arb.texture_compression;
} else {
private
{
PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glCompressedTexImage3DARB;
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;
PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB;
PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glCompressedTexSubImage3DARB;
PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glCompressedTexSubImage2DARB;
PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glCompressedTexSubImage1DARB;
PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glGetCompressedTexImageARB;
version(Windows)
import win32.wingdi; // for wgl funcs
else version(linux)
version = UsingGLX;
version(UsingGLX)
import x11.glx;
import string=std.string;
bool glBindExtFunc(void **ptr, char[] funcName)
{
version(Windows)
*ptr = wglGetProcAddress(string.toStringz(funcName));
else version(UsingGLX)
*ptr = glXGetProcAddress(string.toStringz(funcName));
return (*ptr !is null);
}
}
}
void initialize_compressed_texture_extension()
{
version(useDerelict) {
if (!ARBTextureCompression.load("GL_ARB_texture_compression"))
throw new Exception("Unable to initialize texture compression extension");
}
else {
if(!glBindExtFunc(cast(void**)&glCompressedTexImage3DARB, "glCompressedTexImage3DARB"))
return false;
if(!glBindExtFunc(cast(void**)&glCompressedTexImage2DARB, "glCompressedTexImage2DARB"))
return false;
if(!glBindExtFunc(cast(void**)&glCompressedTexImage1DARB, "glCompressedTexImage1DARB"))
return false;
if(!glBindExtFunc(cast(void**)&glCompressedTexSubImage3DARB, "glCompressedTexSubImage3DARB"))
return false;
if(!glBindExtFunc(cast(void**)&glCompressedTexSubImage2DARB, "glCompressedTexSubImage2DARB"))
return false;
if(!glBindExtFunc(cast(void**)&glCompressedTexSubImage1DARB, "glCompressedTexSubImage1DARB"))
return false;
if(!glBindExtFunc(cast(void**)&glGetCompressedTexImageARB, "glGetCompressedTexImageARB"))
return false;
}
}
|
All the extra code for the non-derelict case basically just does exactly what derelict's ARBTextureCompression.load function does, but modified to use schooner's imports.
--bb |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|