#include "StdAfx.h" #include "GUIFrame.h"

#include <stdlib.h> #include <atlstr.h> #include<cstdlib> #include"ASM_VectorAndMritx.h"

////////////////////////////////////////////// GUIFrame::GUIFrame(void) {  frameName = "";  width = 100.f;  height = 100.f;  PostionX = 0.f;  PostionY = 0.f;  isActive = FALSE;  isEnter = false; }

GUIFrame::~GUIFrame(void) {  Release(); }

void GUIFrame::Release() {

}

void GUIFrame::Updata() {  mouseInQued(); }

float GUIFrame::MouseToWordPositionX(float mouserPosition) {    return mouserPosition - (WIDTH * 0.5f); }

float GUIFrame::MouseToWordPositionY(float mouserPosition) {   return -(mouserPosition - HEIGHT * 0.5); }

bool GUIFrame::mouseInQued() {  lastMouserPosX = MouserPosX;  lastMouserPosY = MouserPosY;  frameName = frameName;  if((MouserPosX >= PostionX+ offset._41+word._41) && (MouserPosX <= (PostionX + offset._41 + word._41 + width)))  {   if (MouserPosY <= 0)   {     if ((MouserPosY <= PostionY + offset._42 + word._42) && (MouserPosY >= (PostionY + offset._42 + word._42 - height)))    {     isEnter = TRUE;     //OutputDebugString(frameName.c_str());

return true;    }    isEnter = false;   }   else   {    if ((MouserPosY <= PostionY + offset._42 + word._42) && (MouserPosY >= (PostionY + offset._42 + word._42 - height)))    {     isEnter = TRUE;     //OutputDebugString(frameName.c_str());

return true;    }     isEnter = false;   }   isEnter = false;   //OutputDebugString(frameName.c_str());  }  isEnter = false;  //OutputDebugString("nil /n");  return false; }

void GUIFrame::mouseMove(float x,float y) {  if (!isActive||!isLMouserDown||!isEnter)  {   isLMouserDown = false;   return;  }

word._41 += x;  word._42 += y; }

////////////////////////////////////////////// GUIFrame_Qued::GUIFrame_Qued() {   }

GUIFrame_Qued::~GUIFrame_Qued() {

}

void GUIFrame_Qued::Release() {  GUIFrame::Release(); }

void GUIFrame_Qued::Updata() {  GUIFrame::Updata(); }

void GUIFrame_Qued::SetDevice(LPDIRECT3DDEVICE9 device) {  Device = device; }

void GUIFrame_Qued::InitFrame(string Name,float Width,float Height,float Postion_x,float Postion_y,string imgName) {  frameName = Name;  width = Width;  height = Height;  PostionX = Postion_x;  PostionY = Postion_y;  D3DXMatrixIdentity(&word);  D3DXMatrixIdentity(&offset);  // 创建纹理  InitTextrue(imgName);

D3DXCreateBox(Device, 100, 100, 100, &mesh, NULL);

// 创建顶点缓存  Device->CreateVertexBuffer(24 * sizeof(CUSTOMVERTEX), 0,   D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVertexBuf, NULL);

// 填充顶点数据  CUSTOMVERTEX *pVertices = NULL;  g_pVertexBuf->Lock(0, 0, (void**)&pVertices, 0);

// 正面顶点数据  pVertices[0] = CUSTOMVERTEX(Postion_x, Postion_y, 0.0f, 0.0f, 0.0f);  pVertices[1] = CUSTOMVERTEX(Postion_x+ Width, Postion_y, 0.0f, 1.0f, 0.0f);  pVertices[2] = CUSTOMVERTEX(Postion_x, Postion_y- Height, 0.0f, 0.0f, 1.0f);  pVertices[3] = CUSTOMVERTEX(Postion_x + Width, Postion_y - Height, 0.0f, 1.0f, 1.0f);  g_pVertexBuf->Unlock();

// 创建索引缓存  Device->CreateIndexBuffer(36 * sizeof(WORD), 0,   D3DFMT_INDEX16, D3DPOOL_DEFAULT, &g_pIndexBuf, NULL);

// 填充索引数据  WORD *pIndices = NULL;  g_pIndexBuf->Lock(0, 0, (void**)&pIndices, 0);

// 正面索引数据  pIndices[0] = 0; pIndices[1] = 3; pIndices[2] = 1;  pIndices[3] = 0; pIndices[4] = 2; pIndices[5] = 3;  g_pIndexBuf->Unlock();

// 设置材质  D3DMATERIAL9 mtrl;  ::ZeroMemory(&mtrl, sizeof(mtrl));  mtrl.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);  mtrl.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);  mtrl.Specular = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);  Device->SetMaterial(&mtrl);

// 设置环境光漫反射环境光  Device->SetRenderState(D3DRS_AMBIENT, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f));

//// 设置取景变换矩阵  //D3DXMATRIX  matView;  //D3DXVECTOR3 vEye(0.0f, 0.0f, -1.0f);  //D3DXVECTOR3 vAt(0.0f, 0.0f, 0.0f);  //D3DXVECTOR3 vUp(0.0f, 1.0f, 0.0f);

//D3DXMatrixLookAtLH(&matView, &vEye, &vAt, &vUp);  //Device->SetTransform(D3DTS_VIEW, &matView);

// 设置投影变换矩阵写死得一半不会重复调用除非改变分辨率和切换平行投影和透视投影  D3DXMATRIX matProj, matOther;  //D3DXMatrixPerspectiveFovLH(&matProj, 3.3333333*0.25f, 1.0f, 0.0f, 1000.0f);  D3DXMatrixOrthoLH(&matOther, WIDTH, HEIGHT, -100.f, 100.f);  Device->SetTransform(D3DTS_PROJECTION, &matOther);

}

void GUIFrame_Qued::InitTextrue(string textrueName) {  TextrueName = textrueName;  g_pTexture = GImageManage::GetImageManage()->GetImage(textrueName);   }

void GUIFrame_Qued::Render()//把鼠标转成世界坐标 {  //这些类都在全局静态存储空间,不准跨站调用  //Device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);  Device->BeginScene();                     // 开始绘制    Device->SetTexture(0, g_pTexture);  //mesh->DrawSubset(0);  // 设置世界变换矩阵  //D3DXMATRIX matWorld;  //D3DXMatrixIdentity(&matWorld);  ////D3DXMatrixScaling(&matWorld, 0.4f, 0.4f, 0.4f);  //matWorld._41 = 2.0f;  //Device->SetTransform(D3DTS_WORLD, &matWorld);  //  //D3DXMATRIX T;  //D3DXMATRIX scale,rotation,transfrom;  //D3DXMatrixScaling(&scale, 0.5, 0.5, 0.5);  //D3DXMatrixRotationX(&rotation, 35);//角度  //D3DXMatrixRotationY(&rotation, -20);//角度  //D3DXMatrixRotationZ(&rotation, 0);//角度  //D3DXMatrixTranslation(&transfrom, 5.f, 2.f, 7.f);  //T = rotation * scale*transfrom;//旋转有次序,先旋转是模型自转,后旋转是绕没移动之前得坐标绕转  //D3DXMatrixIdentity(&word);//单位化zoro  //Device->SetTransform(D3DTS_WORLD, &T);

D3DXMATRIX T;  D3DXMatrixIdentity(&T);  //T = offset * word;  SSE_MatrixMultiplyMatrix(offset, word, T);//手感老好了特别滑   Device->SetTransform(D3DTS_WORLD, &T);

Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);  //// 渲染正方形  //Device->SetStreamSource(0, g_pVertexBuf, 0, sizeof(CUSTOMVERTEX));  //Device->SetFVF(D3DFVF_CUSTOMVERTEX);  //Device->SetIndices(g_pIndexBuf);  //Device->SetTexture(0, g_pTexture);  //Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);  if (isEnter)  {   Device->SetStreamSource(0, g_pVertexBuf, 0, sizeof(CUSTOMVERTEX));   Device->SetFVF(D3DFVF_CUSTOMVERTEX);   Device->SetIndices(g_pIndexBuf);   Device->SetTexture(0, g_pTexture);   Device->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 0, 4, 0, 2);  }  else  {   Device->SetStreamSource(0, g_pVertexBuf, 0, sizeof(CUSTOMVERTEX));   Device->SetFVF(D3DFVF_CUSTOMVERTEX);   Device->SetIndices(g_pIndexBuf);   Device->SetTexture(0, g_pTexture);   Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);

}  //D3DXMatrixIdentity(&matWorld);  //matWorld._41 = 0.0f;

