sdl

How can I modify pixels using SDL?

喜你入骨 提交于 2019-11-30 09:36:11
I have a slight problem: I can't modify the pixels of an SDL screen. Specifically, the following code doesn't work. Uint32 * pixels = (Uint32 *) screen -> pixels; screen -> pixels = pixels; This compiles, but it doesn't show anything. What am I missing? I had the following functions lying around for setting pixels in an SDL_Surface. There are two versions each for 32-bit, 24-bit, 16-bit and 8-bit surfaces. If you just want to set a single pixel, you would use the normal versions. But if you want to set a bunch of pixels, first you lock the surface, then you use the nolock version(named so

Simple sound wave generator with SDL in c++

北战南征 提交于 2019-11-30 09:20:21
i am having problems understanding how the audio part of the sdl library works now, i know that when you initialize it, you have to specify the frequency and a >>callback<< function, which i think is then called automatically at the given frequency. can anyone who worked with the sdl library write a simple example that would use sdl_audio to generate a 440 hz square wave (since it is the simplest waveform) at a sampling frequency of 44000 hz? The Introduction to SDL has got a neat example of using SDL Sound library that should get you started: http://www.libsdl.org/intro.en/usingsound.html

Sleep(1) and SDL_Delay(1) takes 15 ms

左心房为你撑大大i 提交于 2019-11-30 07:34:28
问题 I am writing a C++/SDL/OpenGL application, and I have had the most peculiar bug. The game seemed to be working fine with a simple variable timestep. But then the FPS started behaving strangely. I figured out that both Sleep(1) and SDL_Delay(1) take 15 ms to complete. Any input into those functions between 0-15 takes 15ms to complete, locking FPS at about 64. If I set it to 16, it takes 30 MS O.O I have NO idea why this is happening. This is the strangest bug I have ever encountered. My loop

How can I move the camera correctly in 3D space?

混江龙づ霸主 提交于 2019-11-30 05:47:23
问题 What I want to do: I am trying to figure out how to make the camera work like this: Mouse movement: camera rotates Up/Down key: camera moves forward/backwards; forward means the direction the camera is facing Left/Right key: camera moves sideways Q/E key: camera moves up and down Since I have a lot of code, I will do my best to try to explain how I did it, without too much code. The project I'm working on is very large, and has a pretty big library with many classes and types that would make

ijkplayer系列12:video_refresh_thread

江枫思渺然 提交于 2019-11-30 04:26:35
video_refresh_thread 该线程负责图像的渲染,先来看下整体流程: 从上面的流程图可以得知,最终根据格式的差异分成了三个分支,我们先来看下func_display_overlay_l()的源码,然后再继续深入三个分支中。 static int func_display_overlay_l(SDL_Vout *vout, SDL_VoutOverlay *overlay) { SDL_Vout_Opaque *opaque = vout->opaque; ANativeWindow *native_window = opaque->native_window; if (!native_window) { if (!opaque->null_native_window_warned) { opaque->null_native_window_warned = 1; ALOGW("func_display_overlay_l: NULL native_window"); } return -1; } else { opaque->null_native_window_warned = 1; } if (!overlay) { ALOGE("func_display_overlay_l: NULL overlay"); return -1; } if (overlay->w

How to draw pixels in SDL 2.0?

天涯浪子 提交于 2019-11-30 03:53:40
How does one draw with pixels in SDL2.0? I'm trying to get familiar with C++, but this is very difficult to do without pretty pictures, so I'm trying to get a very basic graphics display thing running. All I really want it to do is give me a window, let me draw rgbα pixels on it, and access information about those pixels. There may be other things I want that I'm not aware of, but that's all that's on my list right now. My research on this has lead me to try using SDL, the current version being 2.0. Almost all my graphics experience comes from using JavaScript on a <canvas> . Most of the other

OpenGL 3.x context creation using SDL2 on OSX (Macbook Air 2012)

心已入冬 提交于 2019-11-30 03:52:49
As far as I'm aware, the Macbook Air 2012 supports OpenGL 3.2. When using SDL 2.0 to create the OpenGL context, however, the context is only opengl version 2.1. Is it possible for SDL 2.0 to create a GL 3.2 context? David Greiner For everyone who still has this problem as of Wednesday, Oct 10th, SDL2 allows you to create an OpenGL 3.2 context on Macs running Mac OS X 10.7 (Lion) and up. You just need to add this code: SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT

How do I draw text using OpenGL, SDL and C++?

大憨熊 提交于 2019-11-30 02:59:27
问题 I heard about SDL_TFF which I read about here but I don't understand how am I supposed to connect the TrueType2 library. Maybe there is something better out there? 回答1: I came across this great guide on linking in SDL extensions for those new to SDL, which you may find useful. That said, when I had your problem, I eventually went with FTGL as the way SDL-ttf produces an SDL-Surface with its font rendered on it overcomplicated matters in my situation. This may not be the case in your situation

FFMPEG - ffplay源代码分析

[亡魂溺海] 提交于 2019-11-29 18:19:27
FFmpeg是一个开源,免费,跨平台的视频和音频流方案,它提供了一套完整的录制、转换以及流化音视频的解决方案。而ffplay是有ffmpeg官方提供的一个基于ffmpeg的简单播放器。学习ffplay对于播放器流程、ffmpeg的调用等等是一个非常好的例子。 1.例子 这里的说明使用如下的例子: ./ffplay avm.mp4 2. read_thread() 线程read_thread负责demux,它的流程如下图: avformat_alloc_context分配AVFormatContext。这是demux的上下文; avformat_open_input()解析文件,确定文件的封装格式(即mux类型); aformat_find_stream_info()继续解析AVFormatContext中包含的stream,根据stream类型确定其decoder,并创建AVCodecContext,这是decode的上下文; 如果指定了播放位置,avformat_seek_file()将播放位置移动到指定位置; av_find_best_stream()查找指定stream类型的最佳质量的stream。 stream_component_open()创建新的线程video_thread。Video_thread负责decode。 最后,read_thread在循环中,调用av

(转)基于FFPMEG2.0版本的ffplay代码分析

筅森魡賤 提交于 2019-11-29 18:19:01
ref:http://zzhhui.blog.sohu.com/304810230.html 背景说明 FFmpeg是一个开源,免费,跨平台的视频和音频流方案,它提供了一套完整的录制、转换以及流化音视频的解决方案。而ffplay是有ffmpeg官方提供的一个基于ffmpeg的简单播放器。学习ffplay对于播放器流程、ffmpeg的调用等等是一个非常好的例子。本文就是对ffplay的一个基本的流程剖析,很多细节内容还需要继续钻研。 注:本文师基于ffmpeg-2.0版本进行分析,具体代码行还请对号入座,谢谢! 主框架流程 总的流程图如下: 下图是一个ffplay播放rtsp流的流程图 下图是一个packet传递的示意图: 下图一个ffplay函数基本调用关系图,其中只保留了视频部分,去除了音频处理、字幕处理以及一些细节处理部分。 注:图中的数字表示了播放中的一次基本调用流程,X?序号表示退出流程。 从上图中我们可以了解到以下几种信息: 三个线程:主流程用于视频图像显示和刷新、read_thread用于读取数据、video_thread用于解码处理; 视频数据处理:由read_thread读取原始数据解复用后,按照packet的方式放入到队列中;由video_thread从packet队列中读取packet解码后,按照picture的方式放入到队列中