我一直在一个新项目工作,但我遇到一个问题,我不明白为什么失败.
当我执行此行时删除textY给我错误_Block_Type_Is_Valid(pHead-> nBlockUse).那么我做错了什么?
这是源代码:
Text.h
#ifndef TEXT_H
#define TEXT_H
typedef boost::shared_ptr<Font> FontPtr;
class Text
{
public:
Text(FontPtr font, char *text)
{
str = new char[35];
this->font = font; str = text;
}
Text(const Text& cSource);
Text& operator=(const Text& cSource);
~Text();
.
.
.
.
private:
FontPtr font;
char *str;
GLuint texture;
GLfloat pos_x, pos_y, width, height;
};
#endif
Run Code Online (Sandbox Code Playgroud)
Text.cpp
Text::Text(const Text& cSource)
{
font = cSource.font;
texture = cSource.texture;
pos_x = cSource.pos_x;
pos_y = cSource.pos_y;
width = cSource.width;
height = …Run Code Online (Sandbox Code Playgroud) 我在代码中遇到了特定功能的终生问题.我正在学习Rust和SDL的教程.该教程稍微陈旧,SDL库自编写以来已经发生了变化,所以我一直在跟进,同时也适应最新版本的Rust-SDL.
终身问题在于这个功能:
pub fn ttf_str_sprite(&mut self, text: &str, font_path: &'static str, size: i32, color: Color) -> Option<Sprite> {
if let Some(font) = self.cached_fonts.get(&(font_path, size)) {
return font.render(text).blended(color).ok()
.and_then(|surface| self.renderer.create_texture_from_surface(&surface).ok())
.map(Sprite::new)
}
//::sdl2_ttf::Font::from_file(Path::new(font_path), size).ok()
self.ttf_context.load_font(Path::new(font_path), size as u16).ok()
.and_then(|font| {
self.cached_fonts.insert((font_path, size), font);
self.ttf_str_sprite(text, font_path, size, color)
})
}
Run Code Online (Sandbox Code Playgroud)
尤其是线路self.ttf_context.load_font(Path::new(font_path), size as u16).ok().上面的注释行是旧的SDL版本的字体加载方法.
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
--> src\phi/mod.rs:57:26
|
57 | self.ttf_context.load_font(Path::new(font_path), size as u16).ok()
| ^^^^^^^^^
|
help: consider …Run Code Online (Sandbox Code Playgroud) 我正在使用SDL 1.2.14和随附的OpenGL绑定编写C++游戏.
但是,如果游戏是全屏的,我Alt- Tab然后回到游戏中,结果是不可预测的.游戏逻辑仍在运行.但是,渲染停止.我只看到在Alt-tab之前绘制的游戏的最后一帧
我已经确保重新初始化OpenGL上下文并在我获得一个SDL_APPACTIVE = 1事件时重新加载所有纹理,而这似乎只适用于一个Alt- Tab然后所有后续的Alt- Tab将停止渲染(我确保SDL_APPACTIVE每个都正确处理)时间并相应地设置上下文.)
我猜测SDL在最小化我不知道的应用程序时会做些什么.
有任何想法吗?
这是我当前的Makefile的一部分:
CFLAGS = -O2 -Wall -pedantic -std=gnu++11 `sdl-config --cflags --libs` -lSDL_mixer
Run Code Online (Sandbox Code Playgroud)
我正确安装了libsdl,SDL.h位于/ usr/include/sdl所属的地方,但它不会编译.#include "SDL.h"我的.h文件中也有这行,但仍然没有.
谁知道为什么?
在阅读有关GLUT与FreeGLUT的 Ubuntu论坛的讨论之后.
GLUT死于图形编程吗?SDL现在对OpenGL编程风靡一时吗?
我想使用 SDL2 制作游戏,但我无法编译和/或运行我的代码,请帮助!
众所周知,SDL2 很难设置,它通常是有抱负的游戏开发人员尝试使用的第一个库。
这篇文章旨在作为设置 SDL2 的常见问题的规范副本。
在Linux上使用C++中的iostream时,它会在终端中显示程序输出,但在Windows中,它只是将输出保存到stdout.txt文件中.如何在Windows中使输出显示在控制台中?
我想编译这段代码:
#include <SDL.h>
int main(int argc, char* argv[]) {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但它无法联系起来: Error 1 error LNK1561: entry point must be defined
这个库里有一些奇怪的代码:http://hg.libsdl.org/SDL/file/75726efbf679/include/SDL_main.h
#define main SDL_main
Run Code Online (Sandbox Code Playgroud)
我也加入SDL2.lib;SDL2main.lib了Project Settings => Linker => Input.
我该怎么做才能运行这个项目?
VS 2012 SP3,空C++项目.
仅使用给定的SDL_Window*和SDL_Renderer*,如何在SDL 2.0中创建和保存屏幕截图?
好的只是一个简单的问题.我在Windows上使用Visual C++进行编程,并且为了学习目的已经更改为Ubuntu并在Code :: Blocks,CodeLite和Eclipse中启动.我已经编写了一些简单的程序,SDL2并使用GLEW基于SDL2窗口的简单OpenGL应用程序.我用命令下载了库:
sudo apt-get install ...
我的主要问题是:因为这个应用程序是在外部库(rellying SDL2,glew,flu,OIS),它并没有在其他Linux计算机上运行.使用终端命令安装所有这些库后,程序将无法执行.我的问题是,是否可以构建不需要安装这些库的程序.例如,在Windows上,您将程序链接到文件夹SDL2.lib并包含SDL2.dll在.exe文件夹中.我怎么能在linux上做到这一点.我对linux编程以及工作原理的经验很少,所以我希望这只是一个基本问题.:)