//Device->SetTransform(D3DTS_WORLD, &matWorld);  //// 绘制立方体  //Device->SetStreamSource(0, g_pVertexBuf, 0, sizeof(CUSTOMVERTEX));  //Device->SetFVF(D3DFVF_CUSTOMVERTEX);  //Device->SetIndices(g_pIndexBuf);  //Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12);

//渲染函数不准夸栈调用  Device->EndScene();                       // 结束绘制  //Device->Present(NULL, NULL, NULL, NULL);  // 翻转 }

float GUIFrame_Qued::getXPosition() {  return offset._41 + word._41; }

float GUIFrame_Qued::getYPosition() {  return offset._42 + word._42; }

void GUIFrame_Qued::SetXOfset(float x) {  word._41 = x; }

void GUIFrame_Qued::SetYOfset(float y) {  word._42 = y; }

void GUIFrame_Qued::OnMsg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {

switch (message)  {  case WM_MOUSEMOVE:   MouserPosX = MouseToWordPositionX(LOWORD(lParam));   MouserPosY = MouseToWordPositionY(HIWORD(lParam));   mouseMove(MouserPosX-lastMouserPosX, MouserPosY- lastMouserPosY);   //OutputDebugString("sdaadsa\n");   break;  case WM_LBUTTONDOWN:   MouserPosX = MouseToWordPositionX(LOWORD(lParam));   MouserPosY = MouseToWordPositionY(HIWORD(lParam));   isLMouserDown = true;   //OutputDebugString("sdaadsa\n");   break;  case WM_LBUTTONUP:   isLMouserDown = false;      break;  }   }

GUIFrame * GUIFrame_Qued::CreateGUIFrame_Qued() {  return new GUIFrame_Qued; }

2D 加速图形界面开发源代码亲写 想买来学习得加qq 313244484 20万当前代码,完整400万包写完的更多相关文章

  1. JAVA与图形界面开发(Applet应用程序、AWT库、Swing)

    Applet 1)简单说,Applet就是嵌入到网页中的小程序,Java代码. 2)编写Applet程序,要继承JApplet类,并根据自己需要覆写相关方法(init.start.stop.destr ...

  2. Java GUI图形界面开发工具

    Applet 应用程序     一种可以在 Web 浏览器中执行的小程序,扩展了浏览器中的网页功能. 缺: 1.需要下载 Applet 及其相关文件 2.Applet 的功能是受限制的 优: 3.无需 ...

  3. JAVA 图形界面开发基础详解

    与C的win32一样,JAVA也有自己的图形界面开发,将在此篇博客中对基础部分进行讲解. 1.Java提供的图形界面类有哪些? Java提供了两套图形界面 (1)AWT组建(基础) AWT组件是jdk ...

  4. Java 图形界面开发--图文并茂建立学生管理系统

    (尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/50932501 冷血之心的博客) 图形用户界面(Graphics U ...

  5. Java Swing 图形界面开发(目录)

    Java Swing 图形界面开发(目录) 2017年05月30日 23:50:42 阅读数:5228 本文链接: http://blog.csdn.net/xietansheng/article/d ...

  6. Java Swing图形界面开发

    本文转自xietansheng的CSDN博客内容,这是自己见过的最通俗易懂.最适合快速上手做Java GUI开发的教程了,这里整合一下作为自己以后复习的笔记: 原文地址:https://blog.cs ...

  7. 只有20行Javascript代码!手把手教你写一个页面模板引擎

    http://www.toobug.net/article/how_to_design_front_end_template_engine.html http://barretlee.com/webs ...

  8. 微信公 众平台开发,用于个人技术交流,有兴趣的加QQ群432921500

    微信公 众平台开发,用于个人技术交流,有兴趣的加QQ群432921500

  9. python 图形界面开发

    用python来开发图形界面,确实不是很方便,没有c#,Java,甚至VB来得容易.几个控件拖拽,然后响应事件. 用python写脚本,或者web service来处理一般工作,绰绰有余.但有的时候, ...

随机推荐

  1. laravel——基础增删改查

    一.控制器代码 <?php namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; class CurdContro ...

  2. vue-router的简单理解

    Vue-router原理了解一下: 找到一篇文章,分析的很透彻 从vue-router看前端路由的两种实现,文章写的很好,看完这篇文章 ➕ 看源码应该可以理解,这里根据我浅显的理解概括一下: vue- ...

  3. TGCA数据的标准化以及差异分析--转载

    转载果子学生信  https://mp.weixin.qq.com/s/Ph1O6V5RkxkyrKpVmB5ODA 前面我们从GDC下载了TCGA肿瘤数据库的数据,也能够把GDC下载的多个TCGA文 ...

  4. transform:rotate3d/tranlate3d

    transform:rotate3d(x,y,z,angle); rotate3d 代表 在3D空间,元素沿着 经过原点(0,0,0) 和 三维坐标(x,y,z) 2点的直线进行旋转.其中: x:是一 ...

  5. Dva三种方式实现dispatch的Promise回调

    Dva2.0及以上版本 使用官方自带的Promise // 业务组件 e.g: Tags.js dispatch({ type: 'user/add', payload: {}, // 需要传递的信息 ...

  6. P2822 组合数问题

    传送门 思路: 利用公式: C( n,r ) = C( n-1,r ) + C( n-1,r-1 ) 由此可以将计算 C( n,r ) 的过程化为加法来做. 可以看出,C( n,r ) 其实就是求杨辉 ...

  7. Apache Solr入门教程(转)

    1.为什么选择Apache Solr Apache Solr是一个功能强大的搜索服务器,它支持REST风格API.Solr是基于Lucene的,Lucene 支持强大的匹配能力,如短语,通配符,连接, ...

  8. 【Redis】windows下redis服务的安装

    下载地址: https://github.com/MicrosoftArchive/redis/releases Redis 支持 32 位和 64 位.这个需要根据你系统平台的实际情况选择,这里我们 ...

  9. 【云短信】腾讯&阿里

    腾讯 : https://github.com/qcloudsms/qcloudsms_csharp 安装nuget包: using qcloudsms_csharp; using System.Co ...

  10. hadoop之数据压缩与数据格式

    * 注:本文原创,转载请注明出处,本人保留对未注明出处行为的责任追究. a.数据压缩 优点: 1.节省本地空间 2.节省带宽 缺点: 花时间 1.MR中允许进行数据压缩的地方有三个: 1)input起 ...