Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_stereo.c
| Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static void wm_method_draw_stereo3d_pageflip(wmWindow *win) | ||||
| for (view = 0; view < 2; view ++) { | for (view = 0; view < 2; view ++) { | ||||
| drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1); | drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1); | ||||
| if (view == STEREO_LEFT_ID) | if (view == STEREO_LEFT_ID) | ||||
| glDrawBuffer(GL_BACK_LEFT); | glDrawBuffer(GL_BACK_LEFT); | ||||
| else //STEREO_RIGHT_ID | else //STEREO_RIGHT_ID | ||||
| glDrawBuffer(GL_BACK_RIGHT); | glDrawBuffer(GL_BACK_RIGHT); | ||||
| wm_triple_draw_textures(win, drawdata->triple, 1.0f, false); | wm_triple_draw_textures(win, drawdata->triple, 1.0f); | ||||
| } | } | ||||
| glDrawBuffer(GL_BACK); | glDrawBuffer(GL_BACK); | ||||
| } | } | ||||
| static enum eStereo3dInterlaceType interlace_prev_type = -1; | static enum eStereo3dInterlaceType interlace_prev_type = -1; | ||||
| static char interlace_prev_swap = -1; | static char interlace_prev_swap = -1; | ||||
| static void wm_method_draw_stereo3d_interlace(wmWindow *win) | static void wm_method_draw_stereo3d_interlace(wmWindow *win) | ||||
| { | { | ||||
| wmDrawData *drawdata; | wmDrawData *drawdata; | ||||
| int view; | int view; | ||||
| bool flag; | bool flag; | ||||
| bool swap = (win->stereo3d_format->flag & S3D_INTERLACE_SWAP) != 0; | bool swap = (win->stereo3d_format->flag & S3D_INTERLACE_SWAP) != 0; | ||||
| enum eStereo3dInterlaceType interlace_type = win->stereo3d_format->interlace_type; | enum eStereo3dInterlaceType interlace_type = win->stereo3d_format->interlace_type; | ||||
| const int sizex = WM_window_pixels_x(win); | |||||
| const int sizey = WM_window_pixels_y(win); | |||||
| /* wmOrtho for the screen has this same offset */ | |||||
| float ratiox = sizex; | |||||
| float ratioy = sizey; | |||||
| float halfx = GLA_PIXEL_OFS; | |||||
| float halfy = GLA_PIXEL_OFS; | |||||
| #if USE_TEXTURE_RECTANGLE | |||||
| /* texture rectangle has unnormalized coordinates */ | |||||
| #else | |||||
| ratiox /= triple->x; | |||||
| ratioy /= triple->y; | |||||
| halfx /= triple->x; | |||||
| halfy /= triple->y; | |||||
| #endif | |||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned texcoord = add_attrib(format, "texCoord", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| const int activeTex = 7; /* arbitrary */ | |||||
| glActiveTexture(GL_TEXTURE0 + activeTex); | |||||
| #if USE_TEXTURE_RECTANGLE | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_RECT_STIPPLE); | |||||
| #else | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_STIPPLE); | |||||
| #endif | |||||
| immUniform1i("image", activeTex); | |||||
| for (view = 0; view < 2; view ++) { | for (view = 0; view < 2; view ++) { | ||||
| flag = swap ? !view : view; | flag = swap ? !view : view; | ||||
| drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1); | drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1); | ||||
| GPU_basic_shader_bind(GPU_SHADER_STIPPLE); | |||||
| GPUBasicShaderStipple stipple_id; | |||||
| switch (interlace_type) { | switch (interlace_type) { | ||||
| case S3D_INTERLACE_ROW: | case S3D_INTERLACE_ROW: | ||||
| if (flag) | if (flag) | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW_SWAP); | stipple_id = GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW_SWAP; | ||||
| else | else | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW); | stipple_id = GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW; | ||||
| break; | break; | ||||
| case S3D_INTERLACE_COLUMN: | case S3D_INTERLACE_COLUMN: | ||||
| if (flag) | if (flag) | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN_SWAP); | stipple_id = GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN_SWAP; | ||||
| else | else | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN); | stipple_id = GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN; | ||||
| break; | break; | ||||
| case S3D_INTERLACE_CHECKERBOARD: | case S3D_INTERLACE_CHECKERBOARD: | ||||
| default: | default: | ||||
| if (flag) | if (flag) | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER_SWAP); | stipple_id = GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER_SWAP; | ||||
| else | else | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER); | stipple_id = GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER; | ||||
| break; | break; | ||||
| } | } | ||||
| wm_triple_draw_textures(win, drawdata->triple, 1.0f, true); | immUniform1i("stipple_id", stipple_id); | ||||
| GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); | |||||
| glBindTexture(drawdata->triple->target, drawdata->triple->bind); | |||||
| immBegin(GL_QUADS, 4); | |||||
| immAttrib2f(texcoord, halfx, halfy); | |||||
| immVertex2f(pos, 0.0f, 0.0f); | |||||
| immAttrib2f(texcoord, ratiox + halfx, halfy); | |||||
| immVertex2f(pos, sizex, 0.0f); | |||||
| immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy); | |||||
| immVertex2f(pos, sizex, sizey); | |||||
| immAttrib2f(texcoord, halfx, ratioy + halfy); | |||||
| immVertex2f(pos, 0.0f, sizey); | |||||
| immEnd(); | |||||
| glBindTexture(drawdata->triple->target, 0); | |||||
| } | } | ||||
| immUnbindProgram(); | |||||
| if (activeTex != 0) | |||||
| glActiveTexture(GL_TEXTURE0); | |||||
| interlace_prev_type = interlace_type; | interlace_prev_type = interlace_type; | ||||
| interlace_prev_swap = swap; | interlace_prev_swap = swap; | ||||
| } | } | ||||
merwin: Most recent call was glActiveTexture(GL_TEXTURE0 + activeTex + (eye = 1))
Could assume… | |||||
| static void wm_method_draw_stereo3d_anaglyph(wmWindow *win) | static void wm_method_draw_stereo3d_anaglyph(wmWindow *win) | ||||
| { | { | ||||
| wmDrawData *drawdata; | wmDrawData *drawdata; | ||||
| int view, bit; | int view, bit; | ||||
| for (view = 0; view < 2; view ++) { | for (view = 0; view < 2; view ++) { | ||||
| drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1); | drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1); | ||||
| Show All 15 Lines | switch (win->stereo3d_format->anaglyph_type) { | ||||
| case S3D_ANAGLYPH_YELLOWBLUE: | case S3D_ANAGLYPH_YELLOWBLUE: | ||||
| glColorMask((1&bit) ? GL_TRUE : GL_FALSE, | glColorMask((1&bit) ? GL_TRUE : GL_FALSE, | ||||
| (1&bit) ? GL_TRUE : GL_FALSE, | (1&bit) ? GL_TRUE : GL_FALSE, | ||||
| (2&bit) ? GL_TRUE : GL_FALSE, | (2&bit) ? GL_TRUE : GL_FALSE, | ||||
| GL_FALSE); | GL_FALSE); | ||||
| break; | break; | ||||
| } | } | ||||
| wm_triple_draw_textures(win, drawdata->triple, 1.0f, false); | wm_triple_draw_textures(win, drawdata->triple, 1.0f); | ||||
| glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | ||||
| } | } | ||||
| } | } | ||||
| static void wm_method_draw_stereo3d_sidebyside(wmWindow *win) | static void wm_method_draw_stereo3d_sidebyside(wmWindow *win) | ||||
| { | { | ||||
| wmDrawData *drawdata; | wmDrawData *drawdata; | ||||
| ▲ Show 20 Lines • Show All 409 Lines • Show Last 20 Lines | |||||
Most recent call was glActiveTexture(GL_TEXTURE0 + activeTex + (eye = 1))
Could assume activeTex > 0 and always call glActiveTexture(GL_TEXTURE0) here
or
use GL_TEXTURE0 + 0 for eye 0
use GL_TEXTURE0 + 1 for eye 1
bind eye 1 then eye 0 so that GL_TEXTURE0 is already active when this function exits.