个人问题贴【二】
sdlgui吧
全部回复
仅看楼主
level 11
2014年06月19日 05点06分 1
level 11
如果安装好了图形库是不是不用换系统了[疑问]
2014年06月19日 05点06分 2
level 11
不得不告诉你[不要],不是图形库没安装好的问题。
是sdl竟不去,初始化不了[不高兴]
2014年06月19日 05点06分 3
2014年06月19日 05点06分
level 10
你重装系统也不行?
2014年06月19日 06点06分 4
level 10
你重装系统也不行?
2014年06月19日 06点06分 5
还没重装,我很怀疑配置错了。。。
2014年06月19日 06点06分
回复 闪光点22的xh :把你的配置环境传上来我试一下
2014年06月19日 06点06分
回复 twtfcu3 :什么叫配置环境?
2014年06月19日 06点06分
回复 闪光点22的xh :就你用的devcpp
2014年06月19日 06点06分
level 11
2014年06月19日 06点06分 6
2014年06月19日 06点06分
level 12
路过围观,完全的表示不懂。
2014年06月19日 17点06分 7
level 11
叫我怎么在gvim配置sdl2吧,我放弃ide了
@twtfcu3
2014年06月20日 04点06分 8
这是codeblocks的配置环境@twtfcu3
2014年06月20日 04点06分
回复 闪光点22的xh :[无效] http://pan.baidu.com/s/1ntLVpmL
2014年06月20日 04点06分
level 10
看到你发的图,编程居然还有中文路径,你太强大了,改改了再用
2014年06月20日 04点06分 9
[无效] http://pan.baidu.com/s/1ntLVpmL,你就看我有没有配置错。
2014年06月20日 04点06分
level 10
2014年06月20日 05点06分 10
[无效] 完全正常,你有库文件里的库不完整,我把它加进去了
2014年06月20日 05点06分
回复 twtfcu3 :太棒了![笑眼]什么库
2014年06月20日 05点06分
http://pan.baidu.com/s/1eQ1QHI6我也不知道,你自己去看吧
2014年06月20日 05点06分
回复 twtfcu3 :你哪里加了库?和我这里的配置一摸一样吗[狂汗]
2014年06月20日 05点06分
level 11
2014年06月20日 12点06分 11
2014年06月20日 12点06分
真不知道,你可以对比一下,我用你的编译环境时发现不能通过就把我用的库直接复制进去了
2014年06月20日 12点06分
回复 twtfcu3 :我的不能加载。。。我决定用vs配置一下了。。。不然就真的进行不了了。。。
2014年06月20日 13点06分
level 11
我好像忽略了一个严重的问题,我的win7是64位机,而@twtfcu3
2014年06月21日 09点06分 12
擦!!!给吞了
2014年06月21日 09点06分
level 11
他的教程应该是32位的,请问这样有影响吗?是不是这个原因导致出现sdl2初始化失败
2014年06月21日 09点06分 13
2014年06月21日 09点06分
level 10
自已下源码编译
2014年06月21日 13点06分 14
和电脑的位数有关系吗?
2014年06月21日 13点06分
回复 闪光点22的xh :有关,下载的sdl2库分为32和64位
2014年06月21日 13点06分
回复 twtfcu3 :你的sdl2 for cb是32位的吗?我机子是64位的。
2014年06月21日 13点06分
回复 闪光点22的xh :我是32位
2014年06月21日 13点06分
level 11
Mix_LoadMUS( );这个函数能不能加载mp3文件,我这里测试不能
@DXKite
2014年06月22日 11点06分 15
2014年06月22日 11点06分
不能,
2014年06月22日 12点06分
level 11
设置透明色出现崩溃,这个你应该知道原因吧@twtfcu3 [乖]
代码如下;
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
int main(int argc,char**argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window *win=SDL_CreateWindow("test",100,100,200,200,SDL_WINDOW_SHOWN);
SDL_Renderer*ren=SDL_CreateRenderer(win,-1,SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC);
SDL_Surface *s=IMG_Load("8.jpeg");
Uint32 ck=SDL_MapRGB(s->format,0,0,0);
SDL_SetColorKey(s,SDL_TRUE,ck);
SDL_Texture *tex=SDL_CreateTextureFromSurface(ren,s);
SDL_RenderCopy(ren,tex,NULL,NULL);
SDL_Delay(10000);
SDL_FreeSurface(s);
SDL_DestroyWindow(win);
SDL_DestroyRenderer(ren);
SDL_DestroyTexture(tex);
SDL_Quit();
return 0;
}
2014年06月27日 07点06分 16
level 10
加载的图不能直接操作
2014年06月27日 09点06分 17
把你设置透明色的视频地址给我看 一下,我找不到了[狂汗]
2014年06月27日 11点06分
回复 闪光点22的xh :https://tieba.baidu.com/p/3082059353
2014年06月27日 11点06分
回复 闪光点22的xh :https://tieba.baidu.com/p/3081731813
2014年06月27日 11点06分
回复 twtfcu3 :已下载。。。
2014年06月27日 12点06分
level 11
打印字体又出现问题了...这个是怎么回事@twtfcu3
2014年06月28日 02点06分 19
level 11
//两份基本相同的代码,只不过一个用了vector,用了vector的代码输出不了中文,另一个/////简单的反而可以,这两个都可以直接运行的,@twtfcu3 @DXKite @TTHHR @小牛_牛sky //都用的TTF_RenderUTF8_Blended这个函数
//1
#include <iostream>
#include <SDL2/SDL_ttf.h>
#include <vector>
#include <windows.h>
#include <SDL2/SDL_image.h>
using namespace std;
SDL_Texture* RenderText(std::string message, std::string fontFile,SDL_Color color, int fontSize);
void print_letter(vector<string> s9);
SDL_Renderer *ren=NULL;
SDL_Window*win=NULL;
SDL_Color color;
SDL_Texture *text=NULL,*tex=NULL;
int W=0,H=0;
vector<string>word={"你","hello","world","field"," ","of","good",
"time","chance","your","smooth","is","very","nice"};
int main(int argc,char**argv)
{
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
win=SDL_CreateWindow("test",0,0,800,850,SDL_WINDOW_SHOWN);
ren=SDL_CreateRenderer(win,-1,
SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC);
color={0,0,0};
SDL_RenderClear(ren);
SDL_GetWindowSize(win,&W,&H);
tex=IMG_LoadTexture(ren,"2.jpg");
SDL_RenderCopy(ren,tex,NULL,NULL);
SDL_RenderPresent(ren);
print_letter(word);
SDL_Delay(3000);
return 0;
}
void print_letter(vector<string> word)//输出文字
{
SDL_Rect post;
post.x=W/2-300;post.y=80;post.w=40;post.h=40;
int c=-1;const int ts=45;
for(auto it=word.begin();it!=word.end();++it){
++c;
text=RenderText(*it,"b.ttf",color,512);
if(post.x>(W/2+255))//换行
{
post.x=W/2-300;
post.y=post.y+25;
if(post.y>((H/25-1)*25+25))//跳页
{
vector<string> let_rest;
for(it=word.begin()+c;it!=word.end();++it)
let_rest.push_back(*it);
print_letter(let_rest);
}
}
SDL_RenderCopy(ren,text,NULL,&post);
cout<<*it<<endl;
SDL_RenderPresent(ren);
post.x=post.x+ts;
SDL_Delay(550);
}
Sleep(5000);
}
SDL_Texture* RenderText(std::string message, std::string fontFile,
SDL_Color color, int fontSize)
{
//Open the font
TTF_Font *font = nullptr;
font = TTF_OpenFont(fontFile.c_str(), fontSize);
//Render the message to an SDL_Surface, as that's what TTF_RenderText_X returns
SDL_Surface *surf = TTF_RenderUTF8_Blended(font, message.c_str(), color);
SDL_Texture *texture = SDL_CreateTextureFromSurface(ren, surf);
//Clean up unneeded stuff
SDL_FreeSurface(surf);
TTF_CloseFont(font);
return texture;
}
//2.
#include <SDL2/SDL.h>
#include <iostream>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_image.h>
using namespace std;
SDL_Texture* RenderText(std::string message, std::string fontFile,
SDL_Color color, int fontSize);
SDL_Renderer *ren=NULL;
int main(int argc, char **argv)
{
SDL_Window *win =SDL_CreateWindow("test", 800, 80, 600, 600, SDL_WINDOW_SHOWN);
ren = SDL_CreateRenderer(win, -1,SDL_RENDERER_ACCELERATED |SDL_RENDERER_PRESENTVSYNC);
TTF_Init();
SDL_Rect pos;
pos.x=300,pos.y=300,pos.w=20,pos.h=20;
SDL_Color color = { 255, 255, 255 };
SDL_Texture *texture = RenderText("你","a.ttf",color,256);
SDL_RenderClear(ren);
SDL_RenderCopy(ren,texture,NULL,&pos);
SDL_RenderPresent(ren);
SDL_Delay(20000);
SDL_DestroyWindow(win);
SDL_DestroyRenderer(ren);
SDL_Quit();
return 0;
}
SDL_Texture* RenderText(std::string message, std::string fontFile,
SDL_Color color, int fontSize)
{
//Open the font
TTF_Font *font = nullptr;
font = TTF_OpenFont(fontFile.c_str(), fontSize);
//Render the message to an SDL_Surface, as that's what TTF_RenderText_X returns
SDL_Surface *surf = TTF_RenderUTF8_Blended(font, message.c_str(), color);
SDL_Texture *texture = SDL_CreateTextureFromSurface(ren, surf);
//Clean up unneeded stuff
SDL_FreeSurface(surf);
TTF_CloseFont(font);
return texture;
}
2014年06月29日 08点06分 20
level 11
看你代码我就发昏,。呃呃,睡了一下午,先试试简单的使用vector储存字符串,应该可以用的,肯定什么地方你弄错了,,其实vector我喜欢这样 vector<string> a={"a","b"};
cout<<a[0]<<a[1];
干嘛用指针啊,。。。麻烦,,
2014年06月29日 10点06分 21
我有一个输出啊,可以输出汉字,只是无法显示在sdl窗口里。。。你拿我代码试一下吧[太开心],可以显示英文,但是汉字无法显示,是第一个代码。[勉强]把windows.h注释掉。
2014年06月29日 10点06分
回复 闪光点22的xh :我弄了好久才发这楼的,其实是把你代码改了后出现一大堆undefined。。。。。然后,就走了,
2014年06月29日 10点06分
回复 DXKite :怎么可能呢?我这里运行的好好地,只是不能输出汉字,楼上那是由2个代码组成的[钱],主要想让你看看第一个不可以显示汉字那个[勉强]
2014年06月29日 11点06分
1 2 尾页