mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Kill off some usages of c_str.
Also changes some function params, but this is ok. Some simplifications were also able to be made (ie. killing off strcmps with ==, etc).
This commit is contained in:
@ -2,7 +2,9 @@
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cctype>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DShader.h"
|
||||
@ -316,7 +318,7 @@ int CD3DFont::Shutdown()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dwColor, const char* strText)
|
||||
int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dwColor, const std::string& text)
|
||||
{
|
||||
if (!m_pVB)
|
||||
return 0;
|
||||
@ -331,7 +333,6 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw
|
||||
// translate starting positions
|
||||
float sx = x * scalex - 1.f;
|
||||
float sy = 1.f - y * scaley;
|
||||
char c;
|
||||
|
||||
// Fill vertex buffer
|
||||
FONT2DVERTEX* pVertices;
|
||||
@ -355,14 +356,14 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw
|
||||
D3D::context->PSSetShaderResources(0, 1, &m_pTexture);
|
||||
|
||||
float fStartX = sx;
|
||||
while (c = *strText++)
|
||||
for (char c : text)
|
||||
{
|
||||
if (c == ('\n'))
|
||||
if (c == '\n')
|
||||
{
|
||||
sx = fStartX;
|
||||
sy -= scaley * size;
|
||||
}
|
||||
if (c < (' '))
|
||||
if (!std::isprint(c))
|
||||
continue;
|
||||
|
||||
c -= 32;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <string>
|
||||
|
||||
#include "Common/MathUtil.h"
|
||||
|
||||
@ -41,9 +42,9 @@ namespace D3D
|
||||
int Init();
|
||||
int Shutdown();
|
||||
int DrawTextScaled(float x, float y,
|
||||
float size,
|
||||
float spacing, u32 dwColor,
|
||||
const char* strText);
|
||||
float size,
|
||||
float spacing, u32 dwColor,
|
||||
const std::string& text);
|
||||
};
|
||||
|
||||
extern CD3DFont font;
|
||||
|
@ -391,7 +391,7 @@ void PixelShaderCache::Init()
|
||||
Clear();
|
||||
|
||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX).c_str());
|
||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||
|
||||
SETSTAT(stats.numPixelShadersCreated, 0);
|
||||
SETSTAT(stats.numPixelShadersAlive, 0);
|
||||
|
@ -255,7 +255,7 @@ Renderer::~Renderer()
|
||||
D3D::Close();
|
||||
}
|
||||
|
||||
void Renderer::RenderText(const char *text, int left, int top, u32 color)
|
||||
void Renderer::RenderText(const std::string& text, int left, int top, u32 color)
|
||||
{
|
||||
D3D::font.DrawTextScaled((float)left, (float)top, 20.f, 0.0f, color, text);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
|
||||
namespace DX11
|
||||
@ -30,7 +31,7 @@ public:
|
||||
void ApplyCullDisable();
|
||||
void RestoreCull();
|
||||
|
||||
void RenderText(const char* pstr, int left, int top, u32 color);
|
||||
void RenderText(const std::string& text, int left, int top, u32 color);
|
||||
|
||||
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data);
|
||||
|
||||
|
@ -138,7 +138,7 @@ void VertexShaderCache::Init()
|
||||
Clear();
|
||||
|
||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX).c_str());
|
||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||
|
||||
SETSTAT(stats.numVertexShadersCreated, 0);
|
||||
SETSTAT(stats.numVertexShadersAlive, 0);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace DX11
|
||||
@ -18,7 +19,7 @@ class VideoBackend : public VideoBackendHardware
|
||||
|
||||
void ShowConfig(void* parent);
|
||||
|
||||
void UpdateFPSDisplay(const char*);
|
||||
void UpdateFPSDisplay(const std::string&);
|
||||
unsigned int PeekMessages();
|
||||
};
|
||||
|
||||
|
@ -2,11 +2,13 @@
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <string>
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/LogManager.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
@ -54,11 +56,9 @@ unsigned int VideoBackend::PeekMessages()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void VideoBackend::UpdateFPSDisplay(const char *text)
|
||||
void VideoBackend::UpdateFPSDisplay(const std::string& text)
|
||||
{
|
||||
TCHAR temp[512];
|
||||
swprintf_s(temp, sizeof(temp)/sizeof(TCHAR), _T("%hs | D3D | %hs"), scm_rev_str, text);
|
||||
EmuWindow::SetWindowText(temp);
|
||||
EmuWindow::SetWindowText(StringFromFormat("%s | D3D | %s", scm_rev_str, text.c_str()));
|
||||
}
|
||||
|
||||
std::string VideoBackend::GetName()
|
||||
@ -154,7 +154,7 @@ bool VideoBackend::Initialize(void *&window_handle)
|
||||
|
||||
frameCount = 0;
|
||||
|
||||
g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_dx11.ini").c_str());
|
||||
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_dx11.ini");
|
||||
g_Config.GameIniLoad();
|
||||
g_Config.UpdateProjectionHack();
|
||||
g_Config.VerifyValidity();
|
||||
|
@ -1755,7 +1755,7 @@ namespace GLExtensions
|
||||
|
||||
// Public members
|
||||
u32 Version() { return _GLVersion; }
|
||||
bool Supports(std::string name)
|
||||
bool Supports(const std::string& name)
|
||||
{
|
||||
return m_extension_list[name];
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace GLExtensions
|
||||
|
||||
// Function for checking if the hardware supports an extension
|
||||
// example: if (GLExtensions::Supports("GL_ARB_multi_map"))
|
||||
bool Supports(std::string name);
|
||||
bool Supports(const std::string& name);
|
||||
|
||||
// Returns OpenGL version in format 430
|
||||
u32 Version();
|
||||
|
@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
@ -27,11 +28,9 @@ unsigned int VideoBackend::PeekMessages()
|
||||
}
|
||||
|
||||
// Show the current FPS
|
||||
void VideoBackend::UpdateFPSDisplay(const char *text)
|
||||
void VideoBackend::UpdateFPSDisplay(const std::string& text)
|
||||
{
|
||||
char temp[100];
|
||||
snprintf(temp, sizeof temp, "%s | %s | %s", scm_rev_str, GetDisplayName().c_str(), text);
|
||||
return GLInterface->UpdateFPSDisplay(temp);
|
||||
return GLInterface->UpdateFPSDisplay(StringFromFormat("%s | %s | %s", scm_rev_str, GetDisplayName().c_str(), text.c_str()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -48,7 +47,7 @@ void InitInterface()
|
||||
#endif
|
||||
}
|
||||
|
||||
GLuint OpenGL_CompileProgram ( const char* vertexShader, const char* fragmentShader )
|
||||
GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShader)
|
||||
{
|
||||
// generate objects
|
||||
GLuint vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
|
||||
|
@ -133,7 +133,7 @@ void ApplyShader()
|
||||
// Fallback to shared user dir
|
||||
path = File::GetSysDirectory() + SHADERS_DIR DIR_SEP + g_ActiveConfig.sPostProcessingShader + ".glsl";
|
||||
}
|
||||
if (!File::ReadFileToString(path.c_str(), code)) {
|
||||
if (!File::ReadFileToString(path, code)) {
|
||||
ERROR_LOG(VIDEO, "Post-processing shader not found: %s", path.c_str());
|
||||
return;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ void ProgramShaderCache::Init(void)
|
||||
else
|
||||
{
|
||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX).c_str());
|
||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||
|
||||
char cache_filename[MAX_PATH];
|
||||
sprintf(cache_filename, "%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
||||
|
@ -141,9 +141,12 @@ RasterFont::RasterFont()
|
||||
glActiveTexture(GL_TEXTURE0+8);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
u32* texture_data = new u32[char_width*char_count*char_height];
|
||||
for (u32 y=0; y<char_height; y++) {
|
||||
for (u32 c=0; c<char_count; c++) {
|
||||
for (u32 x=0; x<char_width; x++) {
|
||||
for (u32 y = 0; y < char_height; y++)
|
||||
{
|
||||
for (u32 c = 0; c < char_count; c++)
|
||||
{
|
||||
for (u32 x = 0; x < char_width; x++)
|
||||
{
|
||||
bool pixel = (0 != (rasters[c][y] & (1<<(char_width-x-1))));
|
||||
texture_data[char_width*char_count*y+char_width*c+x] = pixel ? -1 : 0;
|
||||
}
|
||||
@ -181,10 +184,9 @@ RasterFont::~RasterFont()
|
||||
s_shader.Destroy();
|
||||
}
|
||||
|
||||
void RasterFont::printMultilineText(const char *text, double start_x, double start_y, double z, int bbWidth, int bbHeight, u32 color)
|
||||
void RasterFont::printMultilineText(const std::string& text, double start_x, double start_y, double z, int bbWidth, int bbHeight, u32 color)
|
||||
{
|
||||
size_t length = strlen(text);
|
||||
GLfloat *vertices = new GLfloat[length*6*4];
|
||||
GLfloat* vertices = new GLfloat[text.length() * 6 * 4];
|
||||
|
||||
int usage = 0;
|
||||
GLfloat delta_x = GLfloat(2*char_width)/GLfloat(bbWidth);
|
||||
@ -195,22 +197,24 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta
|
||||
GLfloat x = GLfloat(start_x);
|
||||
GLfloat y = GLfloat(start_y);
|
||||
|
||||
for (size_t i=0; i<length; i++) {
|
||||
u8 c = text[i];
|
||||
|
||||
if (c == '\n') {
|
||||
for (const char& c : text)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
x = GLfloat(start_x);
|
||||
y -= delta_y + border_y;
|
||||
continue;
|
||||
}
|
||||
|
||||
// do not print spaces, they can be skipped easily
|
||||
if (c == ' ') {
|
||||
if (c == ' ')
|
||||
{
|
||||
x += delta_x + border_x;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < char_offset || c >= char_count+char_offset) continue;
|
||||
if (c < char_offset || c >= char_count+char_offset)
|
||||
continue;
|
||||
|
||||
vertices[usage++] = x;
|
||||
vertices[usage++] = y;
|
||||
@ -245,7 +249,8 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta
|
||||
x += delta_x + border_x;
|
||||
}
|
||||
|
||||
if (!usage) {
|
||||
if (!usage)
|
||||
{
|
||||
delete [] vertices;
|
||||
return;
|
||||
}
|
||||
@ -258,7 +263,8 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta
|
||||
|
||||
s_shader.Bind();
|
||||
|
||||
if (color != cached_color) {
|
||||
if (color != cached_color)
|
||||
{
|
||||
glUniform4f(uniform_color_id, GLfloat((color>>16)&0xff)/255.f,GLfloat((color>>8)&0xff)/255.f,GLfloat((color>>0)&0xff)/255.f,GLfloat((color>>24)&0xff)/255.f);
|
||||
cached_color = color;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
|
||||
@ -14,7 +16,7 @@ public:
|
||||
~RasterFont(void);
|
||||
static int debug;
|
||||
|
||||
void printMultilineText(const char *text, double x, double y, double z, int bbWidth, int bbHeight, u32 color);
|
||||
void printMultilineText(const std::string& text, double x, double y, double z, int bbWidth, int bbHeight, u32 color);
|
||||
private:
|
||||
|
||||
u32 VBO;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Atomic.h"
|
||||
@ -829,7 +830,7 @@ void Renderer::DrawDebugInfo()
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::RenderText(const char *text, int left, int top, u32 color)
|
||||
void Renderer::RenderText(const std::string& text, int left, int top, u32 color)
|
||||
{
|
||||
const int nBackbufferWidth = (int)GLInterface->GetBackBufferWidth();
|
||||
const int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight();
|
||||
@ -1436,7 +1437,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||
{
|
||||
OSD::AddMessage(StringFromFormat(
|
||||
"Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
||||
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), w, h).c_str(), 2000);
|
||||
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), w, h), 2000);
|
||||
}
|
||||
}
|
||||
if (bAVIDumping)
|
||||
@ -1485,7 +1486,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||
OSD::AddMessage("Error opening framedump.raw for writing.", 2000);
|
||||
else
|
||||
{
|
||||
OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h).c_str(), 2000);
|
||||
OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000);
|
||||
}
|
||||
}
|
||||
if (pFrameDump)
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
|
||||
namespace OGL
|
||||
@ -27,8 +28,8 @@ extern struct VideoConfig {
|
||||
bool bSupportOGL31;
|
||||
bool bSupportViewportFloat;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char* gl_vendor;
|
||||
const char* gl_renderer;
|
||||
const char* gl_version;
|
||||
const char* glsl_version;
|
||||
|
||||
@ -60,7 +61,7 @@ public:
|
||||
void ApplyState(bool bUseDstAlpha) override {}
|
||||
void RestoreState() override {}
|
||||
|
||||
void RenderText(const char* pstr, int left, int top, u32 color) override;
|
||||
void RenderText(const std::string& text, int left, int top, u32 color) override;
|
||||
void DrawDebugInfo();
|
||||
void FlipImageData(u8 *data, int w, int h, int pixel_width = 3);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace OGL
|
||||
@ -18,7 +19,7 @@ class VideoBackend : public VideoBackendHardware
|
||||
|
||||
void ShowConfig(void* parent) override;
|
||||
|
||||
void UpdateFPSDisplay(const char*) override;
|
||||
void UpdateFPSDisplay(const std::string&) override;
|
||||
unsigned int PeekMessages() override;
|
||||
};
|
||||
|
||||
|
@ -123,7 +123,7 @@ void GetShaders(std::vector<std::string> &shaders)
|
||||
File::ScanDirectoryTree(directory, entry);
|
||||
for (auto& file : entry.children)
|
||||
{
|
||||
std::string name = file.virtualName.c_str();
|
||||
std::string name = file.virtualName;
|
||||
if (name.size() < 5)
|
||||
continue;
|
||||
if (strcasecmp(name.substr(name.size() - 5).c_str(), ".glsl"))
|
||||
@ -176,7 +176,7 @@ bool VideoBackend::Initialize(void *&window_handle)
|
||||
|
||||
frameCount = 0;
|
||||
|
||||
g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_opengl.ini").c_str());
|
||||
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_opengl.ini");
|
||||
g_Config.GameIniLoad();
|
||||
g_Config.UpdateProjectionHack();
|
||||
g_Config.VerifyValidity();
|
||||
|
@ -2,10 +2,13 @@
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Atomic.h"
|
||||
#include "Common/Common.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/LogManager.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
@ -284,9 +287,9 @@ u32 VideoSoftware::Video_GetQueryResult(PerfQueryType type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VideoSoftware::Video_Screenshot(const char *_szFilename)
|
||||
bool VideoSoftware::Video_Screenshot(const std::string& filename)
|
||||
{
|
||||
SWRenderer::SetScreenshot(_szFilename);
|
||||
SWRenderer::SetScreenshot(filename.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -336,7 +339,7 @@ void VideoSoftware::Video_ExitLoop()
|
||||
|
||||
// TODO : could use the OSD class in video common, we would need to implement the Renderer class
|
||||
// however most of it is useless for the SW backend so we could as well move it to its own class
|
||||
void VideoSoftware::Video_AddMessage(const char* pstr, u32 milliseconds)
|
||||
void VideoSoftware::Video_AddMessage(const std::string& msg, u32 milliseconds)
|
||||
{
|
||||
}
|
||||
void VideoSoftware::Video_ClearMessages()
|
||||
@ -385,11 +388,9 @@ unsigned int VideoSoftware::PeekMessages()
|
||||
}
|
||||
|
||||
// Show the current FPS
|
||||
void VideoSoftware::UpdateFPSDisplay(const char *text)
|
||||
void VideoSoftware::UpdateFPSDisplay(const std::string& text)
|
||||
{
|
||||
char temp[100];
|
||||
snprintf(temp, sizeof temp, "%s | Software | %s", scm_rev_str, text);
|
||||
GLInterface->UpdateFPSDisplay(temp);
|
||||
GLInterface->UpdateFPSDisplay(StringFromFormat("%s | Software | %s", scm_rev_str, text.c_str()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace MMIO { class Mapping; }
|
||||
@ -31,9 +32,9 @@ class VideoSoftware : public VideoBackend
|
||||
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) override;
|
||||
u32 Video_GetQueryResult(PerfQueryType type) override;
|
||||
|
||||
void Video_AddMessage(const char* pstr, unsigned int milliseconds) override;
|
||||
void Video_AddMessage(const std::string& msg, unsigned int milliseconds) override;
|
||||
void Video_ClearMessages() override;
|
||||
bool Video_Screenshot(const char* filename) override;
|
||||
bool Video_Screenshot(const std::string& filename) override;
|
||||
|
||||
int Video_LoadTexture(char *imagedata, u32 width, u32 height);
|
||||
void Video_DeleteTexture(int texID);
|
||||
@ -49,7 +50,7 @@ class VideoSoftware : public VideoBackend
|
||||
void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) override;
|
||||
void RegisterPEMMIO(MMIO::Mapping* mmio, u32 base) override;
|
||||
|
||||
void UpdateFPSDisplay(const char*) override;
|
||||
void UpdateFPSDisplay(const std::string&) override;
|
||||
unsigned int PeekMessages() override;
|
||||
|
||||
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true) override;
|
||||
|
Reference in New Issue
Block a user