Browse Source

Add DGL test

tags/1.9.4
falkTX 12 years ago
parent
commit
f293cb75a3
8 changed files with 3265 additions and 5 deletions
  1. +1
    -3
      .gitignore
  2. +1
    -0
      source/includes/dgl
  3. +6
    -0
      source/libs/distrho/dgl/Base.hpp
  4. +16
    -0
      source/libs/distrho/dgl/src/Window.cpp
  5. +93
    -0
      source/tests/DGL.cpp
  6. +3128
    -0
      source/tests/DGL_Artwork.cpp
  7. +15
    -0
      source/tests/DGL_Artwork.hpp
  8. +5
    -2
      source/tests/Makefile

+ 1
- 3
.gitignore View File

@@ -64,12 +64,10 @@ carla-discovery-posix64

data/windows/Carla
source/tests/ANSI
source/tests/Base64
source/tests/CarlaString
source/tests/DGL
source/tests/Print
source/tests/Rewire.cpp
source/tests/RtList
source/tests/Thread
source/tests/Utils

# Docs


+ 1
- 0
source/includes/dgl View File

@@ -0,0 +1 @@
../libs/distrho/dgl/

+ 6
- 0
source/libs/distrho/dgl/Base.hpp View File

@@ -55,6 +55,8 @@

// -------------------------------------------------

START_NAMESPACE_DGL

enum Char {
DGL_CHAR_BACKSPACE = 0x08,
DGL_CHAR_ESCAPE = 0x1B,
@@ -96,6 +98,10 @@ enum Modifier {
DGL_MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
};

END_NAMESPACE_DGL

// -------------------------------------------------

static inline
void dgl_sleep(unsigned int secs)
{


+ 16
- 0
source/libs/distrho/dgl/src/Window.cpp View File

@@ -205,6 +205,16 @@ public:
return fVisible;
}

void setResizable(bool yesNo)
{
if (fResizable == yesNo)
return;

fResizable = yesNo;

//setSize();
}

void setVisible(bool yesNo)
{
if (fVisible == yesNo)
@@ -254,6 +264,7 @@ public:
SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
UpdateWindow(hwnd);
#elif DGL_OS_LINUX
// TODO - handle fResizable
XSizeHints sizeHints;
memset(&sizeHints, 0, sizeof(sizeHints));

@@ -536,6 +547,11 @@ bool Window::isVisible()
return kPrivate->isVisible();
}

void Window::setResizable(bool yesNo)
{
kPrivate->setResizable(yesNo);
}

void Window::setVisible(bool yesNo)
{
kPrivate->setVisible(yesNo);


+ 93
- 0
source/tests/DGL.cpp View File

@@ -0,0 +1,93 @@
/*
* Carla Tests
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the GPL.txt file
*/

#include "dgl/App.hpp"
#include "dgl/Image.hpp"
#include "dgl/Widget.hpp"
#include "dgl/Window.hpp"

#include "DGL_Artwork.hpp"

USE_NAMESPACE_DGL;

class StandaloneWindow
{
public:
StandaloneWindow()
: fApp(),
fWindow(&fApp)
{
}

App* getApp()
{
return &fApp;
}

Window* getWindow()
{
return &fWindow;
}

void exec()
{
fWindow.show();
fApp.exec();
}

private:
App fApp;
Window fWindow;
};

class MyWidget : public Widget
{
public:
MyWidget(StandaloneWindow* win)
: Widget(win->getWindow()),
fWindow(win->getWindow())
{
{
using namespace DGL_Artwork;
fImage.loadFromMemory(start_here_kxstudioData,
Size<int>(start_here_kxstudioWidth, start_here_kxstudioHeight),
GL_BGRA, GL_UNSIGNED_BYTE);
}

fWindow->setSize(fImage.getWidth(), fImage.getHeight());
fWindow->setWindowTitle("DGL Test");
}

protected:
void onDisplay() override
{
fImage.draw();
}

private:
Window* const fWindow;

Image fImage;
};

int main()
{
StandaloneWindow win;
MyWidget widget(&win);
win.exec();
return 0;
}

+ 3128
- 0
source/tests/DGL_Artwork.cpp
File diff suppressed because it is too large
View File


+ 15
- 0
source/tests/DGL_Artwork.hpp View File

@@ -0,0 +1,15 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_DGL_ARTWORK_HPP
#define BINARY_DGL_ARTWORK_HPP

namespace DGL_Artwork
{
extern const char* start_here_kxstudioData;
const unsigned int start_here_kxstudioDataSize = 262144;
const unsigned int start_here_kxstudioWidth = 256;
const unsigned int start_here_kxstudioHeight = 256;
}

#endif // BINARY_DGL_ARTWORK_HPP


+ 5
- 2
source/tests/Makefile View File

@@ -20,7 +20,7 @@ ANSI_CXX_FLAGS += -Wcast-qual -Wconversion -Wsign-conversion -Wlogical-op -Wagg
ANSI_CXX_FLAGS += -std=c++11 -Wzero-as-null-pointer-constant
ANSI_CXX_FLAGS += -DBUILD_ANSI_TEST -DVESTIGE_HEADER -fPIC

TARGETS = ANSI CarlaString RtList Print Utils
TARGETS = ANSI CarlaString DGL RtList Print Utils

all: $(TARGETS) RUN

@@ -32,7 +32,10 @@ ANSI: ANSI.cpp
CarlaString: CarlaString.cpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@

RtList: RtList.cpp ../libs/rtmempool.a ../utils/RtList.hpp
DGL: DGL.cpp DGL_Artwork.cpp ../libs/dgl.a
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -lGL -lX11 -o $@

RtList: RtList.cpp ../utils/RtList.hpp ../libs/rtmempool.a
$(CXX) RtList.cpp ../libs/rtmempool.a $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -pthread -lpthread -o $@

Print: Print.cpp


Loading…
Cancel
Save