wined3d: Don't call glPointParameter with a random context.

This commit is contained in:
Matteo Bruni 2011-01-07 01:16:18 +01:00 committed by Alexandre Julliard
parent 0a9738775c
commit ef0f358813
4 changed files with 39 additions and 37 deletions

View File

@ -1575,23 +1575,6 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
}
if (gl_info->supported[WINED3D_GL_VERSION_2_0])
{
/* Windows doesn't support to query the glPointParameteri function pointer, so use the
* NV_POINT_SPRITE extension.
*/
if (glPointParameteri)
{
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT);
checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT)");
}
else if (gl_info->supported[NV_POINT_SPRITE])
{
GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT));
checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT)");
}
}
if (gl_info->supported[ARB_PROVOKING_VERTEX])
{
GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION));
@ -2019,27 +2002,9 @@ void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
static inline void context_set_render_offscreen(struct wined3d_context *context, const struct StateEntry *StateTable,
BOOL offscreen)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
if (context->render_offscreen == offscreen) return;
if (gl_info->supported[WINED3D_GL_VERSION_2_0])
{
/* Windows doesn't support to query the glPointParameteri function pointer, so use the
* NV_POINT_SPRITE extension.
*/
if (glPointParameteri)
{
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT);
checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
}
else if (gl_info->supported[NV_POINT_SPRITE])
{
GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT));
checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
}
}
Context_MarkStateDirty(context, STATE_POINTSPRITECOORDORIGIN, StateTable);
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
Context_MarkStateDirty(context, STATE_VDECL, StateTable);
Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);

View File

@ -4963,6 +4963,34 @@ static void frontface(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
}
}
static void psorigin_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
static BOOL warned;
if (!warned)
{
WARN("Point sprite coordinate origin switching not supported.\n");
warned = TRUE;
}
}
static void psorigin(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
GLint origin = context->render_offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT;
if (glPointParameteri)
{
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, origin);
checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
}
else if (gl_info->supported[NV_POINT_SPRITE])
{
GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, origin));
checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
}
}
const struct StateEntryTemplate misc_state_template[] = {
{ STATE_RENDER(WINED3DRS_SRCBLEND), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_DESTBLEND), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE },
@ -4978,6 +5006,9 @@ const struct StateEntryTemplate misc_state_template[] = {
{ STATE_VDECL, { STATE_VDECL, streamsrc }, WINED3D_GL_EXT_NONE },
{ STATE_FRONTFACE, { STATE_FRONTFACE, frontface }, WINED3D_GL_EXT_NONE },
{ STATE_SCISSORRECT, { STATE_SCISSORRECT, scissorrect }, WINED3D_GL_EXT_NONE },
{ STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin }, WINED3D_GL_VERSION_2_0 },
{ STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin_w }, WINED3D_GL_EXT_NONE },
/* TODO: Move shader constant loading to vertex and fragment pipeline repectively, as soon as the pshader and
* vshader loadings are untied from each other
*/
@ -5810,6 +5841,7 @@ static void validate_state_table(struct StateEntry *state_table)
STATE_VIEWPORT,
STATE_SCISSORRECT,
STATE_FRONTFACE,
STATE_POINTSPRITECOORDORIGIN,
};
unsigned int i, current;

View File

@ -2212,6 +2212,8 @@ const char *debug_d3dstate(DWORD state)
return "STATE_MATERIAL";
if (STATE_IS_FRONTFACE(state))
return "STATE_FRONTFACE";
if (STATE_IS_POINTSPRITECOORDORIGIN(state))
return "STATE_POINTSPRITECOORDORIGIN";
return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state);
}

View File

@ -992,7 +992,10 @@ extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC
#define STATE_FRONTFACE (STATE_MATERIAL + 1)
#define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE)
#define STATE_HIGHEST (STATE_FRONTFACE)
#define STATE_POINTSPRITECOORDORIGIN (STATE_FRONTFACE + 1)
#define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
#define STATE_HIGHEST (STATE_POINTSPRITECOORDORIGIN)
enum fogsource {
FOGSOURCE_FFP,