~ubuntu-branches/ubuntu/trusty/manaplus/trusty

« back to all changes in this revision

Viewing changes to src/graphicsmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-10-07 10:26:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131007102614-tg2zjdz8vmtl6n7i
Tags: 1.3.9.29-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <GLES2/gl2.h>
28
28
#include <GLES/glext.h>
29
29
#include <EGL/egl.h>
 
30
#ifndef USE_SDL2
30
31
#include <SDL_android.h>
 
32
#endif
31
33
#else
32
34
#include "GL/glx.h"
33
35
#endif
150
152
    logger->log1("enable opengl mode");
151
153
    int textureSampler = 0;
152
154
    int compressTextures = 0;
153
 
    createWindow(100, 100, 0, SDL_ANYFORMAT | SDL_OPENGL);
 
155
#ifndef ANDROID
 
156
    mainGraphics = new NormalOpenGLGraphics;
 
157
#endif
 
158
    SDL_Window *const window = createWindow(100, 100, 0,
 
159
        SDL_ANYFORMAT | SDL_OPENGL);
 
160
    mainGraphics->setWindow(window, 100, 100);
154
161
 
155
162
    initOpenGL();
156
163
    logVersion();
344
351
    const bool noFrame = config.getBoolValue("noframe");
345
352
 
346
353
#ifdef ANDROID
347
 
    int width = config.getValue("screenwidth", 0);
348
 
    int height = config.getValue("screenheight", 0);
 
354
//    int width = config.getValue("screenwidth", 0);
 
355
//    int height = config.getValue("screenheight", 0);
349
356
    StringVect videoModes;
350
357
    SDL::getAllVideoModes(videoModes);
351
 
    if (!videoModes.empty())
352
 
    {
353
 
        bool found(false);
354
 
        std::string str = strprintf("%dx%d", width, height);
355
 
        if (width != 0 && height != 0)
356
 
        {
357
 
            FOR_EACH (StringVectCIter, it, videoModes)
358
 
            {
359
 
                if (str == *it)
360
 
                {
361
 
                    found = true;
362
 
                    break;
363
 
                }
364
 
            }
365
 
        }
 
358
    if (videoModes.empty())
 
359
        logger->error("no video modes detected");
 
360
    std::vector<int> res;
 
361
    splitToIntVector(res, videoModes[0], 'x');
 
362
    if (res.size() != 2)
 
363
        logger->error("no video modes detected");
366
364
 
367
 
        if (!found)
368
 
        {
369
 
            if (width != 0 && height != 0)
370
 
            {
371
 
                logger->log("Current resolution %s is incorrect.",
372
 
                    str.c_str());
373
 
            }
374
 
//            str = videoModes[0];
375
 
            std::vector<int> res;
376
 
            splitToIntVector(res, videoModes[0], 'x');
377
 
            if (res.size() == 2)
378
 
            {
379
 
                width = res[0];
380
 
                height = res[1];
381
 
                logger->log("Autoselect mode %dx%d", width, height);
382
 
            }
383
 
        }
384
 
    }
 
365
    int width = res[0];
 
366
    int height = res[1];
385
367
#else
386
368
    int width = config.getIntValue("screenwidth");
387
369
    int height = config.getIntValue("screenheight");
902
884
{
903
885
    if (error)
904
886
    {
905
 
        std::string errmsg = "Unknown error";
 
887
        std::string errmsg("Unknown error");
906
888
        switch (error)
907
889
        {
908
890
            case GL_INVALID_ENUM:
1085
1067
#endif
1086
1068
    }
1087
1069
#if defined ANDROID
 
1070
#ifdef USE_SDL2
 
1071
    const int dpi = atoi(getenv("DISPLAY_DPI"));
 
1072
    if (dpi <= 120)
 
1073
        mDensity = 0;
 
1074
    else if (dpi <= 160)
 
1075
        mDensity = 1;
 
1076
    else if (dpi <= 213)
 
1077
        mDensity = 2;
 
1078
    else if (dpi <= 240)
 
1079
        mDensity = 3;
 
1080
    else if (dpi <= 320)
 
1081
        mDensity = 4;
 
1082
//    else if (dpi <= 480)
 
1083
    else
 
1084
        mDensity = 5;
 
1085
    mMaxWidth = atoi(getenv("DISPLAY_RESOLUTION_WIDTH"));
 
1086
    mMaxHeight = atoi(getenv("DISPLAY_RESOLUTION_HEIGHT"));
 
1087
    mWidthMM = atoi(getenv("DISPLAY_WIDTH_MM"));
 
1088
    mHeightMM = atoi(getenv("DISPLAY_HEIGHT_MM"));
 
1089
#else
1088
1090
    SDL_ANDROID_GetMetrics(&mMaxWidth, &mMaxHeight,
1089
1091
        &mWidthMM, &mHeightMM, &mDensity);
1090
1092
#endif
 
1093
#endif
1091
1094
    logger->log("screen size in pixels: %dx%d", mMaxWidth, mMaxHeight);
1092
1095
    logger->log("screen size in millimeters: %dx%d", mWidthMM, mHeightMM);
1093
1096
    logger->log("actual screen density: " + getDensityString());