Skip to content

Commit

Permalink
Fix SFML and SDL samples on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikke89 committed Jun 26, 2020
1 parent 33dcbee commit 2ab4ee2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions Dependencies/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include/
lib/
tracy/
*/
5 changes: 3 additions & 2 deletions Samples/basic/sdl2/src/RenderInterfaceSDL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void RmlUiSDL2Renderer::RenderGeometry(Rml::Core::Vertex* vertices, int num_vert
std::vector<Rml::Core::Vector2f> Positions(num_vertices);
std::vector<Rml::Core::Colourb> Colors(num_vertices);
std::vector<Rml::Core::Vector2f> TexCoords(num_vertices);
float texw, texh;
float texw = 0.0f;
float texh = 0.0f;

SDL_Texture* sdl_texture = nullptr;
if(texture)
Expand Down Expand Up @@ -142,7 +143,7 @@ bool RmlUiSDL2Renderer::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rm

Rml::Core::String extension = source.substr(i+1, source.length()-i);

SDL_Surface* surface = IMG_LoadTyped_RW(SDL_RWFromMem(buffer, buffer_size), 1, extension.c_str());
SDL_Surface* surface = IMG_LoadTyped_RW(SDL_RWFromMem(buffer, int(buffer_size)), 1, extension.c_str());

if (surface) {
SDL_Texture *texture = SDL_CreateTextureFromSurface(mRenderer, surface);
Expand Down
8 changes: 6 additions & 2 deletions Samples/basic/sdl2/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@
#include "SystemInterfaceSDL2.h"
#include "RenderInterfaceSDL2.h"

#ifdef RMLUI_PLATFORM_WIN32
#include <windows.h>
#endif

#include <SDL.h>

#include <GL/glew.h>

int main(int /*argc*/, char** /*argv*/)
{
#ifdef RMLUI_PLATFORM_WIN32
DoAllocConsole();
AllocConsole();
#endif

int window_width = 1024;
Expand Down Expand Up @@ -144,7 +148,7 @@ int main(int /*argc*/, char** /*argv*/)
break;

case SDL_MOUSEWHEEL:
Context->ProcessMouseWheel(event.wheel.y, SystemInterface.GetKeyModifiers());
Context->ProcessMouseWheel(float(event.wheel.y), SystemInterface.GetKeyModifiers());
break;

case SDL_KEYDOWN:
Expand Down
8 changes: 6 additions & 2 deletions Samples/basic/sfml2/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#include <Shell.h>
#include <ShellFileInterface.h>

#ifdef RMLUI_PLATFORM_WIN32
#include <windows.h>
#endif

int main(int /*argc*/, char** /*argv*/)
{
#ifdef RMLUI_PLATFORM_WIN32
Expand Down Expand Up @@ -139,12 +143,12 @@ int main(int /*argc*/, char** /*argv*/)
SystemInterface.GetKeyModifiers());
break;
case sf::Event::MouseWheelMoved:
Context->ProcessMouseWheel(-event.mouseWheel.delta,
Context->ProcessMouseWheel(float(-event.mouseWheel.delta),
SystemInterface.GetKeyModifiers());
break;
case sf::Event::TextEntered:
if (event.text.unicode > 32)
Context->ProcessTextInput(event.text.unicode);
Context->ProcessTextInput(Rml::Core::Character(event.text.unicode));
break;
case sf::Event::KeyPressed:
Context->ProcessKeyDown(SystemInterface.TranslateKey(event.key.code),
Expand Down

0 comments on commit 2ab4ee2

Please sign in to comment.