Various fixes

This commit is contained in:
Phillip Stephens 2015-11-02 01:31:06 -08:00
parent e54c8a7c6b
commit d5cd0bfb50
10 changed files with 146 additions and 93 deletions

View File

@ -11,6 +11,15 @@ if (NOT TARGET LogVisor)
endif()
include_directories(include ${LOG_VISOR_INCLUDE_DIR})
if(NOT GEKKO AND NOT CAFE)
list(APPEND PLAT_SRCS
lib/graphicsdev/GL.cpp
lib/graphicsdev/glew.c)
list(APPEND PLAT_HDRS
include/boo/graphicsdev/GL.hpp)
endif()
if(WIN32)
list(APPEND PLAT_SRCS
lib/win/ApplicationWin32.cpp
@ -18,9 +27,12 @@ if(WIN32)
lib/inputdev/HIDListenerWinUSB.cpp
lib/inputdev/HIDDeviceWinUSB.cpp
lib/graphicsdev/D3D11.cpp
lib/graphicsdev/D3D12.cpp
lib/graphicsdev/GL.cpp
lib/graphicsdev/glew.c)
lib/graphicsdev/D3D12.cpp)
list(APPEND PLAT_HDRS
include/boo/graphicsdev/D3D11.hpp
include/boo/graphicsdev/D3D12.hpp)
list(APPEND _BOO_SYS_LIBS Winusb)
elseif(APPLE)
list(APPEND PLAT_SRCS
@ -28,15 +40,17 @@ elseif(APPLE)
lib/mac/WindowCocoa.mm
lib/mac/GLViewCocoa.mm
lib/inputdev/HIDListenerIOKit.cpp
lib/inputdev/HIDDeviceIOKit.cpp
lib/graphicsdev/GL.cpp
lib/graphicsdev/glew.c)
lib/inputdev/HIDDeviceIOKit.cpp)
list(APPEND PLAT_HDRS
include/boo/graphicsdev/Metal.hpp)
find_library(APPKIT_LIBRARY AppKit)
find_library(IOKIT_LIBRARY IOKit)
find_library(OPENGL_LIBRARY OpenGL)
find_library(COREVIDEO_LIBRARY CoreVideo)
list(APPEND _BOO_SYS_LIBS ${APPKIT_LIBRARY} ${IOKIT_LIBRARY} ${OPENGL_LIBRARY} ${COREVIDEO_LIBRARY})
else()
else(NOT GEKKO)
list(APPEND PLAT_SRCS
lib/x11/ApplicationUnix.cpp
lib/x11/ApplicationXCB.hpp
@ -49,6 +63,8 @@ else()
lib/graphicsdev/GLX.cpp
lib/graphicsdev/glew.c)
# list(APPEND PLAT_HDRS )
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(dbus_pkg QUIET libdbus dbus-1)
@ -116,15 +132,12 @@ add_library(Boo
include/boo/IGraphicsContext.hpp
include/boo/graphicsdev/IGraphicsDataFactory.hpp
include/boo/graphicsdev/IGraphicsCommandQueue.hpp
include/boo/graphicsdev/GL.hpp
include/boo/graphicsdev/D3D11.hpp
include/boo/graphicsdev/D3D12.hpp
include/boo/graphicsdev/Metal.hpp
include/boo/IWindow.hpp
include/boo/IApplication.hpp
include/boo/System.hpp
include/boo/boo.hpp
InputDeviceClasses.cpp
${PLAT_SRCS})
${PLAT_SRCS}
${PLAT_HDRS})
add_subdirectory(test)

View File

@ -21,6 +21,12 @@ public:
BUTTON_AUX2 = 5
};
struct SWindowRect
{
int location[2];
int size[2];
};
struct SWindowCoord
{
unsigned pixel[2];
@ -84,6 +90,8 @@ public:
MKEY_COMMAND = 1<<4
};
virtual void resized(const SWindowRect& rect)
{(void)rect;}
virtual void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
{(void)coord;(void)button;(void)mods;}
virtual void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)

View File

