Ejemplo n.º 1
0
// ----------------------------------------------------------------------------
// Name : Render()
// Desc :
// ----------------------------------------------------------------------------
void CUIHelp::Render()
{
	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();
	m_bVisible = TRUE;

	// Set web board texture
	pDrawPort->InitTextureData( m_ptdBaseTexture );

	// Add render regions
	int	nX, nY, nX2, nY2;
	// Background
	// Upper left
	nX = m_nPosX;
	nY = m_nPosY;
	nX2 = m_nPosX + m_nWidth;
	nY2 = m_nPosY + 28;
	pDrawPort->AddTexture( nX, nY, nX + 49, nY2,
										m_rtTitleUL.U0, m_rtTitleUL.V0, m_rtTitleUL.U1, m_rtTitleUL.V1,
										0xFFFFFFFF );
	// Upper middle
	pDrawPort->AddTexture( nX + 49, nY, nX2 - 32, nY2,
										m_rtTitleUM.U0, m_rtTitleUM.V0, m_rtTitleUM.U1, m_rtTitleUM.V1,
										0xFFFFFFFF );
	// Upper right
	pDrawPort->AddTexture( nX2 - 32, nY, nX2, nY2,
										m_rtTitleUR.U0, m_rtTitleUR.V0, m_rtTitleUR.U1, m_rtTitleUR.V1,
										0xFFFFFFFF );

	nY = nY2;
	nY2 = nY2 + 10;

	pDrawPort->AddTexture( nX, nY, nX + 49, nY2,
										m_rtBackUL.U0, m_rtBackUL.V0, m_rtBackUL.U1, m_rtBackUL.V1,
										0xFFFFFFFF );
	// Upper middle
	pDrawPort->AddTexture( nX + 49, nY, nX2 - 32, nY2,
										m_rtBackUM.U0, m_rtBackUM.V0, m_rtBackUM.U1, m_rtBackUM.V1,
										0xFFFFFFFF );
	// Upper right
	pDrawPort->AddTexture( nX2 - 32, nY, nX2, nY2,
										m_rtBackUR.U0, m_rtBackUR.V0, m_rtBackUR.U1, m_rtBackUR.V1,
										0xFFFFFFFF );

	// Middle left
	nY = m_nPosY + m_nHeight - 15;
	pDrawPort->AddTexture( nX, nY2, nX + 49, nY,
										m_rtBackML.U0, m_rtBackML.V0, m_rtBackML.U1, m_rtBackML.V1,
										0xFFFFFFFF );
	// Middle middle
	pDrawPort->AddTexture( nX + 49, nY2, nX2 - 32, nY,
										m_rtBackMM.U0, m_rtBackMM.V0, m_rtBackMM.U1, m_rtBackMM.V1,
										0xFFFFFFFF );
	// Middle right
	pDrawPort->AddTexture( nX2 - 32, nY2, nX2, nY,
										m_rtBackMR.U0, m_rtBackMR.V0, m_rtBackMR.U1, m_rtBackMR.V1,
										0xFFFFFFFF );

	// Lower left
	nY2 = m_nPosY + m_nHeight;
	pDrawPort->AddTexture( nX, nY, nX + 49, nY2,
										m_rtBackLL.U0, m_rtBackLL.V0, m_rtBackLL.U1, m_rtBackLL.V1,
										0xFFFFFFFF );
	// Lower middle
	pDrawPort->AddTexture( nX + 49, nY, nX2 - 32, nY2,
										m_rtBackLM.U0, m_rtBackLM.V0, m_rtBackLM.U1, m_rtBackLM.V1,
										0xFFFFFFFF );
	// Lower right
	pDrawPort->AddTexture( nX2 - 32, nY, nX2, nY2,
										m_rtBackLR.U0, m_rtBackLR.V0, m_rtBackLR.U1, m_rtBackLR.V1,
										0xFFFFFFFF );	

	// Close button
	m_btnClose.Render();

	// Text in web board
	// Title
	pDrawPort->PutTextEx( _S( 1610, "도움말" ), m_nPosX + HELP_TITLE_OFFSETX,
										m_nPosY + HELP_TITLE_OFFSETY, 0xFFFFFFFF );	

	// Render subject List
	RenderList();
	RenderContent();

	// Flush all render queue
	pDrawPort->FlushRenderingQueue();
	pDrawPort->EndTextEx();

	// Render Help Image
	if( m_iImageIdx>=0 )
		RenderImage( m_iImageIdx );	
}
Ejemplo n.º 2
0
static bool Render(Buffer *out, const char *start, const char *input, Seq *hash_stack,
                   char *delim_start, size_t *delim_start_len,
                   char *delim_end, size_t *delim_end_len,
                   bool skip_content,
                   const char *section,
                   const char **section_end)
{
    while (true)
    {
        if (!input)
        {
            Log(LOG_LEVEL_ERR, "Unexpected end to Mustache template");
            return false;
        }

        Mustache tag = NextTag(input, delim_start, *delim_start_len, delim_end, *delim_end_len);

        {
            const char *line_begin = NULL;
            const char *line_end = NULL;
            if (!IsTagTypeRenderable(tag.type) && IsTagStandalone(start, tag.begin, tag.end, &line_begin, &line_end))
            {
                RenderContent(out, input, line_begin - input, false, skip_content);
                input = line_end;
            }
            else
            {
                RenderContent(out, input, tag.begin - input, false, skip_content);
                input = tag.end;
            }
        }

        switch (tag.type)
        {
        case TAG_TYPE_ERR:
            return false;

        case TAG_TYPE_DELIM:
            if (!SetDelimiters(tag.content, tag.content_len,
                               delim_start, delim_start_len,
                               delim_end, delim_end_len))
            {
                return false;
            }
            continue;

        case TAG_TYPE_COMMENT:
            continue;

        case TAG_TYPE_NONE:
            return true;

        case TAG_TYPE_VAR_SERIALIZED:
        case TAG_TYPE_VAR_SERIALIZED_COMPACT:
        case TAG_TYPE_VAR_UNESCAPED:
        case TAG_TYPE_VAR:
            if (!skip_content)
            {
                if (tag.content_len > 0)
                {
                    if (!RenderVariable(out, tag.content, tag.content_len, tag.type, hash_stack))
                    {
                        return false;
                    }
                }
                else
                {
                    RenderContent(out, delim_start, *delim_start_len, false, false);
                    RenderContent(out, delim_end, *delim_end_len, false, false);
                }
            }
            continue;

        case TAG_TYPE_INVERTED:
        case TAG_TYPE_SECTION:
            {
                char *section = xstrndup(tag.content, tag.content_len);
                JsonElement *var = LookupVariable(hash_stack, tag.content, tag.content_len);
                SeqAppend(hash_stack, var);

                if (!var)
                {
                    const char *cur_section_end = NULL;
                    if (!Render(out, start, input, hash_stack, delim_start, delim_start_len, delim_end, delim_end_len,
                                skip_content || tag.type != TAG_TYPE_INVERTED, section, &cur_section_end))
                    {
                        free(section);
                        return false;
                    }
                    free(section);
                    input = cur_section_end;
                    continue;
                }

                switch (JsonGetElementType(var))
                {
                case JSON_ELEMENT_TYPE_PRIMITIVE:
                    switch (JsonGetPrimitiveType(var))
                    {
                    case JSON_PRIMITIVE_TYPE_BOOL:
                        {
                            bool skip = skip_content || (!JsonPrimitiveGetAsBool(var) ^ (tag.type == TAG_TYPE_INVERTED));

                            const char *cur_section_end = NULL;
                            if (!Render(out, start, input, hash_stack, delim_start, delim_start_len, delim_end, delim_end_len,
                                        skip, section, &cur_section_end))
                            {
                                free(section);
                                return false;
                            }
                            free(section);
                            input = cur_section_end;
                        }
                        continue;

                    default:
                        Log(LOG_LEVEL_WARNING, "Mustache sections can only take a boolean or a container (array or map) value, but section '%s' isn't getting one of those.",
                            section);
                        return false;
                    }
                    break;

                case JSON_ELEMENT_TYPE_CONTAINER:
                    switch (JsonGetContainerType(var))
                    {
                    case JSON_CONTAINER_TYPE_OBJECT:
                    case JSON_CONTAINER_TYPE_ARRAY:
                        if (JsonLength(var) > 0)
                        {
                            const char *cur_section_end = NULL;
                            for (size_t i = 0; i < JsonLength(var); i++)
                            {
                                JsonElement *child_hash = JsonAt(var, i);
                                SeqAppend(hash_stack, child_hash);


                                if (!Render(out, start, input,
                                            hash_stack,
                                            delim_start, delim_start_len, delim_end, delim_end_len,
                                            skip_content || tag.type == TAG_TYPE_INVERTED, section, &cur_section_end))
                                {
                                    free(section);
                                    return false;
                                }
                            }
                            input = cur_section_end;
                            free(section);
                        }
                        else
                        {
                            const char *cur_section_end = NULL;
                            if (!Render(out, start, input, hash_stack, delim_start, delim_start_len, delim_end, delim_end_len,
                                        tag.type != TAG_TYPE_INVERTED, section, &cur_section_end))
                            {
                                free(section);
                                return false;
                            }
                            free(section);
                            input = cur_section_end;
                        }
                        break;
                    }
                    break;
                }
            }
            continue;
        case TAG_TYPE_SECTION_END:
            if (!section)
            {
                char *varname = xstrndup(tag.content, tag.content_len);
                Log(LOG_LEVEL_WARNING, "Unknown section close in mustache template '%s'", varname);
                free(varname);
                return false;
            }
            else
            {
                SeqRemove(hash_stack, SeqLength(hash_stack) - 1);
                *section_end = input;
                return true;
            }
            break;

        default:
            assert(false);
            return false;
        }
    }

    assert(false);
}
Ejemplo n.º 3
0
GLvoid Scene::Render(){
    //    if (_camera->_isNeedUpdateCamera){
    //        _camera->_updateCamera();
    //        _camera->_isNeedUpdateCamera = false;
    //    }
    //    if (_camera->_isNeedUpdateMatrix){
    //        _camera->_updateMatrix();
    //        _camera->_isNeedUpdateMatrix = false;
    //    }
    
    //    glMatrixMode(GL_PROJECTION);
    //    glLoadIdentity();
    //    //glLoadMatrixf(_camera->_curProjectionMatrix);
    //    glMatrixMode(GL_MODELVIEW);
    //    //glLoadMatrixf(_camera->_curViewMatrix);
    //    glLoadIdentity();
    GLint viewport[4];
    glGetIntegerv( GL_VIEWPORT, viewport ); // viewport is by default the display window
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective( 45, double(viewport[2])/viewport[3], 0.1, 20000 );
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    
    
    // Camera Tracing
    
    if(_mainCraft->_rotation.w>0.0f){
        _mainCraft->_rotation.w=-360.0f+_mainCraft->_rotation.w;
    }
    if(_mainCraft->_rotation.w<=0.0f && _mainCraft->_rotation.w>=-90.0f){
        _camera->_cameraPos.x = _mainCraft->modelPos.x-zoom*cos(-_mainCraft->_rotation.w*2.0f*PI/360.0f)-eyedistance;
        _camera->_cameraPos.y = _mainCraft->modelPos.y+zoom-eyeheight;
        _camera->_cameraPos.z = _mainCraft->modelPos.z-zoom*sin(-_mainCraft->_rotation.w*2.0f*PI/360.0f);
        gluLookAt(_camera->_cameraPos.x,_camera->_cameraPos.y,_camera->_cameraPos.z, _mainCraft->modelPos.x, _mainCraft->modelPos.y, _mainCraft->modelPos.z, 0,1,0 );
    }
    if(_mainCraft->_rotation.w<-90.0f && _mainCraft->_rotation.w>=-180.0f){
        _camera->_cameraPos.x = _mainCraft->modelPos.x+zoom*sin(-_mainCraft->_rotation.w*2.0f*PI/360.0f-PI/2.0f)-eyedistance;
        _camera->_cameraPos.y =_mainCraft->modelPos.y+zoom-eyeheight;
        _camera->_cameraPos.z =_mainCraft->modelPos.z-zoom*cos(-_mainCraft->_rotation.w*2.0f*PI/360-PI/2.0f);
        gluLookAt(_camera->_cameraPos.x,_camera->_cameraPos.y,_camera->_cameraPos.z, _mainCraft->modelPos.x, _mainCraft->modelPos.y, _mainCraft->modelPos.z, 0,1,0 );
    }
    if(_mainCraft->_rotation.w<-180.0f && _mainCraft->_rotation.w>=-270.0f){
        _camera->_cameraPos.x = _mainCraft->modelPos.x+zoom*cos(-_mainCraft->_rotation.w*2.0f*PI/360-PI)-eyedistance;
        _camera->_cameraPos.y = _mainCraft->modelPos.y+zoom-eyeheight;
        _camera->_cameraPos.z =_mainCraft->modelPos.z+zoom*sin(-_mainCraft->_rotation.w*2.0f*PI/360-PI);
        gluLookAt(_camera->_cameraPos.x,_camera->_cameraPos.y,_camera->_cameraPos.z, _mainCraft->modelPos.x, _mainCraft->modelPos.y, _mainCraft->modelPos.z, 0,1, 0 );
    }
    if(_mainCraft->_rotation.w<-270.0f && _mainCraft->_rotation.w>=-360.0f){
        _camera->_cameraPos.x = _mainCraft->modelPos.x-zoom*sin(-_mainCraft->_rotation.w*2.0f*PI/360.0f-PI*3.0f/2.0f)-eyedistance;
        _camera->_cameraPos.y =_mainCraft->modelPos.y+zoom-eyeheight;
        _camera->_cameraPos.z =_mainCraft->modelPos.z+zoom*cos(-_mainCraft->_rotation.w*2.0f*PI/360.0f-PI*3.0f/2.0f);
        gluLookAt(_camera->_cameraPos.x,_camera->_cameraPos.y,_camera->_cameraPos.z, _mainCraft->modelPos.x, _mainCraft->modelPos.y, _mainCraft->modelPos.z, 0,1,0 );
    }
    //cout<<_mainCraft->modelPos.x<<","<<_mainCraft->modelPos.z<<endl;
    
    // gluLookAt( _camera->_cameraPos.x, _camera->_cameraPos.y, _camera->_cameraPos.z, _mainCraft->modelPos.x, _mainCraft->modelPos.y, _mainCraft->modelPos.z, 0, 1, 0);
    
    //gluLookAt(2, 20, 2, 0, 0, 0, 0, 1, 0);
    glClearColor(0.0f,0.0f,0.0f,1.0f);
    glClearDepth(1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    
    // Put Render Content into Render()
    RenderContent();
    
    // Actually, here doesn't need to call glutSwapBuffer(), cuz it's been called in the external layer, WindowContainer
}