/* * Reagiert auf Spielfenstergrößenänderung * * @author Divan */ void Desktop::Msg_ScreenResize(const ScreenResizeEvent& sr) { // Keep the following block the same as in ctrlGroup class: // Für skalierte Desktops ist alles einfach, die brauchen im besten Fall gar nichts selbst implementieren if (scale_) { //Zunächst an die Kinder weiterleiten for(std::map<unsigned int, Window*>::iterator it = childIdToWnd_.begin(); it != childIdToWnd_.end(); ++it) if(it->second) { Window* ctrl = it->second; // unskalierte Position und Größe bekommen unsigned realx = ctrl->GetX() * 800 / sr.oldWidth; unsigned realy = ctrl->GetY() * 600 / sr.oldHeight; unsigned realwidth = ctrl->GetWidth() * 800 / sr.oldWidth; unsigned realheight = ctrl->GetHeight() * 600 / sr.oldHeight; // Rundungsfehler? if (realx * sr.oldWidth / 800 < ctrl->GetX()) ++realx; if (realy * sr.oldHeight / 600 < ctrl->GetY()) ++realy; if (realwidth * sr.oldWidth / 800 < ctrl->GetWidth()) ++realwidth; if (realheight * sr.oldHeight / 600 < ctrl->GetHeight()) ++realheight; // Und los ctrl->Move(realx * sr.newWidth / 800, realy * sr.newHeight / 600); ctrl->Msg_ScreenResize(sr); ctrl->Resize(realwidth * sr.newWidth / 800, realheight * sr.newHeight / 600); } } // Individuelle Reaktion ist auch erlaubt Resize(sr.newWidth, sr.newHeight); }
void Graphics::RenderScreen() { Window * window = Application::GetDefaultWindow(); GLsizei width = (GLsizei)((Float32)window->GetWidth() * 0.35f); GLsizei height = (GLsizei)((Float32)window->GetHeight() * 0.35f); glViewport(0, window->GetHeight() - height, width,height ); Pointer<Mesh> mesh = m_PostProcessMesh; Matrix4x4 identity = Matrix4x4::Identity(); DisableState(GraphicsState::CullFace); DisableState(GraphicsState::DepthTesting); DisableState(GraphicsState::Blending); Pointer<Shader> shader = m_DebugShader; Pointer<Texture> texture = m_PostProcessMaterial->GetTexture(); Pointer<RenderTexture> renderTexture = Pointer<RenderTexture>::Null(); if (texture.IsAlive()) { renderTexture = texture.Cast<RenderTexture>(); } if (!shader.IsAlive() || !mesh.IsAlive() || !mesh->IsUploaded()) { return; } if (!shader->UseShader()) { return; } BindBuffer(BufferTarget::Array, mesh->GetVBO()); BindBuffer(BufferTarget::ElementArray, mesh->GetIBO()); GLint a_Position = shader->GetAttributeLocation("a_Position"); GLint a_TextureCoordinate = shader->GetAttributeLocation("a_TexCoords"); GLint u_MVP = shader->GetUniformLocation("u_MVP"); GLint u_Texture = shader->GetUniformLocation("u_Texture"); EnableVertexAttrib(a_Position, 3, VERTEX_ATTRIB(position)); EnableVertexAttrib(a_TextureCoordinate, 2, VERTEX_ATTRIB(texCoord)); SetMatrix(u_MVP, identity); SetTexture(u_Texture, 0, renderTexture); //SetTexture(u_Texture,0, texture); //glDrawElements((GLenum)PrimitiveMode::TriangleFans, mesh->GetIndexCount(), GL_UNSIGNED_SHORT, 0); glDrawArrays((GLenum)PrimitiveMode::TriangleFans, 0, 4); DisableVertexAttrib(a_Position); DisableVertexAttrib(a_TextureCoordinate); BindBuffer(BufferTarget::Array, 0); BindBuffer(BufferTarget::ElementArray, 0); }
void Texture::Update(const Window& window, unsigned int x, unsigned int y) { assert(x + window.GetWidth() <= myWidth); assert(y + window.GetHeight() <= myHeight); if (myTexture && window.SetActive(true)) { // Copy pixels from the back-buffer to the texture GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, window.GetWidth(), window.GetHeight())); myPixelsFlipped = true; } }
void Texture::Update(const Window& window, unsigned int x, unsigned int y) { assert(x + window.GetWidth() <= myWidth); assert(y + window.GetHeight() <= myHeight); if (myTexture && window.SetActive(true)) { // Make sure that the current texture binding will be preserved priv::TextureSaver save; // Copy pixels from the back-buffer to the texture GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, window.GetWidth(), window.GetHeight())); myPixelsFlipped = true; myCacheId = GetUniqueId(); } }
//Draws the excisting map on the screen void Map::Draw(Window screen, int completedLvl) { unsigned int drawings = 0; const char* charline; //For optimization, only draws the tiles that you can see on the screen unsigned int Y1, Y2, X1, X2; Y1 = (int)(_mapPosition.Y/_tileDimension.Y); Y2 = (int)((_mapPosition.Y+screen.GetHeight())/_tileDimension.Y)+1; X1 = (int)(_mapPosition.X/_tileDimension.X); X2 = (int)((_mapPosition.X+screen.GetWidth())/_tileDimension.X)+1; unsigned int newCharCounter = 0; for(unsigned int y = 0; y < _mapArray.size(); y++) { charline = _mapArray.at(y).c_str(); for(unsigned int x = 0; x < strlen(charline); x++) { if(_tileLibrary.count(charline[x]) != 0 && charline[x] != _spawnLocation) { TileData td = _tileLibrary.find(charline[x])->second; if(charline[x] == _newMapChar && completedLvl >= 0 && _locked){ if(newCharCounter < _newMapId.size() ){ if(_newMapId[newCharCounter] > completedLvl+1){ std::stringstream ss;ss<<_newMapCharClosed; _mapArray[y].replace(x, 1, ss.str()); td = _tileLibrary.find(_newMapCharClosed)->second; } } } if(y >= Y1 && y <= Y2 && x >= X1 && x <= X2){ if(td.IsDrawable()) _tileSheet->SetTransparency(100); else _tileSheet->SetTransparency(255); SDL_Rect clip = td.Rect(); //SDL_Rect offset = {(Uint16)(x * _tileDimension.X - _mapPosition.X), (Uint16)(y * _tileDimension.Y - _mapPosition.Y), clip.w, clip.h}; //SDL_BlitSurface(_tileSheet, &clip, screen, &offset); _tileSheet->Draw(screen, (Uint32)(x * _tileDimension.X - _mapPosition.X), (Uint32)(y * _tileDimension.Y - _mapPosition.Y), &clip); } if(td.IsDrawable()){ if(_drawObjects.size() > drawings){ if(y >= Y1 && y <= Y2 && x >= X1 && x <= X2) _drawObjects.at(drawings).Draw(screen); } else { _drawObjects.push_back(DrawingObject(_tileDimension.X, _tileDimension.Y, x*_tileDimension.X-_mapPosition.X, y*_tileDimension.Y-_mapPosition.Y)); if(y >= Y1 && y <= Y2 && x >= X1 && x <= X2) _drawObjects.at(drawings).Draw(screen); } drawings++; } if(charline[x] == _newMapChar || charline[x] == _newMapCharClosed) newCharCounter++; } } } }
void InputSystem::ForceCursorToCenter() { Window* mainWindow = Environment::GetSingleton().GetApplication()->GetMainWindow(); mLastMousePos.X() = mainWindow->GetWidth() / 2; mLastMousePos.Y() = mainWindow->GetHeight() / 2; mainWindow->ForceMouseToCenter(); }
RenderingEngine::RenderingEngine(const Window& window) : m_plane(Mesh("plane.obj")), m_window(&window), m_tempTarget(window.GetWidth(), window.GetHeight(), 0, GL_TEXTURE_2D, GL_NEAREST, GL_RGBA, GL_RGBA, false, GL_COLOR_ATTACHMENT0), m_planeMaterial("renderingEngine_filterPlane", m_tempTarget, 1, 8), m_defaultShader("forward-ambient"), m_shadowMapShader("shadowMapGenerator"), m_nullFilter("filter-null"), m_gausBlurFilter("filter-gausBlur7x1"), m_fxaaFilter("filter-fxaa"), m_altCameraTransform(Vector3f(0,0,0), Quaternion(Vector3f(0,1,0),ToRadians(180.0f))), m_altCamera(Matrix4f().InitIdentity(), &m_altCameraTransform) { SetSamplerSlot("diffuse", 0); SetSamplerSlot("normalMap", 1); SetSamplerSlot("dispMap", 2); SetSamplerSlot("shadowMap", 3); SetSamplerSlot("roughMap", 4); SetSamplerSlot("filterTexture", 0); SetVector3f("ambient", Vector3f(0.2f, 0.2f, 0.2f)); SetFloat("fxaaSpanMax", 8.0f); SetFloat("fxaaReduceMin", 1.0f/128.0f); SetFloat("fxaaReduceMul", 1.0f/8.0f); SetFloat("fxaaAspectDistortion", 150.0f); SetTexture("displayTexture", Texture(m_window->GetWidth(), m_window->GetHeight(), 0, GL_TEXTURE_2D, GL_LINEAR, GL_RGBA, GL_RGBA, true, GL_COLOR_ATTACHMENT0)); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); //glEnable(GL_DEPTH_CLAMP); //glEnable(GL_MULTISAMPLE); //glEnable(GL_FRAMEBUFFER_SRGB); //m_planeMaterial("renderingEngine_filterPlane", m_tempTarget, 1, 8); m_planeTransform.SetScale(1.0f); m_planeTransform.Rotate(Quaternion(Vector3f(1,0,0), ToRadians(90.0f))); m_planeTransform.Rotate(Quaternion(Vector3f(0,0,1), ToRadians(180.0f))); for(int i = 0; i < NUM_SHADOW_MAPS; i++) { int shadowMapSize = 1 << (i + 1); m_shadowMaps[i] = Texture(shadowMapSize, shadowMapSize, 0, GL_TEXTURE_2D, GL_LINEAR, GL_RG32F, GL_RGBA, true, GL_COLOR_ATTACHMENT0); m_shadowMapTempTargets[i] = Texture(shadowMapSize, shadowMapSize, 0, GL_TEXTURE_2D, GL_LINEAR, GL_RG32F, GL_RGBA, true, GL_COLOR_ATTACHMENT0); } m_lightMatrix = Matrix4f().InitScale(Vector3f(0,0,0)); }
Error::E RenderSystem::CreateSwapChain(const Window &window) { assert(_device); _swapDesc = kDefaultSwapDesc; _swapDesc.SampleDesc.Count = 4; _swapDesc.SampleDesc.Quality = _msaaQualityLevel - 1; _swapDesc.OutputWindow = window.GetHandle(); _swapDesc.BufferDesc.Width = window.GetWidth(); _swapDesc.BufferDesc.Height = window.GetHeight(); IDXGIFactory *factory = FactoryFromDevice(_device); DEBUG_HR(factory->CreateSwapChain(_device, &_swapDesc, &_swapChain)); ReleaseCom(factory); return Error::OK; }
Error::E RenderSystem::Initialize(const Window &window) { Error::E err = Error::OK; err = CreateDeviceAndContext(); if (err != Error::OK) { FreeResources(); return err; } err = CreateSwapChain(window); if (err != Error::OK) { FreeResources(); return err; } ID3D11Texture2D *backBuffer; DEBUG_HR(_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer))); DEBUG_HR(_device->CreateRenderTargetView(backBuffer, NULL, &_renderTargetView)); ReleaseCom(backBuffer); err = CreateDepthStencilBuffer(); if (err != Error::OK) { FreeResources(); return err; } _context->OMSetRenderTargets(1, &_renderTargetView, _depthStencilView); D3D11_VIEWPORT vp; vp.TopLeftX = 0; vp.TopLeftY = 0; vp.Width = (float)window.GetWidth(); vp.Height = (float)window.GetHeight(); vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; _context->RSSetViewports(1, &vp); _initOk = true; return Error::OK; }
int main() { try { ImageLoaders::PNG loader; if (!loader.CanLoad("resources/logo.png")) { throw FatalException("Cannot load PNG images."); } Image* image = loader.Load("resources/logo.png"); WindowStyle style; style.title = U8("logo.png (") + image->GetWidth() + U8(", ") + image->GetHeight() + U8(")"); style.width = image->GetWidth(); style.height = image->GetHeight(); style.backgroundColor = Colors::black; style.resizable = false; Window window; window.Create(style); OpenGL::Context context; context.Create(&window); GL::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL::Enable(GL_BLEND); GL::Enable(GL_ALPHA_TEST); GL::Enable(GL_TEXTURE_2D); UInt program = LoadShader(U8("resources/shader.vert"), U8("resources/shader.frag")); UInt box = MakeBox(); UInt texture; GL::GenTextures(1, &texture); GL::BindTexture(GL_TEXTURE_2D, texture); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GL::TexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); GL::PixelStorei(GL_UNPACK_ALIGNMENT, 1); GL::TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->GetWidth(), image->GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image->GetData()); GL::BindTexture(GL_TEXTURE_2D, 0); Timer timer; Float32 hue = 0.0f; while (window.IsOpen()) { Timer::Sleep(1); hue = Math::Mod(hue + timer.GetDeltaTime() * 45, 360.0f); context.ClearColor(Color::MakeHSL(hue, 40, 255)); context.Viewport(0, 0, window.GetWidth(), window.GetHeight()); context.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT); GL::UseProgram(program); GL::UniformMatrix4fv(GL::GetUniformLocation(program, "orthoMatrix"), 1, false, Matrix::MakeOrtho(0, 1, 1, 0).GetData()); GL::UniformMatrix4fv(GL::GetUniformLocation(program, "modelMatrix"), 1, false, Matrix::Identity().GetData()); GL::Uniform1i(GL::GetUniformLocation(program, "texture"), 0); GL::ActiveTexture(GL_TEXTURE0); GL::BindTexture(GL_TEXTURE_2D, texture); GL::BindVertexArray(box); GL::DrawArrays(GL_QUADS, 0, 4); GL::BindVertexArray(0); GL::UseProgram(0); context.SwapBuffers(); Window::Update(); } } catch (Exception& e) { std::cout << e.what() << std::endl; std::cout << std::hex << "Error code: 0x" << e.unique << std::dec << " (decimal " << e.unique << ")" << std::endl; } }
int main() { try { Image image; image.Load("resources/jattabox.png"); WindowStyle style; style.title = U8("CGUL - 3D World"); style.size = UCoord32(640, 480); style.backgroundColor = Colors::black; style.resizable = true; Window window; window.Create(style); OpenGL::Context context; context.Create(&window); GL::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL::Enable(GL_BLEND); GL::Enable(GL_ALPHA_TEST); GL::Enable(GL_TEXTURE_2D); GL::Enable(GL_DEPTH_TEST); GL::Enable(GL_CULL_FACE); glCullFace(GL_BACK); UIntN program = LoadShader(U8("resources/shader.vert"), U8("resources/shader.frag")); UIntN box = MakeBox(); UIntN texture; GL::GenTextures(1, &texture); GL::BindTexture(GL_TEXTURE_2D, texture); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); GL::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GL::TexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); GL::PixelStorei(GL_UNPACK_ALIGNMENT, 1); GL::TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.GetWidth(), image.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.GetData< void >()); GL::BindTexture(GL_TEXTURE_2D, 0); Timer timer; Float32 hue = 0.0f; while (window.IsOpen()) { Float32 deltaTime = timer.GetDeltaTime(); Timer::Sleep(1); hue = Math::Mod(hue + deltaTime * 0.125f, 1.0f); context.ClearColor(Color::MakeHSV(hue, 0.156862745098039f, 1.0f)); Float32 movement = 1 + Math::Cos(hue / 10.0f); static Float32 rot = 0; rot += deltaTime / 1.0f; context.Viewport(0, 0, window.GetWidth(), window.GetHeight()); context.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT); GL::UseProgram(program); //GL::UniformMatrix4fv(GL::GetUniformLocation(program, "orthoMatrix"), 1, false, Matrix::MakeOrtho2D(0, 1280, 768, 0).GetData()); MatrixF view = MatrixF::MakeLookAt(Vector3F(Math::Cos(rot) * 50, Math::Cos(rot) * 50, Math::Sin(rot) * 50), Vector3F(0, 0, 0), Vector3F(0, -1, 0)); MatrixF projection = MatrixF::MakePerspective(45.0, window.GetWidth() / (Float32)window.GetHeight(), 1, 1000); MatrixF vp = view * projection; MatrixF model; model = MatrixF::MakeScaling(Vector3F(20, 20, 20)) * model; //Matrix wvp = model * Matrix::MakeOrtho2D(0, 1280, 768, 0); MatrixF wvp = model * vp; GL::UniformMatrix4fv(GL::GetUniformLocation(program, "matrix"), 1, false, wvp.GetData()); GL::Uniform1i(GL::GetUniformLocation(program, "texture"), 0); GL::ActiveTexture(GL_TEXTURE0); GL::BindTexture(GL_TEXTURE_2D, texture); GL::BindVertexArray(box); GL::DrawArrays(GL_QUADS, 0, 24); GL::BindVertexArray(0); GL::UseProgram(0); context.SwapBuffers(); Window::Update(); } } catch (Exception& e) { std::cout << e.what() << std::endl; std::cout << std::hex << "Error code: 0x" << e.unique << std::dec << " (decimal " << e.unique << ")" << std::endl; } }
int GetHeight() const { return mWindow.GetHeight(); }
void Map::DrawBackground(Window screen, Graphics* assets){ Point2D dim = GetMapDimension(); Surface* surface =& (assets->forest[0]); Surface* parallax = & (assets->forestParallax); int forestStart = (int)dim.Y;//The bottom of the map int Xstart = 0; int Xcount = 0; int parallaxStartX =0; //(Bottom of map - (the current camera position + the height of the screen)) divided by the height of the background surface -1 //== (bottom of map - the bottom of the screen)/height of background -1 //==how many backgrounds are already beneath this position? int Ycount = (int)((forestStart - (_mapPosition.Y+screen.GetHeight())) / surface->GetHeight()) - 1; //the starting point for the background to draw int Ystart = (int)dim.Y - surface->GetHeight()*Ycount; while(Ystart>_mapPosition.Y){ //The vertical height determines the kind of background surface->SetTransparency(255); if(Ycount == 0) {surface = &(assets->forest[0]); parallax=&(assets->forestParallax);} else if(Ycount == 1) {surface =&( assets->air[0]);parallax=0;} else if(Ycount == 2) {surface = &(assets->space1);parallax=0;} else if(Ycount < 0) {surface->SetTransparency(0);parallax=0;} else {surface = &(assets->space2);parallax=0;} //This one is handled, go the next one Ystart -= surface->GetHeight(); //The starting position of the next background to render Xstart = (int)(_mapPosition.X - ((Uint32)_mapPosition.X % (Uint32)surface->GetWidth())); //How many backgrounds are already left of this? Xcount = (int)(_mapPosition.X/surface->GetWidth()); if (parallax!=0 && parallax->IsInit()) { int parallaxStartX=(int)(_mapPosition.X/2 - ((Uint32)(_mapPosition.X/2) % (Uint32)parallax->GetWidth())); while(parallaxStartX < _mapPosition.X + screen.GetWidth()){ parallax->Draw(screen,(Uint32)(parallaxStartX-_mapPosition.X/2), (Uint32)(Ystart-_mapPosition.Y)+400); parallax->Draw(screen,(Uint32)(parallaxStartX-_mapPosition.X/2), (Uint32)(Ystart-_mapPosition.Y)+400); parallaxStartX += parallax->GetWidth(); } } while(Xstart < _mapPosition.X + screen.GetWidth()){ //Handle the current image for the looping backgrounds if(Ycount == 1){ if(Xcount>2)Xcount = Xcount%3; surface = &(assets->air[Xcount]); Xcount++; } else if(Ycount == 0){ if(Xcount>3) Xcount = Xcount%4; surface = &(assets->forest[Xcount]); Xcount++; } surface->Draw(screen, (Uint32)(Xstart-_mapPosition.X), (Uint32)(Ystart-_mapPosition.Y)); Xstart += surface->GetWidth(); } Ycount++; } }
JNIEXPORT jint JNICALL Java_sp_app_Window_native_1GetHeight (JNIEnv *env, jclass cls, jlong handler) { Window* window = getHandle<Window>(handler); return window->GetHeight(); }
int lime_window_get_height (value window) { Window* targetWindow = (Window*)val_data (window); return targetWindow->GetHeight (); }
int main() { Jatta::Matrix wee; wee[1][2] = 5; std::cout << wee << std::endl; try { // Setup the window WindowStyle style; style.title = "A Quick Brown Fox Jumps Over The Lazy Dog"; style.width = 800; style.height = 350; style.backgroundColor = Colors::black; style.resizable = false; Window window; window.Create(style); // Create the OpenGL context OpenGL::Context context; context.Create(&window); OpenGL::Program program = LoadShader("Resources/screen.vert", "Resources/screen.frag"); Font font; if (font.Load("Resources/Arial.ttf") == -1) { throw std::runtime_error("Failed to load 'Resources/Arial.ttf'."); } if (font.Load("Resources/epgyosho.ttf") == -1) { throw std::runtime_error("Failed to load 'Resources/epgyosho.ttf'."); } if (font.Load("Resources/LastResort.ttf") == -1) { throw std::runtime_error("Failed to load 'Resources/LastResort.ttf'."); } font.SetStyle(FontStyles::OBLIQUE | FontStyles::UNDERLINED); Image image[22]; OpenGL::Texture texture[22]; OpenGL::VertexArray box[22]; for (unsigned int i = 7; i < 27; ++i) { font.SetSize(i); image[i-7] = font.GenerateText(Jatta::Colors::white,"A Quick Brown Fox Jumps Over The Lazy Dog 0123456789"); texture[i-7].Create(OpenGL::GL::TEXTURE_2D); texture[i-7].Bind(); texture[i-7].SetTextureWrapS(OpenGL::GL::REPEAT); texture[i-7].SetTextureWrapT(OpenGL::GL::REPEAT); texture[i-7].SetMinFilter(OpenGL::GL::LINEAR); texture[i-7].SetMagFilter(OpenGL::GL::LINEAR); texture[i-7].Image2D(0, OpenGL::GL::RGBA, image[i-7].GetWidth(), image[i-7].GetHeight(), 0, OpenGL::GL::RGBA, OpenGL::GL::UNSIGNED_BYTE, image[i-7].GetData()); texture[i-7].Unbind(); box[i-7] = MakeBox(Float2(image[i-7].GetWidth(), image[i-7].GetHeight())); } font.SetSize(16); font.SetStyle(FontStyles::OVERLINED | FontStyles::UNDERLINED); image[21] = font.GenerateText(Jatta::Colors::white,"こんにちわ"); texture[21].Create(OpenGL::GL::TEXTURE_2D); texture[21].Bind(); texture[21].SetTextureWrapS(OpenGL::GL::REPEAT); texture[21].SetTextureWrapT(OpenGL::GL::REPEAT); texture[21].SetMinFilter(OpenGL::GL::LINEAR); texture[21].SetMagFilter(OpenGL::GL::LINEAR); texture[21].Image2D(0, OpenGL::GL::RGBA, image[21].GetWidth(), image[21].GetHeight(), 0, OpenGL::GL::RGBA, OpenGL::GL::UNSIGNED_BYTE, image[21].GetData()); texture[21].Unbind(); box[21] = MakeBox(Float2(image[21].GetWidth(), image[21].GetHeight())); while (window.IsOpen()) { Window::Update(); context.Viewport(0, 0, window.GetWidth(), window.GetHeight()); context.Clear(OpenGL::GL::COLOR_BUFFER_BIT | OpenGL::GL::DEPTH_BUFFER_BIT); UInt32 y = 0; program.Bind(); OpenGL::Program::UniformMatrix4f(program.GetUniformLocation("orthoMatrix"), false, Matrix::MakeOrtho(0, window.GetWidth(), window.GetHeight(), 0)); for (unsigned int i = 7; i < 27; ++i) { OpenGL::Program::UniformMatrix4f(program.GetUniformLocation("modelMatrix"), false, Matrix::MakeTranslation(Float2(0,y))); OpenGL::Program::Uniform1i(program.GetUniformLocation("texture"), texture[i-7].GetID()); OpenGL::ClearErrors(); OpenGL::Texture::Active(texture[i-7].GetID()); texture[i-7].Bind(); box[i-7].Bind(); box[i-7].DrawArrays(OpenGL::GL::QUADS, 0, 4); box[i-7].Unbind(); y += image[i-7].GetHeight(); } OpenGL::Program::UniformMatrix4f(program.GetUniformLocation("modelMatrix"), false, Matrix::MakeTranslation(Float2(800-image[21].GetWidth(),0))); OpenGL::Program::Uniform1i(program.GetUniformLocation("texture"), texture[21].GetID()); OpenGL::ClearErrors(); OpenGL::Texture::Active(texture[21].GetID()); texture[21].Bind(); box[21].Bind(); box[21].DrawArrays(OpenGL::GL::QUADS, 0, 4); box[21].Unbind(); program.Unbind(); context.SwapBuffers(); } } catch (std::exception& e) { std::cout << e.what() << std::endl; } }
static VALUE Window_to_s(VALUE vSelf) { // Get C++ object pointer from vSelf Window *pSelf; Data_Get_Struct(vSelf, Window, pSelf); char szBuffer[256]; sprintf(szBuffer, "Height: %d, Width: %d, Depth Bits: %d, Stencil Bits: %d", pSelf->GetWidth(), pSelf->GetHeight(), pSelf->GetDepthBits(), pSelf->GetStencilBits()); return rb_str_new2(szBuffer); }
value lime_window_get_height (value window) { Window* targetWindow = (Window*)(intptr_t)val_float (window); return alloc_int (targetWindow->GetHeight ()); }
static VALUE Window_get_height(VALUE vSelf) { // Get C++ object pointer from vSelf Window *pSelf; Data_Get_Struct(vSelf, Window, pSelf); return INT2FIX(pSelf->GetHeight()); }
bool Application::OnCreate(const char* a_sCmdLine) { Utilities::ConsoleShow(true); //System m_pWindow = Window::Create("Ichor Window",1024,768); m_pRenderer = DX11Renderer::Create(m_pWindow); m_pGameTime = GameTime::Create(); //Input m_pKeyboard = Keyboard::Create(); m_pMouse = Mouse::Create(); m_pWindow->AttachMouse(m_pMouse); //Camera DX11Frustrum oFustrum; oFustrum.m_fFieldOfView = ((F32)PI_HALF / 2.0f); oFustrum.m_fScreenAspect = ((F32)m_pWindow->GetWidth() / (F32)m_pWindow->GetHeight()); oFustrum.m_fNear = 0.01f; oFustrum.m_fFar = 100.0f; m_pCamera = DX11Camera::Create(oFustrum); m_pCamera->SetTranslate(0.0f,0.0f,-10.0f); struct sData { char cInitial; int iVal; float fVal; double dVal; long long llVal; char cVal; }; sData* fDelta = new sData; //Shaders m_pShaderProp = ShaderProperty::Create("./Data/Shaders/Base.hlsl"); m_pShaderProp->AddCBuffer("Matrix",fDelta,sizeof(sData),0); //OBJECTS //Scene m_pScene = new Node("Scene"); //Cube m_pParent = dynamic_cast<Mesh*>(CreateCube()); m_pParent->AttachProperty(m_pShaderProp); m_pParent->SetTranslate(1,0,0); m_pChild = dynamic_cast<Mesh*>(m_pParent->Clone()); m_pChild->SetTranslate(-5,0,0); m_pParent->Update(); m_pChild->Update(); //Parenting m_pScene->AttachChild(m_pParent); m_pParent->AttachChild(m_pChild); m_fRot = 0.0f; return true; }