@ -18,21 +18,21 @@ public:
Platform platform() const {return PlatformD3D11;}
const char* platformName() const {return "Direct 3D 11";}
const IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t sz);
IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t sz);
IGraphicsBufferD* newDynamicBuffer(BufferUse use);
const ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz);
ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt);
const IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);
IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);
const IShaderPipeline* newShaderPipeline(const char* vertSource, const char* fragSource,
IShaderPipeline* newShaderPipeline(const char* vertSource, const char* fragSource,
size_t texCount, const char** texNames,
BlendFactor srcFac, BlendFactor dstFac,
bool depthTest, bool depthWrite, bool backfaceCulling);
const IShaderDataBinding*
IShaderDataBinding*
newShaderDataBinding(const IShaderPipeline* pipeline,
const IVertexFormat* vtxFormat,
const IGraphicsBuffer* vbo, const IGraphicsBuffer* ebo,

View File

@ -28,22 +28,22 @@ public:
Platform platform() const {return PlatformD3D12;}
const char* platformName() const {return "Direct 3D 12";}
const IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count);
IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count);
IGraphicsBufferD* newDynamicBuffer(BufferUse use, size_t stride, size_t count);
const ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz);
ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt);
const IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);
IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);
const IShaderPipeline* newShaderPipeline(const char* vertSource, const char* fragSource,
IShaderPipeline* newShaderPipeline(const char* vertSource, const char* fragSource,
ComPtr<ID3DBlob>& vertBlobOut, ComPtr<ID3DBlob>& fragBlobOut,
const IVertexFormat* vtxFmt,
BlendFactor srcFac, BlendFactor dstFac,
bool depthTest, bool depthWrite, bool backfaceCulling);
const IShaderDataBinding*
IShaderDataBinding*
newShaderDataBinding(IShaderPipeline* pipeline,
IVertexFormat* vtxFormat,
IGraphicsBuffer* vbo, IGraphicsBuffer* ebo,

View File

@ -23,26 +23,26 @@ public:
Platform platform() const {return PlatformOGLES3;}
const char* platformName() const {return "OpenGL ES 3.0";}
const IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t sz);
IGraphicsBufferD* newDynamicBuffer(BufferUse use);
IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count);
IGraphicsBufferD* newDynamicBuffer(BufferUse use, size_t stride, size_t count);
const ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz);
ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt);
const IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);
IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);
const IShaderPipeline* newShaderPipeline(const char* vertSource, const char* fragSource,
size_t texCount, const char** texNames,
BlendFactor srcFac, BlendFactor dstFac,
bool depthTest, bool depthWrite, bool backfaceCulling);
IShaderPipeline* newShaderPipeline(const char* vertSource, const char* fragSource,
size_t texCount, const char** texNames,
BlendFactor srcFac, BlendFactor dstFac,
bool depthTest, bool depthWrite, bool backfaceCulling);
const IShaderDataBinding*
newShaderDataBinding(const IShaderPipeline* pipeline,
const IVertexFormat* vtxFormat,
const IGraphicsBuffer* vbo, const IGraphicsBuffer* ebo,
size_t ubufCount, const IGraphicsBuffer** ubufs,
size_t texCount, const ITexture** texs);
IShaderDataBinding*
newShaderDataBinding(IShaderPipeline* pipeline,
IVertexFormat* vtxFormat,
IGraphicsBuffer* vbo, IGraphicsBuffer* ebo,
size_t ubufCount, IGraphicsBuffer** ubufs,
size_t texCount, ITexture** texs);
void reset();
IGraphicsData* commit();

View File

