Example #1
0
void drawplane()
{
	oglColour(0.5,0.7,0.5);
	oglBegin(1);
	oglVertex(-200,-50,-200);
	oglVertex(200,-50,-200);
	oglVertex(200,-50,200);
	oglEnd();
	oglBegin(1);
	oglVertex(200,-50,200);
	oglVertex(-200,-50,200);
	oglVertex(-200,-50,-200);
	oglEnd();
}
Example #2
0
void Context::draw(HDC hdc) {
    // DEBUG
    // sm->bDebug = true;

    clock_t t = clock();
    float elapsed = static_cast<float>(t - timeT) / CLOCKS_PER_SEC;
    ++frameCount;
    if (elapsed > OVERLAY_FPS_INTERVAL) {
        OverlayMsg om;
        om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
        om.omh.uiType = OVERLAY_MSGTYPE_FPS;
        om.omh.iLength = sizeof(OverlayMsgFps);
        om.omf.fps = frameCount / elapsed;

        sendMessage(om);

        frameCount = 0;
        timeT = t;
    }

    unsigned int width, height;

    width = oGetDeviceCaps(hdc, HORZRES);
    height = oGetDeviceCaps(hdc, VERTRES);

    HWND hwnd = WindowFromDC(hdc);
    if (hwnd) {
        RECT r;
        if (GetClientRect(hwnd, &r)) {
            width = r.right - r.left;
            height = r.bottom - r.top;
        }
    }

    ods("OpenGL: DrawStart: Screen is %d x %d", width, height);

    checkMessage(width, height);

    oglViewport(0, 0, width, height);

    oglMatrixMode(GL_PROJECTION);
    oglLoadIdentity();
    oglOrtho(0, width, height, 0, -100.0, 100.0);

    oglMatrixMode(GL_MODELVIEW);

    oglBindTexture(GL_TEXTURE_2D, texture);
    oglPushMatrix();
    oglLoadIdentity();

    float w = static_cast<float>(uiWidth);
    float h = static_cast<float>(uiHeight);

    float left   = static_cast<float>(uiLeft);
    float top    = static_cast<float>(uiTop);
    float right  = static_cast<float>(uiRight);
    float bottom = static_cast<float>(uiBottom);

    float xm = (left) / w;
    float ym = (top) / h;
    float xmx = (right) / w;
    float ymx = (bottom) / h;

    oglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    oglBegin(GL_QUADS);

    oglTexCoord2f(xm, ymx);
    oglVertex2f(left, bottom);

    oglTexCoord2f(xm, ym);
    oglVertex2f(left, top);

    oglTexCoord2f(xmx, ym);
    oglVertex2f(right, top);

    oglTexCoord2f(xmx, ymx);
    oglVertex2f(right, bottom);
    oglEnd();

    oglPopMatrix();

}