//void xeeSubmit() {} void xeeSubmit() { // never draw this one if (gl_cull_mode == GL_FRONT_AND_BACK) return; // update states if dirty XeUpdateStates(); // update if dirty XeGlCheckDirtyMatrix(&projection_matrix); XeGlCheckDirtyMatrix(&modelview_matrix); // Xe_SetStreamSource(xe, 0, pVbGL, xe_PrevNumVerts * sizeof(glVerticesFormat_t), 10); Xe_SetShader(xe, SHADER_TYPE_VERTEX, pVertexShader, 0); int i = 0; // setup texture for(i=0; i<XE_MAX_TMUS; i++) { // set texture if (xeTmus[i].enabled && xeTmus[i].boundtexture) { Xe_SetTexture(xe, i, xeTmus[i].boundtexture->teximg); } else { Xe_SetTexture(xe, i, NULL); } } // setup shaders GL_SelectShaders(); // draw Xe_DrawPrimitive(xe, Gl_Prim_2_Xe_Prim(xe_PrimitiveMode), xe_PrevNumVerts, Gl_Prim_2_Size(xe_PrimitiveMode, (xe_NumVerts - xe_PrevNumVerts))); //printBlendValue(); }
void GL_SelectTextures() { int i = 0; // setup texture for(i=0; i<XE_MAX_TMUS; i++) { // set texture if (xeTmus[i].enabled && xeTmus[i].boundtexture) { Xe_SetTexture(xe, i, xeTmus[i].boundtexture->teximg); } else { Xe_SetTexture(xe, i, NULL); } } }
void XeDrawSurface2(struct XenosSurface *txt, float dstx, float dsty, float width, float height, int withalpha) { float uleft = 0, uright = 1, vtop = 0, vbottom = 1; float logo[] = { dstx, dsty + height, uleft, vtop, dstx + width, dsty + height, uright, vtop, dstx, dsty, uleft, vbottom, dstx, dsty, uleft, vbottom, dstx + width, dsty + height, uright, vtop, dstx + width, dsty, uright, vbottom }; Xe_VBBegin(xe, 4); Xe_VBPut(xe, logo, 6 * 4); struct XenosVertexBuffer *vb = Xe_VBEnd(xe); Xe_VBPoolAdd(xe, vb); if (withalpha) { Xe_SetSrcBlend(xe, XE_BLEND_SRCALPHA); Xe_SetDestBlend(xe, XE_BLEND_INVSRCALPHA); Xe_SetBlendOp(xe, XE_BLENDOP_ADD); } else { Xe_SetSrcBlend(xe, XE_BLEND_ONE); Xe_SetDestBlend(xe, XE_BLEND_ZERO); Xe_SetBlendOp(xe, XE_BLENDOP_ADD); } Xe_SetShader(xe, SHADER_TYPE_PIXEL, sh_text_ps, 0); Xe_SetShader(xe, SHADER_TYPE_VERTEX, sh_text_vs, 0); Xe_SetTexture(xe, 0, txt); Xe_Draw(xe, vb, 0); }
void SYSVideoUpdate() { /* resize uv to viewport */ int vwidth = bitmap.viewport.w + (2 * bitmap.viewport.x); int vheight = bitmap.viewport.h + (2 * bitmap.viewport.y); update_texture_viewport(); int video_filter = getVideoFitler(); // apply video filter switch (video_filter){ case VF_2XSAI: filter_Std2xSaI_ex8(bitmap.data, bitmap.pitch, texture_buffer, vwidth, vheight); g_pTexture->width = vwidth<<1; g_pTexture->height = vheight<<1; break; case VF_BLINEAR: g_pTexture->use_filtering = 0; XeTexSubImage(g_pTexture, bitmap.viewport.x, bitmap.viewport.y, bitmap.viewport.w, bitmap.viewport.h, bitmap.data); g_pTexture->width = vwidth; g_pTexture->height = vheight; break; default: g_pTexture->use_filtering = 1; XeTexSubImage(g_pTexture, bitmap.viewport.x, bitmap.viewport.y, bitmap.viewport.w, bitmap.viewport.h, bitmap.data); g_pTexture->width = vwidth; g_pTexture->height = vheight; break; } // Refresh texture cash Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE); Xe_Surface_Unlock(g_pVideoDevice, g_pTexture); // Select stream and shaders Xe_SetTexture(g_pVideoDevice, 0, g_pTexture); Xe_SetCullMode(g_pVideoDevice, XE_CULL_NONE); Xe_SetStreamSource(g_pVideoDevice, 0, vb, 0, sizeof (DrawVerticeFormats)); Xe_SetShader(g_pVideoDevice, SHADER_TYPE_PIXEL, g_pPixelTexturedShader, 0); Xe_SetShader(g_pVideoDevice, SHADER_TYPE_VERTEX, g_pVertexShader, 0); Xe_SetClearColor(g_pVideoDevice, 0xFF000000); // Draw Xe_DrawPrimitive(g_pVideoDevice, XE_PRIMTYPE_RECTLIST, 0, 1); // Resolve Xe_Resolve(g_pVideoDevice); //while (!Xe_IsVBlank(g_pVideoDevice)); Xe_Sync(g_pVideoDevice); // Reset states Xe_InvalidateState(g_pVideoDevice); }
static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { gl_t *vid = data; ScreenUv[UV_TOP] = ((float) (width) / (float) XE_W)*2; ScreenUv[UV_LEFT] = ((float) (height) / (float) XE_H)*2; DrawVerticeFormats * Rect = Xe_VB_Lock(vid->gl_device, vid->vb, 0, 3 * sizeof(DrawVerticeFormats), XE_LOCK_WRITE); /* bottom left */ Rect[1].v = ScreenUv[UV_LEFT]; Rect[2].u = ScreenUv[UV_TOP]; Xe_VB_Unlock(vid->gl_device, vid->vb); /* Refresh texture cache */ uint16_t *dst = Xe_Surface_LockRect(vid->gl_device, vid->g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE); const uint16_t *src = frame; unsigned stride_in = pitch >>1; unsigned stride_out = vid->g_pTexture->wpitch >> 1; unsigned copy_size = width << 1; for (unsigned y = 0; y < height; y++, dst += stride_out, src += stride_in) memcpy(dst, src, copy_size); Xe_Surface_Unlock(vid->gl_device, vid->g_pTexture); /* Reset states */ Xe_InvalidateState(vid->gl_device); Xe_SetClearColor(vid->gl_device, 0); /* Select stream */ Xe_SetTexture(vid->gl_device, 0, vid->g_pTexture); Xe_SetCullMode(vid->gl_device, XE_CULL_NONE); Xe_SetStreamSource(vid->gl_device, 0, vid->vb, 0, sizeof(DrawVerticeFormats)); /* Select shaders */ Xe_SetShader(vid->gl_device, SHADER_TYPE_PIXEL, vid->g_pPixelTexturedShader, 0); Xe_SetShader(vid->gl_device, SHADER_TYPE_VERTEX, vid->g_pVertexShader, 0); #ifdef HAVE_MENU menu_driver_frame(video_info); #endif /* Draw */ Xe_DrawPrimitive(vid->gl_device, XE_PRIMTYPE_TRIANGLELIST, 0, 1); /* Resolve */ Xe_Resolve(vid->gl_device); Xe_Sync(vid->gl_device); return true; }
//Garde l'aspect ratio :) en function de la texture et non du framebuffer void XeDrawSurface(struct XenosSurface *txt, float dstx, float dsty, float scale, int withalpha,int center) { float scrratio = ((float) xe->tex_fb.width / (float) xe->tex_fb.height); //float txtratio=((float)txt->width/(float)txt->height); float height = scale * scrratio; float width = scale; float uleft = 0, uright = 1, vtop = 0, vbottom = 1; dsty=dsty - ((height/2)*center); float logo[] = { dstx, dsty + height, uleft, vtop, dstx + width, dsty + height, uright, vtop, dstx, dsty, uleft, vbottom, dstx, dsty, uleft, vbottom, dstx + width, dsty + height, uright, vtop, dstx + width, dsty, uright, vbottom }; Xe_VBBegin(xe, 4); Xe_VBPut(xe, logo, 6 * 4); struct XenosVertexBuffer *vb = Xe_VBEnd(xe); Xe_VBPoolAdd(xe, vb); if (withalpha) { Xe_SetSrcBlend(xe, XE_BLEND_SRCALPHA); Xe_SetDestBlend(xe, XE_BLEND_INVSRCALPHA); Xe_SetBlendOp(xe, XE_BLENDOP_ADD); } else { Xe_SetSrcBlend(xe, XE_BLEND_ONE); Xe_SetDestBlend(xe, XE_BLEND_ZERO); Xe_SetBlendOp(xe, XE_BLENDOP_ADD); } Xe_SetShader(xe, SHADER_TYPE_PIXEL, sh_text_ps, 0); Xe_SetShader(xe, SHADER_TYPE_VERTEX, sh_text_vs, 0); Xe_SetTexture(xe, 0, txt); Xe_Draw(xe, vb, 0); }
void XePrintf(float dstx, float dsty, const char *text, float scale, uint32_t icolor) { if (!*text) return 0; Xe_VBBegin(xe, 5); while (*text) { //struct fontentry *f = &fontentries[(unsigned char)*text++]; struct fnt_s *f = &verdana_fnt[(unsigned char) *text++]; if (!f->width) continue; float u = f->x / WH; float v = f->y / WH; float uw = f->width / WH; float vw = f->height / WH; float width = uw * scale, height = vw * scale; float xo = f->xoffset / WH * scale; float yo = f->yoffset / WH* scale; float left = dstx + xo, top = dsty - yo, right = dstx + width, bottom = dsty - yo - height; union { float color; int icolor; } un; un.icolor = icolor; float color = un.color; float letter[] = { left, top, u, v, color, right, top, u + uw, v, color, left, bottom, u, v + vw, color, left, bottom, u, v + vw, color, right, top, u + uw, v, color, right, bottom, u + uw, v + vw, color, }; Xe_VBPut(xe, letter, 6 * 5); dstx += f->xadvance / WH * scale; } struct XenosVertexBuffer *vb = Xe_VBEnd(xe); Xe_VBPoolAdd(xe, vb); Xe_SetSrcBlend(xe, XE_BLEND_SRCALPHA); Xe_SetDestBlend(xe, XE_BLEND_INVSRCALPHA); Xe_SetBlendOp(xe, XE_BLENDOP_ADD); Xe_SetShader(xe, SHADER_TYPE_PIXEL, sh_font_ps, 0); Xe_SetShader(xe, SHADER_TYPE_VERTEX, sh_font_vs, 0); Xe_SetTexture(xe, 0, XeFont); Xe_Draw(xe, vb, 0); return dstx; }
void osd_xenon_update_video(render_primitive_list &primlist) { //primlist->acquire_lock(); currList = &primlist; pre_render(); int minwidth, minheight; int newwidth, newheight; // get the minimum width/height for the current layout xenos_target->compute_minimum_size(minwidth, minheight); // minwidth = screen_width; // minheight = screen_height; // make that the size of our target xenos_target->set_bounds(minwidth, minheight); xenos_target->compute_visible_area(screen_width, screen_height, screen_width / screen_height, xenos_target->orientation(), newwidth, newheight); //ShaderEffects.at(2).Render(minwidth, minheight); ShaderEffects.at(0).Render(minwidth, minheight); Xe_SetStreamSource(g_pVideoDevice, 0, soft_vb, nb_vertices, sizeof (MameVerticeFormats)); vertices = (MameVerticeFormats *) Xe_VB_Lock(g_pVideoDevice, soft_vb, 0, 3 * sizeof (MameVerticeFormats), XE_LOCK_WRITE); //CreateRect(((float) newwidth / (float) screen_width), -((float) newheight / (float) screen_height), vertices); CreateRectHlsl(screen_width, screen_height, vertices); Xe_VB_Unlock(g_pVideoDevice, soft_vb); // update texture //draw32_draw_primitives(primlist, screen, minwidth, minheight, g_pTexture->wpitch / 4); /* loop over the list and render each element */ const render_primitive *prim; void *dstdata = (void *) screen; UINT32 width = minwidth; UINT32 height = minheight; UINT32 pitch = g_pTexture->wpitch / 4; /* for (prim = currList->first(); prim != NULL; prim = prim->next()) { switch (prim->type) { case render_primitive::LINE: draw32_draw_line(prim, dstdata, width, height, pitch); break; case render_primitive::QUAD: if (!prim->texture.base) draw32_draw_rect(prim, dstdata, width, height, pitch); else draw32_setup_and_draw_textured_quad(prim, dstdata, width, height, pitch); break; default: throw emu_fatalerror("Unexpected render_primitive type"); } } * */ software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(primlist, dstdata, width, height, pitch); Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE); Xe_Surface_Unlock(g_pVideoDevice, g_pTexture); // correct texture size g_pTexture->width = minwidth; g_pTexture->height = minheight; // draw Xe_SetTexture(g_pVideoDevice, 0, g_pTexture); Xe_DrawPrimitive(g_pVideoDevice, XE_PRIMTYPE_RECTLIST, 0, 1); render(); }