C++ (우분투 리눅스에서 코드 작성)의 SDL 프로그래밍에서 화면에 텍스트를 그릴 때 함수와 두 번째 인수를 사용하여 텍스트를 가져옵니다. 그것의 타입은 char *입니다. main 함수에서 두 번째 인수에 대해 위 함수에 무엇을 보내야합니까? 이 코드에서 예를 들어, 내가 컴파일에서 오류가 발생합니다 : (나는 화면에 (재생기 재생합니다 ...) 텍스트를 그릴 원하는 기능을 사용하여) 당신이 'ISN을 얻고 무엇SDL_ttf 및 함수 사용
#include<iostream>
#include"SDL/SDL.h"
#include<SDL/SDL_gfxPrimitives.h>
#include "SDL/SDL_ttf.h"
using namespace std;
void drawText(SDL_Surface* screen,char* strin1 ,int size,int x, int y,int fR, int fG, int fB,int bR, int bG, int bB)
{
TTF_Font*font = TTF_OpenFont("ARIAL.TTF", size);
SDL_Color foregroundColor = { fR, fG, fB };
SDL_Color backgroundColor = { bR, bG, bB };
SDL_Surface* textSurface = TTF_RenderText_Shaded(font, strin1,foregroundColor, backgroundColor);
SDL_Rect textLocation = { x, y, 0, 0 };
SDL_BlitSurface(textSurface, NULL, screen, &textLocation);
SDL_FreeSurface(textSurface);
TTF_CloseFont(font);
}
int main(){
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
SDL_Surface* screen = SDL_SetVideoMode(1200,800,32,0);
SDL_WM_SetCaption("Ping Pong", 0);
SDL_Delay(500);
drawText(screen,"Player1 must play with ESCAPE & SPACE Keys and player2 must play with UP & DOWN Keys. . . Have Fun!!!",20,15,550,50,50,100,180,180,180);
return 0;
}
다음은 오류 텍스트입니다. 경고 : 사용되지 않는 문자열 상수가 'char *'[-Wwrite-strings]로 변환됩니다. –
어떻게해야합니까? –