void drawMesh(SMeshBuffer* mesh, Matrix4* modelViewMatrix, float* scanlineParams) { u32 offset; rsxAddressToOffset(&mesh->vertices[0].pos,&offset); rsxBindVertexArrayAttrib(context,vertexPosition_id, offset, sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxAddressToOffset(&mesh->vertices[0].nrm,&offset); rsxBindVertexArrayAttrib(context,vertexNormal_id, offset, sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxAddressToOffset(&mesh->vertices[0].u,&offset); rsxBindVertexArrayAttrib(context,vertexTexcoord_id, offset, sizeof(S3DVertex),2,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxLoadVertexProgram(context, vpo, vp_ucode); rsxSetVertexProgramParameter(context, vpo, projMatrix_id, (float*) &P); rsxSetVertexProgramParameter(context, vpo, modelViewMatrix_id,(float*) modelViewMatrix); rsxSetFragmentProgramParameter(context, fpo, scanline_id, scanlineParams, fp_offset); rsxLoadFragmentProgramLocation(context,fpo,fp_offset,GCM_LOCATION_RSX); rsxSetUserClipPlaneControl(context,GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE); rsxAddressToOffset(&mesh->indices[0],&offset); rsxDrawIndexArray(context,GCM_TYPE_TRIANGLES, offset,mesh->cnt_indices, GCM_INDEX_TYPE_16B, GCM_LOCATION_RSX); }
unsigned int * PS3_allocTextureBuffer(int w, int h, int type) { //user interface texture if (type) { texture_buffer_ui = (u32*)rsxMemalign(128,(w * h * 4)); if(!texture_buffer_ui) return NULL; rsxAddressToOffset(texture_buffer_ui, &texture_offset_ui); textureW_ui = w; textureH_ui = h; return texture_buffer_ui; } else //video texture { texture_buffer = (u32*)rsxMemalign(128,(w * h * 4)); if(!texture_buffer) return NULL; rsxAddressToOffset(texture_buffer,&texture_offset); textureW = w; textureH = h; return texture_buffer; } }
int makeBuffer (rsxBuffer * buffer, u16 width, u16 height, int id) { int depth = sizeof (u32); int pitch = depth * width; int size = depth * width * height; buffer->ptr = (uint32_t *) rsxMemalign (64, size); if (buffer->ptr == NULL) goto error; if (rsxAddressToOffset (buffer->ptr, &buffer->offset) != 0) goto error; /* Register the display buffer with the RSX */ if (gcmSetDisplayBuffer (id, buffer->offset, pitch, width, height) != 0) goto error; buffer->width = width; buffer->height = height; buffer->id = id; return TRUE; error: if (buffer->ptr != NULL) rsxFree (buffer->ptr); return FALSE; }
void init_shader() { u32 fpsize = 0; vp_ucode = rsxVertexProgramGetUCode(vpo); projMatrix_id = rsxVertexProgramGetConst(vpo,"projMatrix"); modelViewMatrix_id = rsxVertexProgramGetConst(vpo,"modelViewMatrix"); vertexPosition_id = rsxVertexProgramGetAttrib(vpo,"vertexPosition"); vertexNormal_id = rsxVertexProgramGetAttrib(vpo,"vertexNormal"); vertexTexcoord_id = rsxVertexProgramGetAttrib(vpo,"vertexTexcoord"); fp_ucode = rsxFragmentProgramGetUCode(fpo,&fpsize); fp_buffer = (u32*)rsxMemalign(64,fpsize); memcpy(fp_buffer,fp_ucode,fpsize); rsxAddressToOffset(fp_buffer,&fp_offset); textureUnit_id = rsxFragmentProgramGetAttrib(fpo,"texture"); eyePosition_id = rsxFragmentProgramGetConst(fpo,"eyePosition"); globalAmbient_id = rsxFragmentProgramGetConst(fpo,"globalAmbient"); lightPosition_id = rsxFragmentProgramGetConst(fpo,"lightPosition"); lightColor_id = rsxFragmentProgramGetConst(fpo,"lightColor"); shininess_id = rsxFragmentProgramGetConst(fpo,"shininess"); Ks_id = rsxFragmentProgramGetConst(fpo,"Ks"); Kd_id = rsxFragmentProgramGetConst(fpo,"Kd"); }
static struct sw_displaytarget * psl1ght_displaytarget_create(struct sw_winsys *ws, unsigned tex_usage, enum pipe_format format, unsigned width, unsigned height, unsigned alignment, unsigned *stride) { struct psl1ght_sw_winsys *psl1ght = psl1ght_sw_winsys(ws); struct psl1ght_sw_displaytarget *psdt; psdt = CALLOC_STRUCT(psl1ght_sw_displaytarget); if (!psdt) return NULL; psdt->width = width; psdt->height = height; psdt->stride = width * 4; psdt->bufferId = NO_BUFFER; psdt->data = rsxMemalign(64, psdt->height * psdt->stride); if (!psdt->data) { FREE(psdt); return NULL; } if (rsxAddressToOffset(psdt->data, &psdt->offset)) { rsxFree(psdt->data); FREE(psdt); return NULL; } *stride = psdt->stride; return (struct sw_displaytarget *) psdt; }
int initScreen (void *host_addr, u32 size) { // gcmContextData *context = NULL; /* Context to keep track of the RSX // buffer. */ videoState state; videoConfiguration vconfig; videoResolution res; /* Screen Resolution */ /* Initilise Reality, which sets up the command buffer and shared IO memory */ context = rsxInit (CB_SIZE, size, host_addr); if (context == NULL) goto error; /* Get the state of the display */ if (videoGetState (0, 0, &state) != 0) goto error; /* Make sure display is enabled */ if (state.state != 0) goto error; /* Get the current resolution */ if (videoGetResolution (state.displayMode.resolution, &res) != 0) goto error; /* Configure the buffer format to xRGB */ memset (&vconfig, 0, sizeof (videoConfiguration)); vconfig.resolution = state.displayMode.resolution; vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; vconfig.pitch = res.width * sizeof (u32); vconfig.aspect = state.displayMode.aspect; waitRSXIdle (context); if (videoConfigure (0, &vconfig, NULL, 0) != 0) goto error; if (videoGetState (0, 0, &state) != 0) goto error; gcmSetFlipMode (GCM_FLIP_VSYNC); // Wait for VSYNC to flip depth_pitch = res.width * sizeof (u32); depth_buffer = (u32 *) rsxMemalign (64, (res.height * depth_pitch) * 2); rsxAddressToOffset (depth_buffer, &depth_offset); gcmResetFlipStatus (); return 0; error: if (context) rsxFinish (context, 0); if (host_addr) free (host_addr); return 1; }
u32 tiny3d_TextureOffset(void * text) { u32 offset = 0; assert(rsxAddressToOffset(text, &offset)==0); return offset; }
void init_screen(void *host_addr,u32 size) { printf("initializing screen....\n"); context = rsxInit(CB_SIZE,size,host_addr); videoState state; videoGetState(0,0,&state); videoGetResolution(state.displayMode.resolution,&res); videoConfiguration vconfig; memset(&vconfig,0,sizeof(videoConfiguration)); vconfig.resolution = state.displayMode.resolution; vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; vconfig.pitch = res.width*sizeof(u32); waitRSXIdle(); videoConfigure(0,&vconfig,NULL,0); videoGetState(0,0,&state); gcmSetFlipMode(GCM_FLIP_VSYNC); display_width = res.width; display_height = res.height; color_pitch = display_width*sizeof(u32); color_buffer[0] = (u32*)rsxMemalign(64,(display_height*color_pitch)); color_buffer[1] = (u32*)rsxMemalign(64,(display_height*color_pitch)); rsxAddressToOffset(color_buffer[0],&color_offset[0]); rsxAddressToOffset(color_buffer[1],&color_offset[1]); gcmSetDisplayBuffer(0,color_offset[0],color_pitch,display_width,display_height); gcmSetDisplayBuffer(1,color_offset[1],color_pitch,display_width,display_height); depth_pitch = display_width*sizeof(u32); depth_buffer = (u32*)rsxMemalign(64,(display_height*depth_pitch)*2); rsxAddressToOffset(depth_buffer,&depth_offset); printf("screen initialized....\n"); }
/* Initilize everything. */ void init_screen(displayData *vdat) { int i; /* Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX. */ void *host_addr = memalign(1024*1024, 1024*1024); assert(host_addr != NULL); /* Initilise libRSX, which sets up the command buffer and shared IO memory */ vdat->context = rsxInit(0x10000, 1024*1024, host_addr); assert(vdat->context != NULL); videoState state; s32 status = videoGetState(0, 0, &state); // Get the state of the display assert(status == 0); assert(state.state == 0); // Make sure display is enabled /* Get the current resolution */ status = videoGetResolution(state.displayMode.resolution, &vdat->res); assert(status == 0); /* Configure the buffer format to xRGB */ videoConfiguration vconfig; memset(&vconfig, 0, sizeof(videoConfiguration)); vconfig.resolution = state.displayMode.resolution; vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; vconfig.pitch = vdat->res.width * 4; vconfig.aspect=state.displayMode.aspect; status = videoConfigure(0, &vconfig, NULL, 0); assert(status == 0); status = videoGetState(0, 0, &state); assert(status == 0); gcmSetFlipMode(GCM_FLIP_VSYNC); /* Wait for VSYNC to flip */ /* Allocate and setup two buffers for the RSX to draw to the screen (double buffering) */ vdat->pitch = vdat->res.width*sizeof(u32); for (i=0; i<2; ++i) { vdat->buffer[i] = (u32*)rsxMemalign(64,vdat->res.width*vdat->pitch); assert(vdat->buffer[i] != NULL); status = rsxAddressToOffset(vdat->buffer[i], &vdat->offset[i]); assert(status==0); status = gcmSetDisplayBuffer(i, vdat->offset[i], vdat->pitch, vdat->res.width, vdat->res.height); assert(status==0); } gcmResetFlipStatus(); vdat->curr_fb = 0; vdat->framecnt = 0; flip(vdat); }
static void init_texture() { u32 i; u8 *buffer; const u8 *data = acid.pixel_data; texture_buffer = (u32*)rsxMemalign(128,(acid.width*acid.height*4)); if(!texture_buffer) return; rsxAddressToOffset(texture_buffer,&texture_offset); buffer = (u8*)texture_buffer; for(i=0;i<acid.width*acid.height*4;i+=4) { buffer[i + 1] = *data++; buffer[i + 2] = *data++; buffer[i + 3] = *data++; buffer[i + 0] = *data++; } }
void init_shader() { u32 fpsize = 0; vp_ucode = rsxVertexProgramGetUCode(vpo); projMatrix_id = rsxVertexProgramGetConst(vpo, "projMatrix"); modelViewMatrix_id = rsxVertexProgramGetConst(vpo, "modelViewMatrix"); vertexPosition_id = rsxVertexProgramGetAttrib(vpo, "vertexPosition"); vertexNormal_id = rsxVertexProgramGetAttrib(vpo, "vertexNormal"); vertexTexcoord_id = rsxVertexProgramGetAttrib(vpo, "vertexTexcoord"); fp_ucode = rsxFragmentProgramGetUCode(fpo, &fpsize); fp_buffer = (u32*) rsxMemalign(64, fpsize); memcpy(fp_buffer, fp_ucode, fpsize); rsxAddressToOffset(fp_buffer, &fp_offset); textureUnit_id = rsxFragmentProgramGetAttrib(fpo, "texture"); scanline_id = rsxFragmentProgramGetConst(fpo, "scanline"); }
void drawFrame() { u32 i,offset,color = 0; Matrix4 rotX,rotY; Vector4 objEyePos,objLightPos; Matrix4 viewMatrix,modelMatrix,modelMatrixIT,modelViewMatrix; Point3 lightPos = Point3(250.0f,150.0f,150.0f); f32 globalAmbientColor[3] = {0.1f,0.1f,0.1f}; f32 lightColor[3] = {0.95f,0.95f,0.95f}; f32 materialColorDiffuse[3] = {0.5f,0.0f,0.0f}; f32 materialColorSpecular[3] = {0.7f,0.6f,0.6f}; f32 shininess = 17.8954f; static f32 rot = 0.0f; SMeshBuffer *mesh = NULL; setTexture(); setDrawEnv(); rsxSetClearColor(context,color); rsxSetClearDepthValue(context,0xffff); rsxClearSurface(context,GCM_CLEAR_R | GCM_CLEAR_G | GCM_CLEAR_B | GCM_CLEAR_A | GCM_CLEAR_S | GCM_CLEAR_Z); rsxZControl(context,0,1,1); for(i=0;i<8;i++) rsxSetViewportClip(context,i,display_width,display_height); viewMatrix = Matrix4::lookAt(eye_pos,eye_dir,up_vec); mesh = sphere; rotX = Matrix4::rotationX(DEGTORAD(30.0f)); rotY = Matrix4::rotationY(DEGTORAD(rot)); modelMatrix = rotX*rotY; modelMatrixIT = inverse(modelMatrix); modelViewMatrix = transpose(viewMatrix*modelMatrix); objEyePos = modelMatrixIT*eye_pos; objLightPos = modelMatrixIT*lightPos; rsxAddressToOffset(&mesh->vertices[0].pos,&offset); rsxBindVertexArrayAttrib(context,vertexPosition_id,offset,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxAddressToOffset(&mesh->vertices[0].nrm,&offset); rsxBindVertexArrayAttrib(context,vertexNormal_id,offset,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxAddressToOffset(&mesh->vertices[0].u,&offset); rsxBindVertexArrayAttrib(context,vertexTexcoord_id,offset,sizeof(S3DVertex),2,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxLoadVertexProgram(context,vpo,vp_ucode); rsxSetVertexProgramParameter(context,vpo,projMatrix_id,(float*)&P); rsxSetVertexProgramParameter(context,vpo,modelViewMatrix_id,(float*)&modelViewMatrix); rsxSetFragmentProgramParameter(context,fpo,eyePosition_id,(float*)&objEyePos,fp_offset); rsxSetFragmentProgramParameter(context,fpo,globalAmbient_id,globalAmbientColor,fp_offset); rsxSetFragmentProgramParameter(context,fpo,lightPosition_id,(float*)&objLightPos,fp_offset); rsxSetFragmentProgramParameter(context,fpo,lightColor_id,lightColor,fp_offset); rsxSetFragmentProgramParameter(context,fpo,shininess_id,&shininess,fp_offset); rsxSetFragmentProgramParameter(context,fpo,Kd_id,materialColorDiffuse,fp_offset); rsxSetFragmentProgramParameter(context,fpo,Ks_id,materialColorSpecular,fp_offset); rsxLoadFragmentProgramLocation(context,fpo,fp_offset,GCM_LOCATION_RSX); rsxSetUserClipPlaneControl(context,GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE); rsxAddressToOffset(&mesh->indices[0],&offset); rsxDrawIndexArray(context,GCM_TYPE_TRIANGLES,offset,mesh->cnt_indices,GCM_INDEX_TYPE_16B,GCM_LOCATION_RSX); mesh = donut; rotX = Matrix4::rotationX(DEGTORAD(rot)); rotY = Matrix4::rotationY(DEGTORAD(30.0f)); modelMatrix = rotX*rotY; modelMatrix.setTranslation(Vector3(3.0f,5.0f,-8.0f)); modelMatrixIT = inverse(modelMatrix); modelViewMatrix = transpose(viewMatrix*modelMatrix); objEyePos = modelMatrixIT*eye_pos; objLightPos = modelMatrixIT*lightPos; rsxAddressToOffset(&mesh->vertices[0].pos,&offset); rsxBindVertexArrayAttrib(context,vertexPosition_id,offset,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxAddressToOffset(&mesh->vertices[0].nrm,&offset); rsxBindVertexArrayAttrib(context,vertexNormal_id,offset,sizeof(S3DVertex),3,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxAddressToOffset(&mesh->vertices[0].u,&offset); rsxBindVertexArrayAttrib(context,vertexTexcoord_id,offset,sizeof(S3DVertex),2,GCM_VERTEX_DATA_TYPE_F32,GCM_LOCATION_RSX); rsxLoadVertexProgram(context,vpo,vp_ucode); rsxSetVertexProgramParameter(context,vpo,projMatrix_id,(float*)&P); rsxSetVertexProgramParameter(context,vpo,modelViewMatrix_id,(float*)&modelViewMatrix); rsxSetFragmentProgramParameter(context,fpo,eyePosition_id,(float*)&objEyePos,fp_offset); rsxSetFragmentProgramParameter(context,fpo,globalAmbient_id,globalAmbientColor,fp_offset); rsxSetFragmentProgramParameter(context,fpo,lightPosition_id,(float*)&objLightPos,fp_offset); rsxSetFragmentProgramParameter(context,fpo,lightColor_id,lightColor,fp_offset); rsxSetFragmentProgramParameter(context,fpo,shininess_id,&shininess,fp_offset); rsxSetFragmentProgramParameter(context,fpo,Kd_id,materialColorDiffuse,fp_offset); rsxSetFragmentProgramParameter(context,fpo,Ks_id,materialColorSpecular,fp_offset); rsxLoadFragmentProgramLocation(context,fpo,fp_offset,GCM_LOCATION_RSX); rsxSetUserClipPlaneControl(context,GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE, GCM_USER_CLIP_PLANE_DISABLE); rsxAddressToOffset(&mesh->indices[0],&offset); rsxDrawIndexArray(context,GCM_TYPE_TRIANGLES,offset,mesh->cnt_indices,GCM_INDEX_TYPE_16B,GCM_LOCATION_RSX); rot += 4.0f; if(rot>=360.0f) rot = 0.0f; }
// Initilize and rsx void init_screen(int command_buffer, int z_method) { // Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX. void *host_addr = memalign(1024*1024, command_buffer); assert(host_addr != NULL); if(z_method) zformat = REALITY_TARGET_FORMAT_ZETA_Z24S8; else zformat = REALITY_TARGET_FORMAT_ZETA_Z16; // Initilise Reality, which sets up the command buffer and shared IO memory context = rsxInit(0x10000, command_buffer, host_addr); assert(context != NULL); videoState state; assert(videoGetState(0, 0, &state) == 0); // Get the state of the display assert(state.state == 0); // Make sure display is enabled // Get the current resolution assert(videoGetResolution(state.displayMode.resolution, &Video_Resolution) == 0); Video_pitch = 4 * ((Video_Resolution.width + 15)/16) * 16; // each pixel is 4 bytes if(!z_method) // 16 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen depth_pitch = 2 * ((Video_Resolution.width > 1920) ? (((Video_Resolution.width+31)/32)*32) : 1920); else // 32 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen depth_pitch = 4 * ((Video_Resolution.width > 1920) ? (((Video_Resolution.width+15)/16)*16) : 1920); // Configure the buffer format to xRGB videoConfiguration vconfig; memset(&vconfig, 0, sizeof(videoConfiguration)); vconfig.resolution = state.displayMode.resolution; vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; vconfig.pitch = Video_pitch; Video_aspect=vconfig.aspect=state.displayMode.aspect; assert(videoConfigure(0, &vconfig, NULL, 0) == 0); assert(videoGetState(0, 0, &state) == 0); s32 buffer_size = Video_pitch * Video_Resolution.height; s32 depth_buffer_size; if(!z_method) // 16 bit float. Note it uses 1088 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen depth_buffer_size = depth_pitch * ((Video_Resolution.height > 1088) ? (((Video_Resolution.height+31)/32)*32) : 1088); else // 32 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen depth_buffer_size = depth_pitch * ((Video_Resolution.height > 1088) ? (((Video_Resolution.height+15)/16)*16) : 1088); printf("buffers will be 0x%x bytes\n", buffer_size); gcmSetFlipMode(GCM_FLIP_VSYNC); // Wait for VSYNC to flip // Allocate two buffers for the RSX to draw to the screen (double buffering) Video_buffer[0] = rsxMemalign(64, buffer_size); Video_buffer[1] = rsxMemalign(64, buffer_size); assert(Video_buffer[0] != NULL && Video_buffer[1] != NULL); depth_buffer = rsxMemalign(64, depth_buffer_size); assert(rsxAddressToOffset(Video_buffer[0], &offset[0]) == 0); assert(rsxAddressToOffset(Video_buffer[1], &offset[1]) == 0); // Setup the display buffers assert(gcmSetDisplayBuffer(0, offset[0], Video_pitch, Video_Resolution.width, Video_Resolution.height) == 0); assert(gcmSetDisplayBuffer(1, offset[1], Video_pitch, Video_Resolution.width, Video_Resolution.height) == 0); assert(rsxAddressToOffset(depth_buffer, &depth_offset) == 0); gcmResetFlipStatus(); flip(1); waitFlip(); }
static void set_shader_context(int old_shader) { u32 offset; u32 text_off = 16; if(old_shader == -1) internal_reality_LoadVertexProgram_good(context, (internal_reality_VertexProgram*) data_shader[current_shader].vp); //Pass the matrix to the shader if(use_2d) { internal_reality_SetVertexProgramConstant4fBlock(context, data_shader[current_shader].off_modelv, 4, (float*)(model_view.data)); internal_reality_SetVertexProgramConstant4fBlock(context, data_shader[current_shader].off_project, 4, (float*)(matrix_ident.data)); } else { internal_reality_SetVertexProgramConstant4fBlock(context, data_shader[current_shader].off_modelv, 4, (float*)(model_view.data)); internal_reality_SetVertexProgramConstant4fBlock(context, data_shader[current_shader].off_project, 4, (float*)(project_mat.data)); } if(data_shader[current_shader].off_normal >= 0) { flag_vertex |= VERTEX_MASK; Update_With_Normal(); } else { light.ambient[3] = 0.0f; internal_reality_SetVertexProgramConstant4f(context, data_shader[current_shader].off_lightAmbient, (float *) light.ambient); } flag_vertex &= ~VERTEX_MASKMATRIX; off_head_vertex = 0; //Bind the memory array to the input attributes //rsx requires the offset in his memory area rsxAddressToOffset(&rsx_vertex[off_start_vertex],&offset); //stride is the distance (in bytes) from the attribute in a vertex to the same attribute in the next vertex (that is, the size of a single vertex struct) //elements is the number of components of this attribute that will be passed to this input parameter in the vertex program (max 4) internal_reality_BindVertexBufferAttribute(context, data_shader[current_shader].off_position, offset, data_shader[current_shader].size_vertex, 4, REALITY_BUFFER_DATATYPE_FLOAT, REALITY_RSX_MEMORY); if(data_shader[current_shader].off_normal >= 0) { text_off += 12; rsxAddressToOffset(&rsx_vertex[off_start_vertex + 16],&offset); internal_reality_BindVertexBufferAttribute(context, data_shader[current_shader].off_normal, offset, data_shader[current_shader].size_vertex, 3, REALITY_BUFFER_DATATYPE_FLOAT, REALITY_RSX_MEMORY); } else if(data_shader[current_shader].off_color >= 0) { //now the color rsxAddressToOffset(&rsx_vertex[off_start_vertex + 16],&offset); if(data_shader[current_shader].fixed_color) { text_off += 4; internal_reality_BindVertexBufferAttribute(context, data_shader[current_shader].off_color, offset, data_shader[current_shader].size_vertex, 4, REALITY_BUFFER_DATATYPE_BYTE, REALITY_RSX_MEMORY); } else { text_off += 16; internal_reality_BindVertexBufferAttribute(context, data_shader[current_shader].off_color, offset, data_shader[current_shader].size_vertex, 4, REALITY_BUFFER_DATATYPE_FLOAT, REALITY_RSX_MEMORY); } } if(data_shader[current_shader].off_texture >= 0) { //now the texture coords rsxAddressToOffset(&rsx_vertex[off_start_vertex + text_off], &offset); internal_reality_BindVertexBufferAttribute(context, data_shader[current_shader].off_texture, offset, data_shader[current_shader].size_vertex, 2, REALITY_BUFFER_DATATYPE_FLOAT, REALITY_RSX_MEMORY); if(data_shader[current_shader].off_texture2 >= 0) { //now the texture coords2 rsxAddressToOffset(&rsx_vertex[off_start_vertex + text_off + 8], &offset); internal_reality_BindVertexBufferAttribute(context, data_shader[current_shader].off_texture2, offset, data_shader[current_shader].size_vertex, 2, REALITY_BUFFER_DATATYPE_FLOAT, REALITY_RSX_MEMORY); } } if(data_shader[current_shader].fp_yuv[0] && enable_yuv) internal_reality_LoadFragmentProgram(context, data_shader[current_shader].fp_yuv[enable_yuv - 1]); else if(data_shader[current_shader].fp_alt[0] == NULL) internal_reality_LoadFragmentProgram(context, data_shader[current_shader].fp); else { select_fp &= 15; if(!select_fp) internal_reality_LoadFragmentProgram(context, data_shader[current_shader].fp); else internal_reality_LoadFragmentProgram(context, data_shader[current_shader].fp_alt[select_fp-1]); } }