void start() { texture = new vsx_texture; texture->init_color_depth_buffer(res_x,res_x); texture->valid = false; texture_result->set(texture); }
void vsx_module_texture_rotate::run() { //printf("rotate_begin\n"); vsx_texture** texture_info_in = texture_info_param_in->get_addr(); //printf("validness: %d\n",texture_info_param_in->valid); // if (texture_info_in->valid) if (texture_info_in) { texture_out->valid = (*texture_info_in)->valid; // if (texture_info_in->texture_info) { texture_out->texture_info = (*texture_info_in)->texture_info; // } float x = rotation_axis->get(0); float y = rotation_axis->get(1); float z = rotation_axis->get(2); float a = rotation_angle->get()*360; vsx_transform_obj* prev_transform = (*texture_info_in)->get_transform(); transform.set_previous_transform(prev_transform); transform.update(a, x, y, z); // if (texture_out) texture_out->set_transform(&transform); ((vsx_module_param_texture*)texture_result)->set(texture_out); } else { //printf("fooble\n"); texture_result->valid = false; } }
void output(vsx_module_param_abs* param) { vsx_texture** t_a; t_a = texture_a_in->get_addr(); vsx_texture** t_b; t_b = texture_b_in->get_addr(); if (t_a && t_b) { ((vsx_module_param_texture*)texture_a_out)->set(*t_a); ((vsx_module_param_texture*)texture_b_out)->set(*t_b); } if (fade_pos_from_engine->get() != 0.0f) { fade_pos_out->set(fade_pos_in->get()); } else { fade_pos_out->set((float)fmod(engine->real_vtime, 1.0f)); } }
void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters) { texture_a_in = (vsx_module_param_texture*)in_parameters.create(VSX_MODULE_PARAM_ID_TEXTURE, "texture_a_in"); texture_b_in = (vsx_module_param_texture*)in_parameters.create(VSX_MODULE_PARAM_ID_TEXTURE, "texture_b_in"); fade_pos_from_engine = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "fade_pos_from_engine"); fade_pos_in = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "fade_pos_in"); fade_pos_out = (vsx_module_param_float*)out_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "fade_pos_out"); fade_pos_out->set(0.0f); texture_a_out = (vsx_module_param_texture*)out_parameters.create(VSX_MODULE_PARAM_ID_TEXTURE, "texture_a_out"); texture_b_out = (vsx_module_param_texture*)out_parameters.create(VSX_MODULE_PARAM_ID_TEXTURE, "texture_b_out"); ab.bpp = 4; ab.bformat = GL_RGBA; ab.size_x = ab.size_y = 2; ab.data = new vsx_bitmap_32bt[4]; ((vsx_bitmap_32bt*)ab.data)[0] = 0xFFFF0000; ((vsx_bitmap_32bt*)ab.data)[1] = 0xFF000000; ((vsx_bitmap_32bt*)ab.data)[2] = 0xFF000000; ((vsx_bitmap_32bt*)ab.data)[3] = 0xFFFF0000; ab.valid = true; bb.bpp = 4; bb.bformat = GL_RGBA; bb.size_x = bb.size_y = 2; bb.data = new vsx_bitmap_32bt[4]; ((vsx_bitmap_32bt*)bb.data)[0] = 0xFF000000; ((vsx_bitmap_32bt*)bb.data)[1] = 0xFF0000FF; ((vsx_bitmap_32bt*)bb.data)[2] = 0xFF0000FF; ((vsx_bitmap_32bt*)bb.data)[3] = 0xFF000000; bb.valid = true; texture_a.locked = true; texture_a.init_opengl_texture(); texture_b.locked = true; texture_b.init_opengl_texture(); texture_a.upload_ram_bitmap(&ab,false); texture_b.upload_ram_bitmap(&bb,false); texture_a_out->set(&texture_a); texture_b_out->set(&texture_b); }
void start() { which_buffer = false; texture = new vsx_texture; texture->init_buffer(res_x,res_x); texture->valid = false; texture_result->set(texture); texture2 = new vsx_texture; texture2->init_buffer(res_x,res_x); texture2->valid = false; }
void vsx_module_texture_translate::run() { vsx_texture** texture_info_in = texture_info_param_in->get_addr(); if (texture_info_in) { texture_out->valid = (*texture_info_in)->valid; texture_out->texture_info = (*texture_info_in)->texture_info; float x = translation_vec->get(0); float y = translation_vec->get(1); float z = translation_vec->get(2); vsx_transform_obj* prev_transform = (*texture_info_in)->get_transform(); transform.set_previous_transform(prev_transform); transform.update(x, y, z); texture_out->set_transform(&transform); ((vsx_module_param_texture*)texture_result)->set(texture_out); } else texture_result->valid = false; }
void run() { texture_out = texture_info_param_in->get_addr(); if (texture_out) { if (param_updates) { (*texture_out)->bind(); #ifdef VSXU_OPENGL_ES if (GL_EXT_texture_filter_anisotropic) #endif #ifndef VSXU_OPENGL_ES if (GLEW_EXT_texture_filter_anisotropic) #endif { float rMaxAniso; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &rMaxAniso); if (anisotropic_filter->get()) glTexParameterf((*texture_out)->texture_info.ogl_type, GL_TEXTURE_MAX_ANISOTROPY_EXT, rMaxAniso); else glTexParameterf((*texture_out)->texture_info.ogl_type, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f); } float vals[4]; vals[0] = border_color->get(0); vals[1] = border_color->get(1); vals[2] = border_color->get(2); vals[3] = border_color->get(3); glTexParameteri((*texture_out)->texture_info.ogl_type,GL_TEXTURE_MIN_FILTER, tex_filter[min_filter->get()]); glTexParameteri((*texture_out)->texture_info.ogl_type,GL_TEXTURE_MAG_FILTER, tex_filter[mag_filter->get()]); #ifndef VSXU_OPENGL_ES glTexParameterfv((*texture_out)->texture_info.ogl_type, GL_TEXTURE_BORDER_COLOR, vals); #endif glTexParameteri((*texture_out)->texture_info.ogl_type, GL_TEXTURE_WRAP_T, tex_wrap[wrap_t->get()]); glTexParameteri((*texture_out)->texture_info.ogl_type, GL_TEXTURE_WRAP_S, tex_wrap[wrap_s->get()]); (*texture_out)->_bind(); --param_updates; } ((vsx_module_param_texture*)texture_result)->set(*texture_out); } else { texture_result->valid = false; } }
void run() { texture = texture_in->get_addr(); if (texture) { (*texture)->bind(); GLint components; glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_COMPONENTS,&components); //printf("components: %d\n",components); GLint pack; glGetIntegerv(GL_PACK_ALIGNMENT,&pack); // printf("pack: %d\n",pack); if (pack == 4) { GLint width; GLint height; glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&width); glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&height); // printf("height: %d\n",height); if (bitm.size_x != (unsigned int)width || bitm.size_y != (unsigned int)height) { // printf("allocating new memory\n"); // printf("height: %d\n",height); if (bitm.data) delete[] (vsx_bitmap_32bt*)bitm.data; bitm.data = new vsx_bitmap_32bt[width*height]; bitm.size_x = width; bitm.size_y = height; } //printf("bwidth: %d\n",width); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitm.data); //printf("bdata: %d\n",(unsigned int)bitm.data[0]); bitm.valid = true; ++bitm.timestamp; result1->set_p(bitm); } (*texture)->_bind(); } }
bool activate_offscreen() { #if defined(VSXU_OPENGL_ES) || defined (__APPLE__) glGetIntegerv (GL_VIEWPORT, viewport); #endif bool rebuild = false; if (alpha_channel->get() != alpha_channel_int) { alpha_channel_int = alpha_channel->get(); rebuild = true; } if (float_texture->get() != float_texture_int) { float_texture_int = float_texture->get(); rebuild = true; } if (multisample->get() != multisample_int) { multisample_int = multisample->get(); rebuild = true; } if (multisample->get() != multisample_int) { multisample_int = multisample->get(); rebuild = true; } if (depth_buffer_in->connected && depth_buffer_in->valid) { vsx_texture* depth_in = depth_buffer_in->get(); if ( depth_buffer_in_int != depth_in->texture_info.ogl_id ) { depth_buffer_in_int = depth_in->texture_info.ogl_id; rebuild = true; } // check if the sizes differ, if they do we can't proceed } else { if (0 != depth_buffer_in_int) rebuild = true; depth_buffer_in_int = 0; } if (texture_size->get() >= 10) { glGetIntegerv (GL_VIEWPORT, viewport); int t_res_x = abs(viewport[2] - viewport[0]); int t_res_y = abs(viewport[3] - viewport[1]); if (texture_size->get() == 10) { if (t_res_x != res_x || t_res_y != res_y) rebuild = true; } if (texture_size->get() == 11) { if (t_res_x / 2 != res_x || t_res_y / 2 != res_y) rebuild = true; } if (texture_size->get() == 12) { if (t_res_x / 4 != res_x || t_res_y / 4 != res_y) rebuild = true; } if (texture_size->get() == 13) { if (t_res_x * 2 != res_x || t_res_y * 2 != res_y) rebuild = true; } if (texture_size->get() == 14) { if (t_res_x * 4 != res_x || t_res_y * 4 != res_y) rebuild = true; } } if (texture_size->get() != tex_size_internal || rebuild) { //printf("generating new framebuffer\n"); tex_size_internal = texture_size->get(); switch (tex_size_internal) { case 0: res_y = res_x = 2048; break; case 1: res_y = res_x = 1024; break; case 2: res_y = res_x = 512; break; case 3: res_y = res_x = 256; break; case 4: res_y = res_x = 128; break; case 5: res_y = res_x = 64; break; case 6: res_y = res_x = 32; break; case 7: res_y = res_x = 16; break; case 8: res_y = res_x = 8; break; case 9: res_y = res_x = 4; break; case 10: res_x = abs(viewport[2] - viewport[0]); res_y = abs(viewport[3] - viewport[1]); break; case 11: res_x = abs(viewport[2] - viewport[0]) / 2; res_y = abs(viewport[3] - viewport[1]) / 2; break; case 12: res_x = abs(viewport[2] - viewport[0]) / 4; res_y = abs(viewport[3] - viewport[1]) / 4; break; case 13: res_x = abs(viewport[2] - viewport[0]) * 2; res_y = abs(viewport[3] - viewport[1]) * 2; break; case 14: res_x = abs(viewport[2] - viewport[0]) * 4; res_y = abs(viewport[3] - viewport[1]) * 4; break; }; if ( depth_buffer_in_int != 0 ) { vsx_texture* depth_in = depth_buffer_in->get(); if ( depth_in->texture_info.size_x != res_x || depth_in->texture_info.size_y != res_y ) { res_x = depth_in->texture_info.size_x; res_y = depth_in->texture_info.size_y; } } texture->reinit_color_depth_buffer ( res_x, res_y, float_texture_int, alpha_channel_int, multisample_int, depth_buffer_in_int ); } texture->begin_capture_to_buffer(); //printf("changing viewport to %d\n",res_x); glViewport(0,0,res_x,res_y); glDepthMask(GL_TRUE); glEnable(GL_BLEND); glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&glsl_prog); if ( atof((char*)glGetString(GL_VERSION)) >= 2.0 ) glUseProgram(0); else glUseProgramObjectARB(0); depth_buffer_texture.texture_info.ogl_id = texture->get_depth_buffer_handle(); depth_buffer_texture.texture_info.ogl_type = GL_TEXTURE_2D; depth_buffer_texture.texture_info.size_x = res_x; depth_buffer_texture.texture_info.size_y = res_y; depth_buffer_out->set(&depth_buffer_texture); loading_done = true; return true; }