@ -147,21 +147,21 @@ struct IGraphicsDataFactory
virtual Platform platform() const=0;
virtual const char* platformName() const=0;
virtual const IGraphicsBufferS*
virtual IGraphicsBufferS*
newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count)=0;
virtual IGraphicsBufferD*
newDynamicBuffer(BufferUse use, size_t stride, size_t count)=0;
virtual const ITextureS*
virtual ITextureS*
newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz)=0;
virtual ITextureD*
newDynamicTexture(size_t width, size_t height, TextureFormat fmt)=0;
virtual const IVertexFormat*
virtual IVertexFormat*
newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements)=0;
virtual const IShaderDataBinding*
virtual IShaderDataBinding*
newShaderDataBinding(IShaderPipeline* pipeline,
IVertexFormat* vtxFormat,
IGraphicsBuffer* vbo, IGraphicsBuffer* ebo,

View File

@ -141,7 +141,7 @@ public:
}
};
const IGraphicsBufferS*
IGraphicsBufferS*
D3D12DataFactory::newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count)
{
D3D12GraphicsBufferS* retval = new D3D12GraphicsBufferS(use, m_ctx, data, stride, count);
@ -246,7 +246,7 @@ public:
}
};
const ITextureS*
ITextureS*
D3D12DataFactory::newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz)
{
@ -360,7 +360,7 @@ public:
D3D12ShaderPipeline(const D3D12ShaderPipeline&) = delete;
};
const IShaderPipeline* D3D12DataFactory::newShaderPipeline
IShaderPipeline* D3D12DataFactory::newShaderPipeline
(const char* vertSource, const char* fragSource,
ComPtr<ID3DBlob>& vertBlobOut, ComPtr<ID3DBlob>& fragBlobOut,
const IVertexFormat* vtxFmt,
@ -520,7 +520,7 @@ struct D3D12ShaderDataBinding : IShaderDataBinding
}
};
const IShaderDataBinding*
IShaderDataBinding*
D3D12DataFactory::newShaderDataBinding(IShaderPipeline* pipeline,
IVertexFormat* vtxFormat,
IGraphicsBuffer* vbuf, IGraphicsBuffer* ibuf,
@ -800,7 +800,7 @@ D3D12DataFactory::newDynamicTexture(size_t width, size_t height, TextureFormat f
return retval;
}
const IVertexFormat* D3D12DataFactory::newVertexFormat
IVertexFormat* D3D12DataFactory::newVertexFormat
(size_t elementCount, const VertexElementDescriptor* elements)
{
D3D12CommandQueue* q = static_cast<D3D12CommandQueue*>(m_parent->getCommandQueue());

View File

@ -30,7 +30,7 @@ static const GLenum USE_TABLE[] =
GL_UNIFORM_BUFFER
};
class GLES3GraphicsBufferS : IGraphicsBufferS
class GLES3GraphicsBufferS : public IGraphicsBufferS
{
friend class GLES3DataFactory;
friend struct GLES3CommandQueue;
@ -54,7 +54,7 @@ public:
{glBindBufferBase(GL_UNIFORM_BUFFER, idx, m_buf);}
};
class GLES3GraphicsBufferD : IGraphicsBufferD
class GLES3GraphicsBufferD : public IGraphicsBufferD
{
friend class GLES3DataFactory;
friend struct GLES3CommandQueue;
@ -81,15 +81,15 @@ public:
void bindUniform(size_t idx) const;
};
const IGraphicsBufferS*
GLES3DataFactory::newStaticBuffer(BufferUse use, const void* data, size_t sz)
IGraphicsBufferS*
GLES3DataFactory::newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count)
{
GLES3GraphicsBufferS* retval = new GLES3GraphicsBufferS(use, data, sz);
GLES3GraphicsBufferS* retval = new GLES3GraphicsBufferS(use, data, stride * count);
static_cast<GLES3Data*>(m_deferredData)->m_SBufs.emplace_back(retval);
return retval;
}
class GLES3TextureS : ITextureS
class GLES3TextureS : public ITextureS
{
friend class GLES3DataFactory;
GLuint m_tex;
@ -125,7 +125,7 @@ public:
}
};
class GLES3TextureD : ITextureD
class GLES3TextureD : public ITextureD
{
friend class GLES3DataFactory;
friend struct GLES3CommandQueue;
@ -168,7 +168,7 @@ public:
}
};
const ITextureS*
ITextureS*
GLES3DataFactory::newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz)
{
@ -276,7 +276,7 @@ static const GLenum BLEND_FACTOR_TABLE[] =
GL_ONE_MINUS_DST_ALPHA
};
const IShaderPipeline* GLES3DataFactory::newShaderPipeline
IShaderPipeline* GLES3DataFactory::newShaderPipeline
(const char* vertSource, const char* fragSource,
size_t texCount, const char** texNames,
BlendFactor srcFac, BlendFactor dstFac,
@ -368,19 +368,19 @@ struct GLES3ShaderDataBinding : IShaderDataBinding
const GLES3ShaderPipeline* m_pipeline;
const GLES3VertexFormat* m_vtxFormat;
size_t m_ubufCount;
std::unique_ptr<const IGraphicsBuffer*[]> m_ubufs;
std::unique_ptr<IGraphicsBuffer*[]> m_ubufs;
size_t m_texCount;
std::unique_ptr<const ITexture*[]> m_texs;
GLES3ShaderDataBinding(const IShaderPipeline* pipeline,
const IVertexFormat* vtxFormat,
size_t ubufCount, const IGraphicsBuffer** ubufs,
size_t texCount, const ITexture** texs)
: m_pipeline(static_cast<const GLES3ShaderPipeline*>(pipeline)),
m_vtxFormat(static_cast<const GLES3VertexFormat*>(vtxFormat)),
std::unique_ptr<ITexture*[]> m_texs;
GLES3ShaderDataBinding(IShaderPipeline* pipeline,
IVertexFormat* vtxFormat,
size_t ubufCount, IGraphicsBuffer** ubufs,
size_t texCount, ITexture** texs)
: m_pipeline(static_cast<GLES3ShaderPipeline*>(pipeline)),
m_vtxFormat(static_cast<GLES3VertexFormat*>(vtxFormat)),
m_ubufCount(ubufCount),
m_ubufs(new const IGraphicsBuffer*[ubufCount]),
m_ubufs(new IGraphicsBuffer*[ubufCount]),
m_texCount(texCount),
m_texs(new const ITexture*[texCount])
m_texs(new ITexture*[texCount])
{
for (size_t i=0 ; i<ubufCount ; ++i)
m_ubufs[i] = ubufs[i];
@ -393,20 +393,28 @@ struct GLES3ShaderDataBinding : IShaderDataBinding
m_vtxFormat->bind();
for (size_t i=0 ; i<m_ubufCount ; ++i)
{
m_ubufs[i]->bindUniform(i);
if (m_ubufs[i]->dynamic())
static_cast<GLES3GraphicsBufferD*>(m_ubufs[i])->bindUniform(i);
else
static_cast<GLES3GraphicsBufferD*>(m_ubufs[i])->bindUniform(i);
glUniformBlockBinding(prog, i, i);
}
for (size_t i=0 ; i<m_texCount ; ++i)
m_texs[i]->bind(i);
{
if (m_texs[i]->dynamic())
static_cast<GLES3TextureD*>(m_texs[i])->bind(i);
else
static_cast<GLES3TextureS*>(m_texs[i])->bind(i);
}
}
};
const IShaderDataBinding*
GLES3DataFactory::newShaderDataBinding(const IShaderPipeline* pipeline,
const IVertexFormat* vtxFormat,
const IGraphicsBuffer*, const IGraphicsBuffer*,
size_t ubufCount, const IGraphicsBuffer** ubufs,
size_t texCount, const ITexture** texs)
IShaderDataBinding*
GLES3DataFactory::newShaderDataBinding(IShaderPipeline* pipeline,
IVertexFormat* vtxFormat,
IGraphicsBuffer*, IGraphicsBuffer*,
size_t ubufCount, IGraphicsBuffer** ubufs,
size_t texCount, ITexture** texs)
{
GLES3ShaderDataBinding* retval =
new GLES3ShaderDataBinding(pipeline, vtxFormat, ubufCount, ubufs, texCount, texs);
@ -549,12 +557,18 @@ struct GLES3CommandQueue : IGraphicsCommandQueue
if (desc->vertBuffer != lastVBO)
{
lastVBO = desc->vertBuffer;
lastVBO->bindVertex();
if (lastVBO->dynamic())
static_cast<const GLES3GraphicsBufferD*>(lastVBO)->bindVertex();
else
static_cast<const GLES3GraphicsBufferS*>(lastVBO)->bindVertex();
}
if (desc->indexBuffer != lastEBO)
{
lastEBO = desc->indexBuffer;
lastEBO->bindIndex();
if (lastEBO->dynamic())
static_cast<const GLES3GraphicsBufferD*>(lastEBO)->bindIndex();
else
static_cast<const GLES3GraphicsBufferS*>(lastEBO)->bindIndex();
}
glEnableVertexAttribArray(i);
glVertexAttribPointer(i, SEMANTIC_COUNT_TABLE[desc->semantic],
@ -820,7 +834,7 @@ void GLES3GraphicsBufferD::bindUniform(size_t idx) const
{glBindBufferBase(GL_UNIFORM_BUFFER, idx, m_bufs[m_q->m_drawBuf]);}
IGraphicsBufferD*
GLES3DataFactory::newDynamicBuffer(BufferUse use)
GLES3DataFactory::newDynamicBuffer(BufferUse use, size_t stride, size_t count)
{
GLES3CommandQueue* q = static_cast<GLES3CommandQueue*>(m_parent->getCommandQueue());
GLES3GraphicsBufferD* retval = new GLES3GraphicsBufferD(q, use);
@ -863,7 +877,7 @@ GLES3VertexFormat::GLES3VertexFormat(GLES3CommandQueue* q, size_t elementCount,
}
GLES3VertexFormat::~GLES3VertexFormat() {m_q->delVertexFormat(this);}
const IVertexFormat* GLES3DataFactory::newVertexFormat
IVertexFormat* GLES3DataFactory::newVertexFormat
(size_t elementCount, const VertexElementDescriptor* elements)
{
GLES3CommandQueue* q = static_cast<GLES3CommandQueue*>(m_parent->getCommandQueue());

View File

@ -315,16 +315,12 @@ public:
{
fprintf(stderr, "%s\n", message);
}
typedef void(*glDebugMessageCallbackPROC)(DEBUGPROC callback, void* userParam);
typedef void(*glDebugMessageCallbackPROC)(DEBUGPROC callback, void* userParam);
void postInit()
{
GLXExtensionCheck();
GLXEnableVSync(m_xDisp, m_glxWindow);
glDebugMessageCallbackPROC glDebugMessageCb = (glDebugMessageCallbackPROC)
glXGetProcAddressARB((const GLubyte*)"glDebugMessageCallback");
glDebugMessageCb(DebugCb, nullptr);
}
IGraphicsCommandQueue* getCommandQueue()
@ -337,7 +333,7 @@ public:
IGraphicsDataFactory* getDataFactory()
{
if (!m_dataFactory)
m_dataFactory = new struct GLES3DataFactory(this);
m_dataFactory = new class GLES3DataFactory(this);
return m_dataFactory;
}
@ -446,7 +442,7 @@ public:
XIEventMask mask = {XIAllMasterDevices, XIMaskLen(XI_LASTEVENT)};
mask.mask = (unsigned char*)malloc(mask.mask_len);
memset(mask.mask, 0, mask.mask_len);
XISetMask(mask.mask, XI_Motion);
/* XISetMask(mask.mask, XI_Motion); Can't do this without losing mouse move events :( */
XISetMask(mask.mask, XI_TouchBegin);
XISetMask(mask.mask, XI_TouchUpdate);
XISetMask(mask.mask, XI_TouchEnd);
@ -765,6 +761,12 @@ public:
m_wy = event->xexpose.y;
m_ww = event->xexpose.width;
m_wh = event->xexpose.height;
if (m_callback)
{
IWindowCallback::SWindowRect rect =
{ {m_wx, m_wy}, {m_ww, m_wh} };
m_callback->resized(rect);
}
return;
}
case ConfigureNotify:
@ -775,6 +777,13 @@ public:
m_wy = event->xconfigure.y;
m_ww = event->xconfigure.width;
m_wh = event->xconfigure.height;
if (m_callback)
{
IWindowCallback::SWindowRect rect =
{ {m_wx, m_wy}, {m_ww, m_wh} };
m_callback->resized(rect);
}
}
return;
}
@ -822,6 +831,7 @@ public:
{
if (m_callback)
{
getWindowFrame(m_wx, m_wy, m_ww, m_wh);
int button = translateButton(event->xbutton.button);
if (button)
{
@ -830,7 +840,7 @@ public:
{
{(unsigned)event->xbutton.x, (unsigned)event->xbutton.y},
{(unsigned)(event->xbutton.x / m_pixelFactor), (unsigned)(event->xbutton.y / m_pixelFactor)},
{event->xbutton.x / (float)m_ww, event->xbutton.y / (float)m_wh}
{float(event->xbutton.x) / float(m_ww), float(event->xbutton.y) / float(m_wh)}
};
m_callback->mouseDown(coord, (IWindowCallback::EMouseButton)button,
(IWindowCallback::EModifierKey)modifierMask);
@ -844,7 +854,7 @@ public:
{
{(unsigned)event->xbutton.x, (unsigned)event->xbutton.y},
{(unsigned)(event->xbutton.x / m_pixelFactor), (unsigned)(event->xbutton.y / m_pixelFactor)},
{event->xbutton.x / (float)m_ww, event->xbutton.y / (float)m_wh}
{(float)event->xbutton.x / (float)m_ww, (float)event->xbutton.y / (float)m_wh}
};
IWindowCallback::SScrollDelta scrollDelta =
{
@ -868,6 +878,7 @@ public:
{
if (m_callback)
{
getWindowFrame(m_wx, m_wy, m_ww, m_wh);
int button = translateButton(event->xbutton.button);
if (button)
{
@ -888,6 +899,7 @@ public:
{
if (m_callback)
{
getWindowFrame(m_wx, m_wy, m_ww, m_wh);
IWindowCallback::SWindowCoord coord =
{
{(unsigned)event->xmotion.x, (unsigned)event->xmotion.y},
@ -902,10 +914,13 @@ public:
{
if (event->xgeneric.extension == XINPUT_OPCODE)
{
getWindowFrame(m_wx, m_wy, m_ww, m_wh);
switch (event->xgeneric.evtype)
{
case XI_Motion:
{
fprintf(stderr, "motion\n");
XIDeviceEvent* ev = (XIDeviceEvent*)event;
if (m_lastInputID != ev->deviceid)
_pointingDeviceChanged(ev->deviceid);

View File

@ -115,6 +115,9 @@ public:
struct CTestWindowCallback : IWindowCallback
{
void resized(const SWindowRect& rect)
{ fprintf(stderr, "Resized %d, %d (%d, %d)\n", rect.size[0], rect.size[1], rect.location[0], rect.location[1]); }
void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
{
fprintf(stderr, "Mouse Down %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]);
@ -125,7 +128,7 @@ struct CTestWindowCallback : IWindowCallback
}
void mouseMove(const SWindowCoord& coord)
{
//fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]);
fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]);
}
void scroll(const SWindowCoord& coord, const SScrollDelta& scroll)
{
@ -201,16 +204,16 @@ struct TestApplicationCallback : IApplicationCallback
{{0.5,-0.5},{1.0,0.0}},
{{-0.5,-0.5},{0.0,0.0}}
};
const IGraphicsBuffer* vbo =
factory->newStaticBuffer(BufferUseVertex, quad, sizeof(quad));
IGraphicsBuffer* vbo =
factory->newStaticBuffer(BufferUseVertex, quad, sizeof(quad), 4);
/* Make vertex format */
const VertexElementDescriptor descs[2] =
VertexElementDescriptor descs[2] =
{
{vbo, nullptr, VertexSemanticPosition},
{vbo, nullptr, VertexSemanticUV}
};
const IVertexFormat* vfmt = factory->newVertexFormat(2, descs);
IVertexFormat* vfmt = factory->newVertexFormat(2, descs);
/* Make ramp texture */
using Pixel = uint8_t[4];
@ -223,7 +226,7 @@ struct TestApplicationCallback : IApplicationCallback
tex[i][j][2] = 0;
tex[i][j][3] = 0xff;
}
const ITexture* texture =
ITexture* texture =
factory->newStaticTexture(256, 256, 1, TextureFormatRGBA8, tex, 256*256*4);
/* Make shader pipeline */
@ -251,7 +254,7 @@ struct TestApplicationCallback : IApplicationCallback
static const char* TexNames[] = {"smplr"};
const IShaderPipeline* pipeline =
IShaderPipeline* pipeline =
factory->newShaderPipeline(VS, FS, 1, TexNames, BlendFactorOne, BlendFactorZero, true, true, false);
/* Make shader data binding */
@ -301,7 +304,7 @@ struct TestApplicationCallback : IApplicationCallback
gfxQ->present();
gfxQ->execute();
fprintf(stderr, "%zu\n", frameIdx);
//fprintf(stderr, "%zu\n", frameIdx);
++frameIdx;
if ((frameIdx - lastCheck) > 100)