Slider::Slider(Rect slider_rect, float _minValue, float _maxValue, float _value, char* slider_id, SliderStyle *slider_style) { if(slider_style == NULL) style = &gDefaultSliderStyle; else style = slider_style; id = slider_id; rect = slider_rect; screenRect = rect; D3DVIEWPORT9 viewPort = gEngine->GetDriver()->GetViewPort(0); screenRect.TransLate(viewPort.X, viewPort.Y); minValue = _minValue; maxValue = _maxValue; value = _value; if(value < minValue) value = minValue; if(value > maxValue) value = maxValue; CreateVertexBuffer(); }
bool eae6320::Graphics::Mesh::LoadGraphicsMeshData() { o_direct3dDevice = eae6320::Graphics::GetLocalDirect3dDevice(); //o_vertexDeclaration = m_vertexDeclaration; //o_vertexBuffer = m_vertexBuffer; //o_indexBuffer = m_indexBuffer; //o_vertexData = m_vertexData; //o_indexData = m_indexData; //o_vertexCount = m_vertexCount; //o_indexCount = m_indexCount; if (!CreateVertexBuffer()) { return false; } if (!CreateIndexBuffer()) { return false; } return true; }
Application::Application() : window(new Window(1280, 720, L"testerata!")), device(new D3D12Device(*window)), frameQueueIndex(0) { // Create a command allocator for every inflight-frame for (int i = 0; i < D3D12Device::MAX_FRAMES_INFLIGHT; ++i) { if (FAILED(device->GetD3D12Device()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&commandAllocator[i])))) CRITICAL_ERROR("Failed to create command list allocator."); } // Create the command list. if (FAILED(device->GetD3D12Device()->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator[frameQueueIndex].Get(), pso.Get(), IID_PPV_ARGS(&commandList)))) CRITICAL_ERROR("Failed to create command list"); commandList->Close(); CreateRootSignature(); CreatePSO(); CreateVertexBuffer(); CreateTextures(); // Configure viewport and scissor rect. viewport.TopLeftX = 0.0f; viewport.TopLeftY = 0.0f; viewport.Width = static_cast<float>(window->GetWidth()); viewport.Height = static_cast<float>(window->GetHeight()); viewport.MinDepth = 0.0f; viewport.MaxDepth = 1.0f; scissorRect.left = 0; scissorRect.top = 0; scissorRect.right = static_cast<LONG>(window->GetWidth()); scissorRect.bottom = static_cast<LONG>(window->GetHeight()); }
void ParticleEmitterInstance::Initiate(ParticleEmitterData* someData, bool anAllowManyParticles) { myParticleEmitterData = someData; myEmitterPath = myParticleEmitterData->myFileName; int particleCount = static_cast<int>(myParticleEmitterData->myParticlesPerEmitt * myParticleEmitterData->myParticlesLifeTime / myParticleEmitterData->myEmissionRate) + 1; DL_DEBUG(("Loading :" + myEmitterPath).c_str()); DL_ASSERT_EXP(anAllowManyParticles == true || particleCount <= 201, "Can't have more than 201 particles in an emitter!"); myGraphicalParticles.Init(particleCount); myLogicalParticles.Init(particleCount); myEmissionTime = myParticleEmitterData->myEmissionRate; myDiffColor = (myParticleEmitterData->myData.myEndColor - myParticleEmitterData->myData.myStartColor) / myParticleEmitterData->myParticlesLifeTime; for (int i = 0; i < particleCount; ++i) { GraphicalParticle tempGraphics; myGraphicalParticles.Add(tempGraphics); LogicalParticle tempLogic; myLogicalParticles.Add(tempLogic); } myIsActive = myParticleEmitterData->myIsActiveAtStart; myShouldLive = myParticleEmitterData->myIsActiveAtStart; myEmitterLife = myParticleEmitterData->myEmitterLifeTime; CreateVertexBuffer(); }
void ProxyModel::Initialize() { // Load a compiled vertex shader std::string compiledVertexShader = Utility::LoadBinaryFile("Content\\Shaders\\BasicVS.cso"); Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreateVertexShader(&compiledVertexShader[0], compiledVertexShader.size(), nullptr, mVertexShader.ReleaseAndGetAddressOf()), "ID3D11Device::CreatedVertexShader() failed."); // Load a compiled pixel shader std::string compiledPixelShader = Utility::LoadBinaryFile("Content\\Shaders\\BasicPS.cso"); Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreatePixelShader(&compiledPixelShader[0], compiledPixelShader.size(), nullptr, mPixelShader.ReleaseAndGetAddressOf()), "ID3D11Device::CreatedPixelShader() failed."); // Create an input layout D3D11_INPUT_ELEMENT_DESC inputElementDescriptions[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreateInputLayout(inputElementDescriptions, ARRAYSIZE(inputElementDescriptions), &compiledVertexShader[0], compiledVertexShader.size(), mInputLayout.ReleaseAndGetAddressOf()), "ID3D11Device::CreateInputLayout() failed."); // Create constant buffers D3D11_BUFFER_DESC constantBufferDesc; ZeroMemory(&constantBufferDesc, sizeof(constantBufferDesc)); constantBufferDesc.ByteWidth = sizeof(mVertexCBufferPerObjectData); constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; Utility::ThrowIfFailed(mGame->GetD3DDevice()->CreateBuffer(&constantBufferDesc, nullptr, mVertexCBufferPerObject.ReleaseAndGetAddressOf()), "ID3D11Device::CreateBuffer() failed."); // Load a model std::unique_ptr<Model> model(new Model(*mGame, mModelFileName, true)); Mesh* mesh = model->Meshes().at(0); CreateVertexBuffer(mGame->GetD3DDevice(), *mesh, mVertexBuffer.ReleaseAndGetAddressOf()); mesh->CreateIndexBuffer(mIndexBuffer.ReleaseAndGetAddressOf()); mIndexCount = static_cast<UINT>(mesh->Indices().size()); }
bool Init() { Vector3f Pos(5.0f, 1.0f, -3.0f); Vector3f Target(0.0f, 0.0f, 1.0f); Vector3f Up(0.0, 1.0f, 0.0f); m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up); CreateVertexBuffer(); m_pEffect = new LightingTechnique(); if (!m_pEffect->Init()) { printf("Error initializing the lighting technique\n"); return false; } m_pEffect->Enable(); m_pEffect->SetTextureUnit(0); m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png"); if (!m_pTexture->Load()) { return false; } return true; }
void Allocate(ID3D11Device *device, const int meshCount, const int *verticesPerMesh, const int *indicesPerMesh) override { int totalVertexCount = 0; int totalIndexCount = 0; for (int i = 0; i < meshCount; ++i) { totalVertexCount += verticesPerMesh[i]; totalIndexCount += indicesPerMesh[i]; } CreateVertexBuffer(device, totalVertexCount); CreateIndexBuffer(device, totalIndexCount); int indexOffset = 0; int vertexOffset = 0; for (int i = 0; i < meshCount; ++i) { meshes_.emplace_back(std::unique_ptr<StaticMesh>( new StaticMesh(verticesPerMesh[i], indicesPerMesh[i], i))); meshes_[i]->vertexBuffer = vertexBuffer_; meshes_[i]->vertexBufferSRV = vertexBufferSRV_; meshes_[i]->indexBuffer = indexBuffer_; meshes_[i]->indexBufferSRV = indexBufferSRV_; meshes_[i]->indexOffset = indexOffset; indexOffset += indicesPerMesh[i] * sizeof(int); meshes_[i]->vertexOffset = vertexOffset; vertexOffset += verticesPerMesh[i] * 3 * sizeof(float); } CreateMeshConstantsBuffer(device); }
bool Init() { m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT); CreateVertexBuffer(); CreateIndexBuffer(); m_pEffect = new LightingTechnique(); if (!m_pEffect->Init()) { return false; } m_pEffect->Enable(); m_pEffect->SetTextureUnit(0); m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png"); if (!m_pTexture->Load()) { return false; } return true; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(800, 600); glutInitWindowPosition(100, 100); glutCreateWindow("Tutorial 09"); GLenum res = glewInit(); if (res != GLEW_OK) { fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res)); return 1; } glClearColor(0.8f, 0.3f, 0.1f, 1.0f); InitializeGlutCallbacks(); CreateVertexBuffer(); CompileShader(); glutMainLoop(); return 0; }
void BasicShapes::CreateCube( _Out_ ID3D11Buffer **vertexBuffer, _Out_ ID3D11Buffer **indexBuffer, _Out_opt_ unsigned int *vertexCount, _Out_opt_ unsigned int *indexCount ) { CreateVertexBuffer( ARRAYSIZE(cubeVertices), cubeVertices, vertexBuffer ); if (vertexCount != nullptr) { *vertexCount = ARRAYSIZE(cubeVertices); } CreateIndexBuffer( ARRAYSIZE(cubeIndices), cubeIndices, indexBuffer ); if (indexCount != nullptr) { *indexCount = ARRAYSIZE(cubeIndices); } }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(1024, 768); glutInitWindowPosition(100, 100); glutCreateWindow("Tutorial 02"); InitializeGlutCallbacks(); // Must be done after glut is initialized! GLenum res = glewInit(); if (res != GLEW_OK) { fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res)); return 1; } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); CreateVertexBuffer(); glutMainLoop(); return 0; }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutInitWindowPosition(100, 100); glutCreateWindow("Homework 3: camera"); glutGameModeString("1280x1024@32"); glutEnterGameMode(); InitializeGlutCallbacks(); pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT); GLenum res = glewInit(); if (res != GLEW_OK) { fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res)); return 1; } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); CreateVertexBuffer(); CreateIndexBuffer(); CompileShaders(); glutMainLoop(); return 0; }
void Initialize() { RenderContext& rc = GlobalRenderContext; glswInit(); glswSetPath("../", ".glsl"); glswAddDirectiveToken("GL3", "#version 130"); rc.VertexBuffer = CreateVertexBuffer(); rc.IndexBuffer = CreateIndexBuffer(); #if defined(__APPLE__) rc.ToonHandle = BuildProgram("Toon.Vertex.GL2", "Toon.Fragment.GL2"); #else rc.ToonHandle = BuildProgram("Toon.Vertex.GL3", "Toon.Fragment.GL3"); #endif rc.ToonUniforms.Projection = glGetUniformLocation(rc.ToonHandle, "Projection"); rc.ToonUniforms.Modelview = glGetUniformLocation(rc.ToonHandle, "Modelview"); rc.ToonUniforms.NormalMatrix = glGetUniformLocation(rc.ToonHandle, "NormalMatrix"); rc.ToonUniforms.LightPosition = glGetUniformLocation(rc.ToonHandle, "LightPosition"); rc.ToonUniforms.AmbientMaterial = glGetUniformLocation(rc.ToonHandle, "AmbientMaterial"); rc.ToonUniforms.DiffuseMaterial = glGetUniformLocation(rc.ToonHandle, "DiffuseMaterial"); rc.ToonUniforms.SpecularMaterial = glGetUniformLocation(rc.ToonHandle, "SpecularMaterial"); rc.ToonUniforms.Shininess = glGetUniformLocation(rc.ToonHandle, "Shininess"); glEnable(GL_DEPTH_TEST); const float S = 0.46f; const float H = S * ViewportHeight / ViewportWidth; rc.Projection = mat4::Frustum(-S, S, -H, H, 4, 10); }
//-----------------------------------------------------------------------------// // load mesh, bone, material file //-----------------------------------------------------------------------------// SBMMLoader* CFileLoader::LoadModel( char *szFileName ) { ModelItor itor = s_ModelMap.find( szFileName ); if( s_ModelMap.end() != itor ) { SBMMLoader *p = (SBMMLoader*)itor->second.pItem; // Skinning Animation의 경우 모델마다 VertexBuffer를 생성해야 한다. // VertexBuffer 를 생성한다. if( ANI_SKIN == p->type ) CreateVertexBuffer( (SBMMLoader*)itor->second.pItem ); return (SBMMLoader*)itor->second.pItem; } // binary파일이 있다면 그것을 로드한다. // binary파일은 같은 파일명에서 확장자만(.bmm) 바뀐다. char binfile[ MAX_PATH]; strcpy( binfile, szFileName ); strcpy( &binfile[ strlen(binfile)-3], "bmm" ); SMapItem item; ZeroMemory( &item, sizeof(item) ); if( PathFileExists(binfile) ) { // binary파일이 있다면 그것을 로드한다. item.eType = MT_LINEAR; item.pItem = (BYTE*)LoadBMM_Bin( binfile ); if( !item.pItem ) return FALSE; s_ModelMap.insert( ModelMap::value_type(szFileName,item) ); } else { // binary파일이 없다면, binary파일을 생성한다. item.eType = MT_TREE; item.pItem = (BYTE*)LoadBMM_GPJ( szFileName ); if( !item.pItem ) return FALSE; s_ModelMap.insert( ModelMap::value_type(szFileName,item) ); // WriteScripttoBinary_Model( (SBMMLoader*)item.pItem, binfile ); } ModifyTextureFilename( &((SBMMLoader*)item.pItem)->mtrl ); // VertexBuffer, IndexBuffer를 생성한다. CreateVertexBuffer( (SBMMLoader*)item.pItem ); CreateIndexBuffer( (SBMMLoader*)item.pItem ); return (SBMMLoader*)item.pItem; }
void Material::CreateVertexBuffer(ID3D11Device* direct3d_device, const Model& model, std::vector<ID3D11Buffer*>& vertex_buffers) const { vertex_buffers.reserve(model.Meshes().size()); for (Mesh* mesh : model.Meshes()) { ID3D11Buffer* vertex_buffer; CreateVertexBuffer(direct3d_device, *mesh, &vertex_buffer); vertex_buffers.push_back(vertex_buffer); } }
void Cuboid::CreateVertexBuffer(void) { const float height = 6.0f; const float depth = 2.0f; const float width = 2.0f; CreateVertexBuffer(width/2.0f, height/2.0f, depth/2.0f); }
LPDIRECT3DVERTEXBUFFER9 CreateVertexBuffer( LPDIRECT3DDEVICE9 device, OvBufferSPtr buffer ) { if ( buffer ) { return CreateVertexBuffer( device, buffer->Pointer(), buffer->Size() ); } return NULL; }
////////////////////////////////////////////////////////////////////// // Construction/Destruction //////////////////////////////////////////////////////////////////// CPanel::CPanel(DWORD dwColour) { m_pVertexBuffer = NULL; m_pD3DDevice=g_pGame->GetDevice(); m_dwColour = dwColour; CreateVertexBuffer(); }
bool D3D10Model::CreateResources(ID3D10Device* pdev) { if (!CreateInputLayout(pdev)) return false; if (!CreateVertexBuffer(pdev)) return false; if (!CreateIndexBuffer(pdev)) return false; return true; }
void Mesh::Build(VertexType type) { vertexType = type; switch(vertexType){ case XYZ: sizeofVertex = 12; vertexData = positionData; break; case XYZ_UV: sizeofVertex = 20; vertexData = new VertexUV[numVertices]; for(int i = 0; i < numVertices; ++i){ VertexUV vert = VertexUV(positionData[i].x, positionData[i].y, positionData[i].z, uvData[i].x, uvData[i].y); ((VertexUV*)vertexData)[i] = vert; } break; case XYZ_N: sizeofVertex = 24; vertexData = new VertexN[numVertices]; for(int i = 0; i < numVertices; ++i){ VertexN vert = VertexN(positionData[i].x, positionData[i].y, positionData[i].z, normalData[i].x, normalData[i].y, normalData[i].z); ((VertexN*)vertexData)[i] = vert; } break; case XYZ_UV_N: sizeofVertex = 32; vertexData = new VertexUVN[numVertices]; for(int i =0; i < numVertices; ++i){ VertexUVN vert = VertexUVN(positionData[i].x, positionData[i].y, positionData[i].z, uvData[i].x, uvData[i].y, normalData[i].x, normalData[i].y, normalData[i].z); ((VertexUVN*)vertexData)[i] = vert; } break; case XYZ_UV_TBN: sizeofVertex = 56; vertexData = new VertexUVTBN[numVertices]; for(int i =0; i < numVertices; ++i){ VertexUVTBN vert = VertexUVTBN(positionData[i].x, positionData[i].y, positionData[i].z, uvData[i].x, uvData[i].y, tangentData[i].x, tangentData[i].y, tangentData[i].z, bitangentData[i].x, bitangentData[i].y, bitangentData[i].z, normalData[i].x, normalData[i].y, normalData[i].z); ((VertexUVTBN*)vertexData)[i] = vert; } break; } CreateVertexBuffer(numVertices); CreateIndexBuffer(3*numTriangles); CalculateBoundingBox(); }
Arrow* Arrow::init() { auto device = ShaderDevise::device(); _start = D3DXVECTOR3(0, 2, 0); _end = D3DXVECTOR3( 0, -2, 0); if(vbuf == NULL) device->CreateVertexBuffer(sizeof(CUSTOMVERTEX)*4, D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &vbuf, NULL); updateBuffer(); return this; }
void MyWindow::initialize() { CreateVertexBuffer(); initShaders(); initMatrices(); //mRotationMatrixLocation = mProgram->uniformLocation("RotationMatrix"); glFrontFace(GL_CCW); glEnable(GL_DEPTH_TEST); }
Menu::Menu(const char* url) : mWebView(0) , mPosX(0) , mPosY(0) , mWidth(0) , mHeight(0) , mViewLoaded(false) , mURL(url) , mVertexBuffer(0) , mStateBlock(0) , mFrameCount(0) { static bool sbWebCoreInitilized = false; // Initialize once the Awesomium web core if ( !sbWebCoreInitilized ) { // TODO: Move Awesomium to a separate core awe_webcore_initialize( true, true, false, awe_string_empty(), awe_string_empty(), awe_string_empty(), awe_string_empty(), awe_string_empty(), AWE_LL_NORMAL, false, awe_string_empty(), true, awe_string_empty(), awe_string_empty(), awe_string_empty(), awe_string_empty(), awe_string_empty(), awe_string_empty(), false, 0, false, false, awe_string_empty() ); awe_webcore_set_base_directory( AweString("Menus/") ); sbWebCoreInitilized = true; } // Get the screen dimension const VCNPoint& screenRes = VCNRenderCore::GetInstance()->GetResolution(); mWidth = screenRes.x; mHeight = screenRes.y; VCN_ASSERT(mWidth != 0 && mHeight != 0); // Create the web view mWebView = awe_webcore_create_webview(mWidth, mHeight, false); ASSERT(mWebView && "Failed to create web view"); // Map this view to recover in callbacks. sViewMap[mWebView] = this; // Load initial view awe_webview_load_file( mWebView, AweString(mURL.c_str()), awe_string_empty() ); awe_webview_set_callback_js_callback( mWebView, OnCallbackHandler ); awe_webview_set_callback_finish_loading( mWebView, OnFinishLoadingHandler ); // Preserve transparency (for the HUD) awe_webview_set_transparent(mWebView, true); // Always create a Native object to call native functions from javascript. awe_webview_create_object( mWebView, AweString("Native") ); CreateTexture(); CreateStateBlock(); CreateVertexBuffer(); }
void Tree::Initialize(ID3D10Device* lDevice, D3DXVECTOR4 lPosition) { mDevice = lDevice; mShaderObject->Initialize(lDevice, "FX/Tree.fx", D3D10_SHADER_ENABLE_STRICTNESS); mShaderObject->AddTechniqueByName(BillboardVertexDescription, BillboardVertexInputLayoutNumElements, "DrawTech"); mShaderObject->SetResource("tex2D", ResourceLoader::GetResourceLoader()->GetTreeTexture()); mShaderObject->SetTechniqueByInteger(0); CreateVertexBuffer(1, lPosition); D3DXMatrixIdentity(&mWorldMatrix); }
void D3D10System::Init() { VBData *data = new VBData; data->UVList.SetSize(1); data->VertList.SetSize(4); data->UVList[0].SetSize(4); spriteVertexBuffer = CreateVertexBuffer(data, FALSE); //------------------------------------------------------------------ data = new VBData; data->VertList.SetSize(5); boxVertexBuffer = CreateVertexBuffer(data, FALSE); //------------------------------------------------------------------ GraphicsSystem::Init(); }
void OSGFPlane::InitVertices() { float x = 34000000.0f; Vertex vertices[] = { {D3DXVECTOR3(-1.0f*x, 0, -1.0f*x), D3DXVECTOR3(0,0,0),D3DXVECTOR3(0,1,0)}, {D3DXVECTOR3(-1.0f*x, 0, 1.0f*x), D3DXVECTOR3(0,1,0),D3DXVECTOR3(0,1,0)}, {D3DXVECTOR3(1.0f*x, 0, 1.0f*x), D3DXVECTOR3(1,1,0),D3DXVECTOR3(0,1,0)}, {D3DXVECTOR3(1.0f*x, 0, -1.0f*x), D3DXVECTOR3(1,0,0),D3DXVECTOR3(0,1,0)} }; CreateVertexBuffer(vertices,sizeof(vertices),sizeof(Vertex)); }
//------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ bool Sprite3D::init() { auto renderer = App::instance().getRenderer(); auto pDevice = renderer->getDevice(); // 頂点作成 if(FAILED(pDevice->CreateVertexBuffer( sizeof(VERTEX_3D) * 4, D3DUSAGE_WRITEONLY, NULL, D3DPOOL_MANAGED, &_vtxBuff, NULL ))) { return false; } //頂点バッファ VERTEX_3D *pVtx = nullptr; //位置更新 _vtxBuff->Lock(0,0,(void **)&pVtx,0); pVtx[0].vtx = D3DXVECTOR3(-0.5f,0.5f,0.f); pVtx[1].vtx = D3DXVECTOR3(0.5f,0.5f,0.f); pVtx[2].vtx = D3DXVECTOR3(-0.5f,-0.5f,0.f); pVtx[3].vtx = D3DXVECTOR3(0.5f,-0.5f,0.f); pVtx[0].nor = D3DXVECTOR3(0,0,-1); pVtx[1].nor = D3DXVECTOR3(0,0,-1); pVtx[2].nor = D3DXVECTOR3(0,0,-1); pVtx[3].nor = D3DXVECTOR3(0,0,-1); pVtx[0].tex = D3DXVECTOR2(0,0); pVtx[1].tex = D3DXVECTOR2(1,0); pVtx[2].tex = D3DXVECTOR2(0,1); pVtx[3].tex = D3DXVECTOR2(1,1); _vtxBuff->Unlock(); // 頂点 pDevice->CreateVertexDeclaration(vElement,&_p3DDec); // シェーダ _vtxShaderID = renderer->getShader()->getVtxShader("vs_model.cso"); // 色 _color = D3DXCOLOR(1,1,1,1); // 色々初期化 _numU = 1; _numV = 1; _animID = 0; _texPos = {0,0}; _texScl = {1.f,1.f}; return true; }
HRESULT MeshSphere::Init(LPDIRECT3DDEVICE9 pDevice) { HRESULT result = Mesh::Init(pDevice); int vertexInRowCount = m_levelCount + 1 + 2; int vertexCount = vertexInRowCount * m_levelCount; // Initialize three vertices for rendering a triangle CUSTOMVERTEX * g_Vertices = new CUSTOMVERTEX[vertexCount]; for (int j = 0; j < m_levelCount; ++j) { for (int i = 0; i < m_levelCount + 1; ++i) { g_Vertices[vertexInRowCount * j + i] = GetVertexOnSphere(i, m_levelCount, j, m_levelCount); } // Добавляем вершины для вырожденных треугольников g_Vertices[vertexInRowCount * j + (m_levelCount + 1 + 0)] = g_Vertices[vertexInRowCount * j + (m_levelCount + 0)]; // Последний раз добавлять не нужно if (j < m_levelCount - 1) { g_Vertices[vertexInRowCount * j + (m_levelCount + 1 + 1)] = GetVertexOnSphere(0, m_levelCount, j + 1, m_levelCount); } else { g_Vertices[vertexInRowCount * j + (m_levelCount + 1 + 1)] = g_Vertices[vertexInRowCount * j + (m_levelCount + 0)]; } } int indexCount = (m_levelCount - 1) * vertexInRowCount * 2; int * g_Indices = new int[indexCount]; for (int j = 0; j < (m_levelCount - 1); ++j) { for (int i = 0; i < vertexInRowCount; ++i) { g_Indices[j * vertexInRowCount * 2 + i * 2 + 0] = j * vertexInRowCount + i; g_Indices[j * vertexInRowCount * 2 + i * 2 + 1] = j * vertexInRowCount + vertexInRowCount + i; } } result &= CreateVertexBuffer(g_Vertices, sizeof(CUSTOMVERTEX) * vertexCount, vertexCount, D3DFVF_CUSTOMVERTEX); result &= CreateIndexBuffer (g_Indices, sizeof(int) * indexCount, indexCount, D3DPT_TRIANGLESTRIP); delete g_Indices; delete g_Vertices; return result; }
void MyWindow::initialize() { CreateVertexBuffer(); initShaders(); pass1Index = mFuncs->glGetSubroutineIndex( mProgram->programId(), GL_FRAGMENT_SHADER, "pass1"); pass2Index = mFuncs->glGetSubroutineIndex( mProgram->programId(), GL_FRAGMENT_SHADER, "pass2"); pass3Index = mFuncs->glGetSubroutineIndex( mProgram->programId(), GL_FRAGMENT_SHADER, "pass3"); initMatrices(); setupFBO(); glFrontFace(GL_CCW); glEnable(GL_DEPTH_TEST); }
bool Init() { CreateVertexBuffer(); m_pEffect = new ShaderTechnique(); m_pEffect->Enable(); if (!m_pEffect->Init()){ printf("Error initializing the lighting technique\n"); return false; } m_pEffect->Enable(); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0); return true; }