void RenderContextGL2::layout(float width, float height, bool flipY) { m_width = width; m_height = height; LOG("layout with widthInPixels=%f, heightInPixels=%f", m_width, m_height) glViewport(0, 0, width, height); if( flipY ){ applyOrtho(0, width, height, 0); }else{ applyOrtho(0, width, 0, height); } switchToProgram(TEXTURE_PROGRAM); }
RenderContextGL2::RenderContextGL2() : m_width(100),m_height(100) { m_programs[TEXTURE_PROGRAM] = buildTexProgram(); m_programs[FILLRECT_PROGRAM] = buildFillProgram(); applyOrtho(0, m_width, 0, m_height); m_matrixStackIndex = 0; esLoadIdentity(&m_matrixStack[0]); esMatrixCopy(&m_tsrMatrix, &m_matrixStack[0]); m_alphaStack[0] = 1.0; switchToProgram(TEXTURE_PROGRAM); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); }
void GL2Renderer::initialize(int width, int height) { // create the framebuffer object and attach the color buffer glGenFramebuffers(1, &m_framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_renderbuffer); glViewport(0, 0, width, height); // The strings are included with that trick - remember? m_simpleProgram = buildProgram(SimpleVertexShader, SimpleFragmentShader); glUseProgram(m_simpleProgram); // Initialise the projection matrix const float maxX = 2; const float maxY = 3; applyOrtho(maxX, maxY); };
void RenderingEngine::init(int width, int height) { glClearColor(0.0f, 0.0f, 0.0f, 1); // Create the framebuffer object and attach the color buffer. glGenFramebuffers(1, &m_framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_renderbuffer); glViewport(0, 0, width, height); m_simpleProgram = shader::BuildProgram(SimpleVertexShader, SimpleFragmentShader); glUseProgram(m_simpleProgram); // init the projection matrix. applyOrtho(width, height); Game::getInstance().init(width, height); }