sdl

Rendering pixels from array of RGB values in SDL 1.2?

最后都变了- 提交于 2019-11-29 15:12:27
I'm working on a NES emulator right now and I'm having trouble figuring out how to render the pixels. I am using a 3 dimensional array to hold the RGB value of each pixel. The array definition looks like this for the 256 x 224 screen size: byte screenData[224][256][3]; For example, [0][0][0] holds the blue value, [0][0][1] holds the green values and [0][0][2] holds the red value of the pixel at screen position [0][0] . When the vblank flag goes high, I need to render the screen. When SDL goes to render the screen, the screenData array will be full of the RGB values for each pixel. I was able

SDL 2.0: linking error

无人久伴 提交于 2019-11-29 14:36:58
I know that similar questions had been asked but none of the answers helped me... I wrote a simple SDL program: #include "SDL.h" int main( int argc, char* args[] ) { //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); //Quit SDL SDL_Quit(); return 0; } using Code:Blocks. I followed this tutorial http://lazyfoo.net/SDL_tutorials/lesson01/windows/codeblocks/index.php but I still cannot compile. Here is the build log: mingw32-g++.exe -LC:\SDL\SDL2\lib\x86 -o bin\Debug\test.exe obj\Debug\test.o -lmingw32 -lSDL2main -lSDL2 -mwindows C:\SDL\SDL2\lib\x86/SDL2main.lib(./Release/SDL_windows_main.obj):(.text[

A function-definition is not allowed here before '{'

人走茶凉 提交于 2019-11-29 11:28:47
i am getting a REALLY annoying error. i literally looked everywhere for it! i even went back and changed all of my if (case) // to-do to if (case) { // to-do } i don't ask a lot of questions like this, but i am really getting frustrated, and i am almost positive it is something simple that i am not seeing. here is the error: entity.cpp: In member function ‘virtual void Entity::clean()’: entity.cpp:148: error: a function-definition is not allowed here before ‘{’ token entity.cpp:394: error: expected ‘}’ at end of input here is my class code: #include "./entity.hpp" std::vector<Entity *> Entity:

Compiling with int main(void) fails; main(int argc, char *argv[]) succeeds. Why?

半腔热情 提交于 2019-11-29 11:05:56
Problem Why would compiling a program which has an int main(void) main function differ from compiling a program which has an int main(int argc, char *argv[]) main function, if the program does not use arguments passed on the command line? Is this OS or compiler specific? I do not get the same results using mingw and g++ (which is weird isn't it as wingw is a port of gcc) . Example Code #include <iostream> #include"SDL/SDL.h" int main(void) { return 0; } Compilation commands g++ test.cpp; #g++ 4.4.5 i586-mingw32msvc-g++ test.cpp; # mingw 4.4.4 Error (Given by the second command.) a(main.o):(

Linux/X11 input library without creating a window

一笑奈何 提交于 2019-11-29 06:57:37
Is there a good library to use for gathering user input in Linux from the mouse/keyboard/joystick that doesn't force you to create a visible window to do so? SDL lets you get user input in a reasonable way, but seems to force you to create a window, which is troublesome if you have abstracted control so the control machine doesn't have to be the same as the render machine. However, if the control and render machines are the same, this results in an ugly little SDL window on top of your display. Edit To Clarify : The renderer has an output window, in its normal use case, that window is full

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

你。 提交于 2019-11-29 04:33:26
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 looks like this: while (1){ GLuint t = SDL_GetTicks(); Sleep(1); //or SDL_Delay(1) cout << SDL_GetTicks(

How to draw pixels in SDL 2.0?

怎甘沉沦 提交于 2019-11-29 01:24:49
问题 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

Forcing Machine to Use Dedicated Graphics Card?

雨燕双飞 提交于 2019-11-29 01:21:39
问题 I am part of a team developing an application using C++ with SDL and OpenGL. On laptops when the application is ran the dedicated graphics card is not used and the GL context fails to create because the integrated graphics card does not support the version of GL we want. I have a feeling that this problem is specific to the laptop in question and not something we can solve through code. But, if anyone knows if there is a solution that'd be great. 回答1: Does it use NVidia dedicated graphics?

Performant 2D OpenGL graphics in R for fast display of raster image using qtpaint (qt) or rdyncall (SDL/OpenGL) packages?

谁说我不能喝 提交于 2019-11-28 22:52:41
For a real-time interactive Mandelbrot viewer I was making in R & Rcpp+OpenMP & Shiny I am on the lookout for a performant way to display 1920x1080 matrices as raster images in the hope of being able to achieve ca. 5-10 fps ( calculating the Mandelbrot images themselves now achieves ca. 20-30 fps at moderate zooms , and certainly scrolling around should go fast). Using image() with option useRaster=TRUE , plot.raster or even grid.raster() still doesn't quite cut it, so I am on the lookout for a more performant option, ideally using OpenGL acceleration. I noticed that there are qt wrapper

How do you include files in C++ from the /Library/Framework folder in MAC

孤街醉人 提交于 2019-11-28 21:30:33
I am trying to use SDL. I have a folder in /Library/Frameworks called SDL2.framework . I want to include the file SDL.h in my project. How do I do this? My code looks like: // Example program: // Using SDL2 to create an application window #include <SDL.h> #include <stdio.h> int main(int argc, char* argv[]) { SDL_Window *window; // Declare a pointer SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2 // Create an application window with the following settings: window = SDL_CreateWindow( "An SDL2 window", // window title SDL_WINDOWPOS_UNDEFINED, // initial x position SDL_WINDOWPOS_UNDEFINED, // initial