sdl

How to fix weird camera rotation while moving camera with sdl, opengl in c++

自闭症网瘾萝莉.ら 提交于 2019-12-24 07:40:08
问题 I have a camera object that I have put together from reading on the net that handles moving forward and backward, strafe left and right and even look around with the mouse. But when I move in any direction plus try to look around it jumps all over the place, but when I don't move and look around its fine. I'm hoping someone can help me work out why I can move and look around at the same time? main.h #include "SDL/SDL.h" #include "SDL/SDL_opengl.h" #include <cmath> #define CAMERASPEED 0.03f //

Cannot draw a filled circle with SDL2 gfx

笑着哭i 提交于 2019-12-24 07:26:41
问题 There is the following code. The desired result is that a window is created and a filled circle is drawn: #include <SDL2/SDL.h> #include <iostream> #include <SDL2/SDL2_gfxPrimitives.h> int main() { SDL_Window* window = nullptr; SDL_Renderer* renderer = nullptr; if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << "Could not initialise" << std::endl; return 1; } window = SDL_CreateWindow("MyGame", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN); if(!window) { std:

glDrawArrays does not draw anything in GL_TRIANGLES mode

家住魔仙堡 提交于 2019-12-24 07:26:22
问题 My problem is the glDrawArray command stops working. I've written a few programs which I used that command. However now, I don't have any idea why it doesn't work. But I still can draw lines to the screen with GL_LINES instead of GL_TRIANGLES . Here is my code: #include "Mesh.h" #include <iostream> Mesh::Mesh() { glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &vbo); size = 0; } void Mesh::AddVertices(const Vertex vertices[], int length) { size = length; glBindBuffer(GL

SDL Error while Creating Window?

僤鯓⒐⒋嵵緔 提交于 2019-12-24 06:06:37
问题 #include<SDL2/SDL.h> #include<stdio.h> #include<stdbool.h> bool init(char *title, int width, int height); void close(); SDL_Window *window = NULL; SDL_Surface *screen = NULL; bool init(char *title, int width, int height){ bool success = true; // SDL_Init 0 on success and returns negative on failure if( SDL_Init(SDL_INIT_EVERYTHING) != 0 ){ SDL_Log("Couldn't initialize SDL: %s",SDL_GetError()); success = false; } // creating Window and Surface window = SDL_CreateWindow(title, SDL_WINDOWPOS

Get window handle of SDL 2 application

杀马特。学长 韩版系。学妹 提交于 2019-12-24 05:09:05
问题 I would like to get the handle of a SDL2 window, to use it with WinApi. I retrieve that handle with the following code : /* All the SDL initalisation... */ SDL_Window* window = SDL_CreateWindow("My Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, RESX, RESY, SDL_WINDOW_SHOWN); SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); if (window == NULL || renderer == NULL) { MessageBox(NULL, L"SDL initialisation error", NULL, MB_OK); exit(-1); } SDL

Greyscale image in SDL2

痴心易碎 提交于 2019-12-24 03:07:10
问题 I have an array of uint8_t which represents a greyscale picture, where each pixel is one uint8_t . I would like to display this in a window using the SDL2 library. I have tried to create an SDL_Surface from the array by doing mSurface = SDL_CreateRGBSurfaceFrom(mData, mWidth, mHeight, 8, mWidth, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000); However, the problem is that when a depth of 8 bits is passed to SDL_CreateRGBSurfaceFrom (as I have done here), according to the SDL2 wiki "If depth is 4 or 8

'User Templates' not showing up in 'New Project' window - Xcode 4

久未见 提交于 2019-12-24 01:16:52
问题 I recently downloaded two SDL packages from the SDL website and moved them to the appropriate folders. in :/Library/Application Support/Developer/Shared/Xcode/Project Templates, I made a folder called "Applications" and in it I moved 'SDL Application' and two other SDL folders. Also, in: /Library/Frameworks, I moved SDL.Framework. When I make a new project, I see in the left side bar a section for iOS and Mac OS X. But what I want is a 'User templates' section, but it isn't there. (I would

pip install pygame - SDL.h file not found

匆匆过客 提交于 2019-12-24 00:34:29
问题 MacOS Sierra ➜ fun_python $ pip --version pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5) pip install pygame is giving me the following error: src/scrap.c:27:10: fatal error: 'SDL.h' file not found , error: command '/usr/bin/clang' failed with exit status 1 , #include "SDL.h" . I don't see this SDL/SDL.h file under /usr/include/... folder tree. gave me the following error. ➜ fun_python $ pip install pygame Collecting pygame Downloading

Colors are off in SDL program

百般思念 提交于 2019-12-24 00:29:00
问题 I am currently working on a very simple game using a pure C approach with SDL (and its official extra libraries such as SDL_image) and OpenGL. Right now though I've hit a bit of a stumbling block and I have no idea why it is doing this: the colors are all off when drawn. I am running the program on a Mac currently, but if I remember correctly when I run it in Windows the colors are closer to being correct, but there are still some odd things happening (such as a pure white polygon drawing as

SDL: Window freezes

限于喜欢 提交于 2019-12-23 23:24:40
问题 I wanted to start working on SDL. I got a sample code to see if it worked fine. When compiling I get no errors, but when I run it the window shows up but the program freezes until the delay time is over. I'm new to this so I would really appreciate some help. int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Window *window = 0; window = SDL_CreateWindow("Hello World!", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN); SDL_Delay(10000); SDL