immediate mode: using texture shader for stereo drawing
(for side-by-side and top-bottom stereo modes)
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
|
||||
#include "GPU_glew.h"
|
||||
#include "GPU_basic_shader.h"
|
||||
#include "GPU_immediate.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
@@ -203,23 +204,33 @@ static void wm_method_draw_stereo3d_sidebyside(wmWindow *win)
|
||||
halfy /= triple->y;
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned texcoord = add_attrib(format, "texcoord", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
unsigned pos = add_attrib(format, "position", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
glEnable(triple->target);
|
||||
immBindBuiltinProgram((triple->target == GL_TEXTURE_2D) ? GPU_SHADER_2D_TEXTURE_2D : GPU_SHADER_2D_TEXTURE_RECT);
|
||||
|
||||
glBindTexture(triple->target, triple->bind);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(halfx, halfy);
|
||||
glVertex2f(soffx, 0);
|
||||
immUniform1i("texture_map", 0);
|
||||
|
||||
glTexCoord2f(ratiox + halfx, halfy);
|
||||
glVertex2f(soffx + (sizex * 0.5f), 0);
|
||||
immBegin(GL_QUADS, 4);
|
||||
|
||||
glTexCoord2f(ratiox + halfx, ratioy + halfy);
|
||||
glVertex2f(soffx + (sizex * 0.5f), sizey);
|
||||
immAttrib2f(texcoord, halfx, halfy);
|
||||
immVertex2f(pos, soffx, 0.0f);
|
||||
|
||||
glTexCoord2f(halfx, ratioy + halfy);
|
||||
glVertex2f(soffx, sizey);
|
||||
glEnd();
|
||||
immAttrib2f(texcoord, ratiox + halfx, halfy);
|
||||
immVertex2f(pos, soffx + (sizex * 0.5f), 0.0f);
|
||||
|
||||
immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy);
|
||||
immVertex2f(pos, soffx + (sizex * 0.5f), sizey);
|
||||
|
||||
immAttrib2f(texcoord, halfx, ratioy + halfy);
|
||||
immVertex2f(pos, soffx, sizey);
|
||||
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
|
||||
glBindTexture(triple->target, 0);
|
||||
glDisable(triple->target);
|
||||
@@ -262,23 +273,33 @@ static void wm_method_draw_stereo3d_topbottom(wmWindow *win)
|
||||
halfy /= triple->y;
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned texcoord = add_attrib(format, "texcoord", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
unsigned pos = add_attrib(format, "position", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
glEnable(triple->target);
|
||||
immBindBuiltinProgram((triple->target == GL_TEXTURE_2D) ? GPU_SHADER_2D_TEXTURE_2D : GPU_SHADER_2D_TEXTURE_RECT);
|
||||
|
||||
glBindTexture(triple->target, triple->bind);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(halfx, halfy);
|
||||
glVertex2f(0, soffy);
|
||||
immUniform1i("texture_map", 0);
|
||||
|
||||
glTexCoord2f(ratiox + halfx, halfy);
|
||||
glVertex2f(sizex, soffy);
|
||||
immBegin(GL_QUADS, 4);
|
||||
|
||||
glTexCoord2f(ratiox + halfx, ratioy + halfy);
|
||||
glVertex2f(sizex, soffy + (sizey * 0.5f));
|
||||
immAttrib2f(texcoord, halfx, halfy);
|
||||
immVertex2f(pos, 0.0f, soffy);
|
||||
|
||||
glTexCoord2f(halfx, ratioy + halfy);
|
||||
glVertex2f(0, soffy + (sizey * 0.5f));
|
||||
glEnd();
|
||||
immAttrib2f(texcoord, ratiox + halfx, halfy);
|
||||
immVertex2f(pos, sizex, soffy);
|
||||
|
||||
immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy);
|
||||
immVertex2f(pos, sizex, soffy + (sizey * 0.5f));
|
||||
|
||||
immAttrib2f(texcoord, halfx, ratioy + halfy);
|
||||
immVertex2f(pos, 0.0f, soffy + (sizey * 0.5f));
|
||||
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
|
||||
glBindTexture(triple->target, 0);
|
||||
glDisable(triple->target);
|
||||
|
||||
Reference in New Issue
Block a user