Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
--HG--
branch : trunk
  • Loading branch information
icculus committed Apr 28, 2008
1 parent 85967d9 commit 18940b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions finderrors.c
Expand Up @@ -114,10 +114,10 @@ int main(int argc, char **argv)
SDL_GL_LoadLibrary(NULL);
SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
MOJOSHADER_glContext *ctx;
ctx = MOJOSHADER_glInit(profile, SDL_GL_GetProcAddress, 0, 0, 0);
ctx = MOJOSHADER_glCreateContext(profile, SDL_GL_GetProcAddress, 0, 0, 0);
if (ctx == NULL)
{
printf("MOJOSHADER_glInit() fail: %s\n", MOJOSHADER_glGetError());
printf("MOJOSHADER_glCreateContext() fail: %s\n", MOJOSHADER_glGetError());
SDL_Quit();
return 1;
} // if
Expand All @@ -130,7 +130,7 @@ int main(int argc, char **argv)
printf("Saw %d bytecode files.\n", total);

#if FINDERRORS_COMPILE_SHADERS
MOJOSHADER_glDeinit(ctx);
MOJOSHADER_glDestroyContext(ctx);
SDL_Quit();
#endif
} // else
Expand Down
23 changes: 11 additions & 12 deletions mojoshader.h
Expand Up @@ -359,8 +359,8 @@ typedef struct MOJOSHADER_glProgram MOJOSHADER_glProgram;
* You must call this once AFTER you have successfully built your GL context
* and made it current. This function will lookup the GL functions it needs
* through the callback you supply, after which it may call them at any time
* up until you call MOJOSHADER_glDeinit(). The lookup function is neither
* stored nor used by MojoShader after this function returns.
* up until you call MOJOSHADER_glDestroyContext(). The lookup function is
* neither stored nor used by MojoShader after this function returns.
*
* (profile) is an OpenGL-specific MojoShader profile, which decides how
* Direct3D bytecode shaders get turned into OpenGL programs, and how they
Expand All @@ -385,14 +385,15 @@ typedef struct MOJOSHADER_glProgram MOJOSHADER_glProgram;
* are not thread safe, you should probably only call this from the same
* thread that created the GL context.
*/
MOJOSHADER_glContext *MOJOSHADER_glInit(const char *profile,
MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *profile,
void *(*lookup)(const char *fnname),
MOJOSHADER_malloc m, MOJOSHADER_free f,
void *d);

/*
* You must call this before using the context that you got from
* MOJOSHADER_glInit(), and must use it when you switch to a new GL context.
* MOJOSHADER_glCreateContext(), and must use it when you switch to a new GL
* context.
*
* You can only have one MOJOSHADER_glContext per actual GL context, or
* undefined behaviour will result.
Expand All @@ -419,15 +420,13 @@ void MOJOSHADER_glMakeContextCurrent(MOJOSHADER_glContext *ctx);
* buffer. Do not keep the pointer around, either, as it's likely to become
* invalid as soon as you call into MojoShader again.
*
* This is safe to call even if MOJOSHADER_glInit() failed.
*
* This call is NOT thread safe! As most OpenGL implementations are not thread
* safe, you should probably only call this from the same thread that created
* the GL context.
*
* This call does NOT require a valid MOJOSHADER_glContext to have been made
* current. The error buffer is shared between contexts, so you can get
* error results from a failed MOJOSHADER_glInit().
* error results from a failed MOJOSHADER_glCreateContext().
*/
const char *MOJOSHADER_glGetError(void);

Expand Down Expand Up @@ -699,10 +698,10 @@ void MOJOSHADER_glDeleteShader(MOJOSHADER_glShader *shader);
/*
* Deinitialize MojoShader's OpenGL shader management.
*
* You must call this once, while your GL context is still current, if you
* previously had a successful call to MOJOSHADER_glInit(). This should
* be the last MOJOSHADER_gl* function you call until you've initialized
* again.
* You must call this once, while your GL context (not MojoShader context) is
* still current, if you previously had a successful call to
* MOJOSHADER_glCreateContext(). This should be the last MOJOSHADER_gl*
* function you call until you've prepared a context again.
*
* This will clean up resources previously allocated, and may call into the GL.
*
Expand All @@ -718,7 +717,7 @@ void MOJOSHADER_glDeleteShader(MOJOSHADER_glShader *shader);
* are not thread safe, you should probably only call this from the same
* thread that created the GL context.
*/
void MOJOSHADER_glDeinit(MOJOSHADER_glContext *ctx);
void MOJOSHADER_glDestroyContext(MOJOSHADER_glContext *ctx);

#ifdef __cplusplus
}
Expand Down
8 changes: 4 additions & 4 deletions mojoshader_opengl.c
Expand Up @@ -297,7 +297,7 @@ static int check_extensions(void *(*lookup)(const char *fnname))
} // check_extensions


MOJOSHADER_glContext *MOJOSHADER_glInit(const char *_profile,
MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *_profile,
void *(*lookup)(const char *fnname),
MOJOSHADER_malloc m, MOJOSHADER_free f,
void *d)
Expand Down Expand Up @@ -343,7 +343,7 @@ MOJOSHADER_glContext *MOJOSHADER_glInit(const char *_profile,
f(ctx, d);
ctx = current_ctx;
return NULL;
} // MOJOSHADER_glInit
} // MOJOSHADER_glCreateContext


void MOJOSHADER_glMakeContextCurrent(MOJOSHADER_glContext *_ctx)
Expand Down Expand Up @@ -820,15 +820,15 @@ void MOJOSHADER_glDeleteShader(MOJOSHADER_glShader *shader)
} // MOJOSHADER_glDeleteShader


void MOJOSHADER_glDeinit(MOJOSHADER_glContext *_ctx)
void MOJOSHADER_glDestroyContext(MOJOSHADER_glContext *_ctx)
{
MOJOSHADER_glContext *current_ctx = ctx;
ctx = _ctx;
MOJOSHADER_glBindProgram(NULL);
lookup_entry_points(NULL);
Free(ctx);
ctx = ((current_ctx == _ctx) ? NULL : current_ctx);
} // MOJOSHADER_glDeinit
} // MOJOSHADER_glDestroyContext

// end of mojoshader_opengl.c ...

0 comments on commit 18940b8

Please sign in to comment.