Search Results

Search found 427 results on 18 pages for 'sdl gfx'.

Page 7/18 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Implementation of APIs on diferent platforms

    - by b-gen-jack-o-neill
    OK, this is basicly just about any non-default OS API running on all different OS. But for my example let´s consider platform Windows, API SDL (Simple DirectMedia Layer). Actually this question came to my mind when I was reading about SDL. Originally, I thought that on Windows (and basicly any other OS) you must use OS API to make certain actions, like wrtiting to screen, creating window and so on, becouse that API knows what kernel calls and system subroutines calls it has to do. But when I read about SDL, I surprised me, becouse, you cannot make computer to do anything more than OS can, since you cannot acess HW directly, only thru OS API, from Console allocation to DirectX. So, my question actually is, how does this not-default-OS APIs work? Do they use (wrap) original system API (like MFC wraps win32 api)? Or, do they actually have direct acess to Windows kernel? Or is there any third, way in between? Thanks.

    Read the article

  • Compiler issues on VC++ 2008 Express, Seemingly correct code throws errors.

    - by Anthony Clever
    Hi there, I've been trying to get back into coding for a while, so I figured I'd start with some simple SDL, now, without the file i/o, this compiles fine, but when I throw in the stdio code, it starts throwing errors. This I'm not sure about, I don't see any problem with the code itself, however, like I said, I might as well be a newbie, and figured I'd come here to get someone with a little more experience with this type of thing to look at it. I guess my question boils down to: "Why doesn't this compile under Microsoft's Visual C++ 2008 Express?" I've attached the error log at the bottom of the code snippet. Thanks in advance for any help. #include "SDL/SDL.h" #include "stdio.h" int main(int argc, char *argv[]) { FILE *stderr; FILE *stdout; stderr = fopen("stderr", "wb"); stdout = fopen("stdout", "wb"); SDL_Init(SDL_INIT_EVERYTHING); fprintf(stdout, "SDL INITIALIZED SUCCESSFULLY\n"); SDL_Quit(); fprintf(stderr, "SDL QUIT.\n"); fclose(stderr); fclose(stdout); return 0; } /* 1>------ Build started: Project: opengl_crap, Configuration: Debug Win32 ------ 1>Compiling... 1>main.cpp 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(6) : error C2090: function returns array 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(6) : error C2528: '__iob_func' : pointer to reference is illegal 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(6) : error C2556: 'FILE ***__iob_func(void)' : overloaded function differs only by return type from 'FILE *__iob_func(void)' 1> c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(132) : see declaration of '__iob_func' 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(7) : error C2090: function returns array 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(7) : error C2528: '__iob_func' : pointer to reference is illegal 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(9) : error C2440: '=' : cannot convert from 'FILE *' to 'FILE ***' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(10) : error C2440: '=' : cannot convert from 'FILE *' to 'FILE ***' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(13) : error C2664: 'fprintf' : cannot convert parameter 1 from 'FILE ***' to 'FILE *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(15) : error C2664: 'fprintf' : cannot convert parameter 1 from 'FILE ***' to 'FILE *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(17) : error C2664: 'fclose' : cannot convert parameter 1 from 'FILE ***' to 'FILE *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\documents and settings\owner\my documents\visual studio 2008\projects\opengl_crap\opengl_crap\main.cpp(18) : error C2664: 'fclose' : cannot convert parameter 1 from 'FILE ***' to 'FILE *' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\opengl_crap\opengl_crap\Debug\BuildLog.htm" 1>opengl_crap - 11 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== */

    Read the article

  • Unwanted SDL_QUIT Event on mouseclick.

    - by Anthony Clever
    I'm having a slight problem with my SDL/Opengl code, specifically, when i try to do something on a mousebuttondown event, the program sends an sdl_quit event to the stack, closing my application. I know this because I can make the program work (sans the ability to quit out of it :| ) by checking for SDL_QUIT during my event loop, and making it do nothing, rather than quitting the application. If anyone could help make my program work, while retaining the ability to, well, close it, it'd be much appreciated. Code attached below: #include "SDL/SDL.h" #include "SDL/SDL_opengl.h" void draw_polygon(); void init(); int main(int argc, char *argv[]) { SDL_Event Event; int quit = 0; GLfloat color[] = { 0.0f, 0.0f, 0.0f }; init(); glColor3fv (color); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); draw_polygon(); while(!quit) { while(SDL_PollEvent( &Event )) { switch(Event.type) { case SDL_MOUSEBUTTONDOWN: for (int i = 0; i <= sizeof(color); i++) { color[i] += 0.1f; } glColor3fv ( color ); draw_polygon(); case SDL_KEYDOWN: switch(Event.key.keysym.sym) { case SDLK_ESCAPE: quit = 1; default: break; } default: break; } } } SDL_Quit(); return 0; } void draw_polygon() { glBegin(GL_POLYGON); glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0); glEnd(); SDL_GL_SwapBuffers(); } void init() { SDL_Init(SDL_INIT_EVERYTHING); SDL_SetVideoMode( 640, 480, 32, SDL_OPENGL ); glClearColor (0.0, 0.0, 0.0, 0.0); glMatrixMode( GL_PROJECTION | GL_MODELVIEW ); glLoadIdentity(); glClear (GL_COLOR_BUFFER_BIT); SDL_WM_SetCaption( "OpenGL Test", NULL ); } If it matters in this case, I'm compiling via the included compiler with Visual C++ 2008 express.

    Read the article

  • How to boot linux direct to application on console with no login

    - by amanda
    I have a need to start an application on bootup on the linux console and I do not have a need for any type of login or security. I do not need any ALT-F1,F2,etc virtual consoles but I would like to allow SSH access via the network port for debugging, loading, etc. The application is a SDL graphics program running with fbcon as the SDL_VIDEODRIVER if that matters. I'm currently using Fedora 10 and 12 but any distro that supports SDL using the fbcon framebuffer would be acceptable.

    Read the article

  • OpenGL multiple threads, variable handling [closed]

    - by toeplitz
    I have written an OpenGL program which runs in the following way: Main: - Initialize SDL - Create thread which has the OpenGL context: - Renderloop - Set camera (view) matrix with glUniform. - glDrawElements() .... etc. - Swapbuffers(); - Main SDL loop handling input events and such. - Update camera matrix of type glm::mat4. This is how I pass my camera object to the class that handles opengl. Camera *cam = new Camera(); gl.setCam(cam); where void setCam(Camera *camera) { this->camera = camera; } For rendering in the opengl context thread, this happens: glm::mat4 modelView = camera->view * model; glUniformMatrix4fv(shader->bindUniform("modelView"), 1, GL_FALSE, glm::value_ptr(modelView)); In the main program where my SDL and other things are handles I then recompute the view matrix. This his working fine without me using any mutex locks. Is this correct? On the other hand, I add objects to my scene by an "upload queue" and in this case I have to mutex lock my upload queue vector (vector class type) when adding items to it or else the program crashes. In summary: I recompute my matrix in a different thread and then use it in the opengl thread without any mutex lock. Why is this working? Edit: I think my question is similar to what was asked here: Should I lock a variable in one thread if I only need it's value in other threads, and why does it work if I don't?, only in my case it is even more simple with only one matrix being changed.

    Read the article

  • C++ Linker Error SDL Image - could not read symbols

    - by Matt H
    Hi, I'm trying to use the SDL_Image library and I've added the .so to the link libraries list for my project (I'm using Code::Blocks, by the way). After doing this, when I go to compile, I get this error: Linking console executable: bin/Debug/ttfx /usr/lib32/libSDL_image-1.2.so: could not read symbols: File in wrong format What does this mean and how can I get it working? Thanks!

    Read the article

  • Mandatory Embedded schema field not throwing excepiton when empty in SDL Tridion 2011

    - by user1733557
    I am pulling back to the basic schema questions in Tridion 2011. I have an embedded schema with three optional fields and I referred this schema in a content schema and marked it as mandatory. When I create a component and save it without entering data to this mandatory field; CME is not throwing any exception and proceeds with saving. Please let me know if there are any patches to resolve this issue. Thanks in advance.

    Read the article

  • Using ret with FASM on Win32

    - by Jon Purdy
    I'm using SDL with FASM, and have code that's minimally like the following: format ELF extrn _SDL_Init extrn _SDL_SetVideoMode extrn _SDL_Quit extrn _exit SDL_INIT_VIDEO equ 0x00000020 section '.text' public _SDL_main _SDL_main: ccall _SDL_Init, SDL_INIT_VIDEO ccall _SDL_SetVideoMode, 640, 480, 32, 0 ccall _SDL_Quit ccall _exit, 0 ; Success, or ret ; failure. With the following quick-and-dirty makefile: SOURCES = main.asm OBJECTS = main.o TARGET = SDLASM.exe FASM = C:\fasm\fasm.exe release : $(OBJECTS) ld $(OBJECTS) -LC:/SDL/lib/ -lSDLmain -lSDL -LC:/MinGW/lib/ -lmingw32 -lcrtdll -o $(TARGET) --subsystem windows cleanrelease : del $(OBJECTS) %.o : %.asm $(FASM) $< $@ Using exit() (or Windows' ExitProcess()) seems to be the only way to get this program to exit cleanly, even though I feel like I should be able to use retn/retf. When I just ret without calling exit(), the application does not terminate and needs to be killed. Could anyone shed some light on this? It only happens when I make the call to SDL_SetVideoMode().

    Read the article

  • How do I use SDl_Threads properly?

    - by Anoymonous
    I am new to threads,SDL and how graphic work in general. I've been looking through all of LazyFoo's SDL tutorials, and had helped me greatly. But in his tutorials about multi threading, he commented that you should never use video functions in separate threads, or might cause problem. I am curious how it should be done, as I still have a vague understanding of graphics and threads. As one of my projects is a shoot'em up, I was wondering if I should create one thread that displays all the graphics, one threads receives all the player input for his ship, and another thread for the enemy AI. If this is NOT how it should be done, (I think it's wrong) does anyone have any advice of how graphics should be implemented with user input and enemy AI with threads? For the Lazyfoo's tutorials, this is the link: http://lazyfoo.net/SDL_tutorials/

    Read the article

  • Newly installed 12.04 on Radeon or NVIDIA type of gfx card?

    - by Falk
    I use a Nvidia Quadro NVS 290/PCIe/SSE2 at work with dual monitor setup. Since 11.10 things has gone downwards with performance. But now with 12.04 performance is even worse, and I can agree that the 290 is old and puny. So when I look what low profile cards I can get to my computer today, the choice it Radeon HD 6570 or NVIDIA Quadro 600. I have always used Nvidia on linux beq I think that historically their drivers worked better. But which one do you recommend today on 12.04 and Unity3d? -- Regards Falk

    Read the article

  • SDL 2 passe à la version 2.0.1, la bibliothèque de création d'applications multimédias en deux dimensions améliore les performances d'OpenGL ES 2

    SDL 2 reçoit une mise à jour mineure et passe en version 2.0.1 Cette version n'apporte aucune fonctionnalités mais permet de stabilisé la bibliothèque et de la rendre plus performante. Voici la liste des correctifs :Général : ajout de fonctions pour récupérer les chemins commun du système de fichiers dans SDL_filesystem.h : SDL_GetBasePath(), SDL_GetPrefPath() ; ajout d'une fonction pour optimiser les mis à jour de textures YV12 et IYUV : SDL_UpdateYUVTexture() ; ajout d'une fonction...

    Read the article

  • How can I make a program (using SDL) built on Ubuntu work on other systems?

    - by halifar
    Hi there, I'm writing a program that uses OpenAL. When I link against it (I'm using CMake), it also links against libpulse - PulseAudio. This results in the binary not working on other systems. Can I somehow not link against PulseAudio and still use OpenAL on Ubuntu? Edit: I just figured something out: It's not OpenAL that's dragging PulseAudio in, it's SDL. Is there anything I can do about that?

    Read the article

  • SDL_GL_SwapBuffers Segfault

    - by RyanG
    I'm getting a segfault that GDB says is coming from SDL_GL_SwapBuffers. However, I can't imagine why. The SDL documentation mentions no specific pre-conditions for calling swapBuffers except that double buffering be allowed. Is this an option I have to turn on while initializing OpenGL or is this a hardware capability thing? My code: http://pastie.org/859721 (Ignore the unused variables, strange comments and other things. I haven't prettied this up at all. :P)

    Read the article

  • How do I create a curved line or filled circle or generally a circle using C++/SDL?

    - by NoobScratcher
    Hello I've been trying for ages to make a pixel circle using the putpixel function provided by SDL main website here is that function : void putpixel(int x,int y , int color , SDL_Surface* surface) { unsigned int *ptr = static_cast <unsigned int *> (surface->pixels); int offset = y * (surface->pitch/sizeof(unsigned int)); ptr[offset + x] = color; } and my question is how do I curve a line or create an circle arc of pixels or any other curved shape then a rectangle or singular pixel or line. for example here are some pictures filled pixel circle below enter link description here now my idea was too change the x and y value of the pixel position using + and - to create the curves but in practice didn't provide the correct results what my results are in this is to be able to create a circle that is made out of pixels only nothing else. thank you for anyone who takes the time to read this question thanks! :D

    Read the article

  • Sprite movement

    - by Lemmons
    Hi everyone. I'm ripping my hair out over this one. For some odd reason I cannot find out / think of how to move a sprite in SFML and or SDL. The tutorials I've looked at for both libraries state nothing about this; so I assume that it's more of a C++ thing than a library thing. So I was wondering; how do you move a sprite? (When I say move, I mean have the sprite "glide" across the window at a set speed)

    Read the article

  • Graphic programming over video playback

    - by ignatius
    I want to make some GUI mockup program for video player, so my idea is just to show some menu pictures over real video being playback. I have working program made with C and SDL just to load pictures and make a slideshow, but i don´t know how to put this over video with transparencies. Do you have a hint? ps. i usually program with python and C, so if there is any solution with this two i highly appreciate. Thanks!

    Read the article

  • SDL_ttf and Numbers (int)

    - by jack moore
    int score = 0; char* fixedscore=(char*)score; . . . imgTxt = TTF_RenderText_Solid( font, fixedscore, fColor ); ^^ This doesn't work - looks like fixedscore is empty or doesn't exists. int score = 0; char* fixedscore=(char*)score; . . . imgTxt = TTF_RenderText_Solid( font, "Works fine", fColor ); ^^ Works fine, but... I guess converting int to char* doesn't really work. So how do you print scores in SDL? Oh and one more thing: why is the text so ugly? Any help would be appreciated. Thanks.

    Read the article

  • C++ union assignment, is there a good way to do this?

    - by Sqeaky
    I am working on a project with a library and I must work with unions. Specifically I am working with SDL and the SDL_Event union. I need to make copies of the SDL_Events, and I could find no good information on overloading assignment operators with unions. Provided that I can overload the assignment operator, should I manually sift through the union members and copy the pertinent members or can I simply come some members (this seems dangerous to me), or maybe just use memcpy() (this seems simple and fast, but slightly dangerous)? If I can't overload operators what would my best options be from there? I guess I could make new copies and pass around a bunch of pointers, but in this situation I would prefer not to do that. Any ideas welcome!

    Read the article

  • Application Distribution

    - by FrozenWasteland
    I have a SDL app that compiles fine, and the images show up, but only if they are in the correct folder with the binary next to them, if the images are moved they wont show up next time the application is run. How can I make a complete binary that will allow me to compile the images as well as the code, so that I can distribute one single binary, and not a zip file with all of my assets. I have looked into writing a .deb file which is what I think I need, but the process looked complicated. I am running Ubuntu 10.10 I only need to distribute to Ubuntu

    Read the article

  • Slick2D Rendering Lots of Polygons

    - by Hazzard
    I'm writing an little isometric game using Slick. The world terrain is made up of lots of quadrilaterals. In a small world that is 128 by 128 squares, over 16,000 quadrilaterals need to be rendered. This puts my pretty powerful computer down to 30 fps. I've though about caching "chunks" of the world so only single chunks would ever need updating at a time, but I don't know how to do this, and I am sure there are other ways to optimize it besides that. Maybe I'm doing the whole thing wrong, surely fancy 3D games that run fine on my machine are more intensive than this. My question is how can I improve the FPS and am I doing something wrong? Or does it actually take that much power to render those polygons? -- Here is the source code for the render method in my game state. It iterates through a 2d array or heights and draws polygons based on the height. public void render(GameContainer container, StateBasedGame game, Graphics gfx) throws SlickException { gfx.translate(offsetX * d + container.getWidth() / 2, offsetY * d + container.getHeight() / 2); gfx.scale(d, d); for (int y = 0; y < placeholder.length; y++) {// x & y are isometric // diag for (int x = 0; x < placeholder[0].length; x++) { Polygon poly; int hor = TestState.TILE_WIDTH * (x - y);// hor and ver are orthagonal int W = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y + 1][x];//points to go off of int S = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y + 1][x + 1]; int E = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y][x + 1]; int N = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y][x]; if (placeholder[y][x] == null) { poly = new Polygon();//Create actual surface polygon poly.addPoint(-TestState.TILE_WIDTH + hor, W); poly.addPoint(hor, S + TestState.TILE_HEIGHT); poly.addPoint(TestState.TILE_WIDTH + hor, E); poly.addPoint(hor, N - TestState.TILE_HEIGHT); float z = ((float) heights[y][x + 1] - heights[y + 1][x]) / 32 + 0.5f; placeholder[y][x] = new Tile(poly, new Color(z, z, z)); //ShapeRenderer.fill(placeholder[y][x]); } if (true) {//ONLY draw tile if it's on screen gfx.setColor(placeholder[y][x].getColor()); ShapeRenderer.fill(placeholder[y][x]); //gfx.fill(placeholder[y][x]); //placeholder[y][x]. //DRAW EDGES if (y + 1 == placeholder.length) {//draw South foundation edges gfx.setColor(Color.gray); Polygon found = new Polygon(); found.addPoint(-TestState.TILE_WIDTH + hor, W); found.addPoint(hor, S + TestState.TILE_HEIGHT); found.addPoint(hor, TestState.TILE_HEIGHT * (x + y + 1)); found.addPoint(-TestState.TILE_WIDTH + hor, TestState.TILE_HEIGHT * (x + y)); gfx.fill(found); } if (x + 1 == placeholder[0].length) {//north gfx.setColor(Color.darkGray); Polygon found = new Polygon(); found.addPoint(TestState.TILE_WIDTH + hor, E); found.addPoint(hor, S + TestState.TILE_HEIGHT); found.addPoint(hor, TestState.TILE_HEIGHT * (x + y + 1)); found.addPoint(TestState.TILE_WIDTH + hor, TestState.TILE_HEIGHT * (x + y)); gfx.fill(found); }//*/ } } } }

    Read the article

  • Help with SDL_mixer (no sound)

    - by Kaizoku
    Hello, I have this strange problem with SDL_mixer, it doesn't want to play music. It doesn't throw any error, it just skips it. Any advice? I am compiling on linux with libvorbis. audio.h #ifndef AUDIO_H #define AUDIO_H #include <string> #include <SDL/SDL_mixer.h> class Audio { private: Mix_Music *music; public: Audio(); virtual ~Audio(); public: void setMusic(std::string path); void playMusic(); }; #endif /* AUDIO_H */ audio.cpp #include "Audio.h" #include <stdexcept> Audio::Audio() { if (0 == Mix_Init(MIX_INIT_OGG)) throw std::runtime_error(Mix_GetError()); if (-1 == Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096)) throw std::runtime_error(Mix_GetError()); } Audio::~Audio() { Mix_FreeMusic(music); Mix_Quit(); } void Audio::setMusic(std::string path) { music = Mix_LoadMUS(path.c_str()); if (NULL == music) throw std::runtime_error(Mix_GetError()); } void Audio::playMusic() { if (NULL != music) { if (-1 == Mix_PlayMusic(music, -1)) throw std::runtime_error(Mix_GetError()); } }

    Read the article

  • 2D Platformer Collision Problems With Both Axes

    - by AusGat
    I'm working on a little 2D platformer/fighting game with C++ and SDL, and I'm having quite a bit of trouble with the collision detection. The levels are made up of an array of tiles, and I use a for loop to go through each one (I know it may not be the best way to do it, and I may need help with that too). For each side of the character, I move it one pixel in that direction and check for a collision (I also check to see if the character is moving in that direction). If there is a collision, I set the velocity to 0 and move the player to the edge of the tile. My problem is that if I check for horizontal collisions first, and the player moves vertically at more than one pixel per frame, it handles the horizontal collision and moves the character to the side of the tile even if the tile is below (or above) the character. If I handle vertical collision first, it does the same, except it does it for the horizontal axis. How can I handle collisions on both axes without having those problems? Is there any better way to handle collision than how I'm doing it?

    Read the article

  • C++: Maybe you know this pitfall?

    - by Martijn Courteaux
    Hi, I'm developing a game. I have a header GameSystem (just methods like the game loop, no class) with two variables: int mouseX and int mouseY. These are updated in my game loop. Now I want to access them from Game.cpp file (a class built by a header-file and the source-file). So, I #include "GameSystem.h" in Game.h. After doing this I get a lot of compile errors. When I remove the include he says of course: Game.cpp:33: error: ‘mouseX’ was not declared in this scope Game.cpp:34: error: ‘mouseY’ was not declared in this scope Where I want to access mouseX and mouseY. All my .h files have Header Guards, generated by Eclipse. I'm using SDL and if I remove the lines that wants to access the variables, everything compiles and run perfectly (*). I hope you can help me... This is the error-log when I #include "GameSystem.h" (All the code he is refering to works, like explained by the (*)): In file included from ../trunk/source/domein/Game.h:14, from ../trunk/source/domein/Game.cpp:8: ../trunk/source/domein/GameSystem.h:30: error: expected constructor, destructor, or type conversion before ‘*’ token ../trunk/source/domein/GameSystem.h:46: error: variable or field ‘InitGame’ declared void ../trunk/source/domein/GameSystem.h:46: error: ‘Game’ was not declared in this scope ../trunk/source/domein/GameSystem.h:46: error: ‘g’ was not declared in this scope ../trunk/source/domein/GameSystem.h:46: error: expected primary-expression before ‘char’ ../trunk/source/domein/GameSystem.h:46: error: expected primary-expression before ‘bool’ ../trunk/source/domein/FPS.h:46: warning: ‘void FPS_SleepMilliseconds(int)’ defined but not used This is the code which try to access the two variables: SDL_Rect pointer; pointer.x = mouseX; pointer.y = mouseY; pointer.w = 3; pointer.h = 3; SDL_FillRect(buffer, &pointer, 0xFF0000);

    Read the article

  • Can't get my object to point at the mouse.

    - by melignus
    I'm using a combination of SDL and OpenGL in a sort of crash course project to teach myself how this all works. I'm really only interested in OpenGL as a way to use acceleration in 2D games so I just need this to work in a 2D plane. I have been having a lot of problems today with my current issue, I would like an object to point towards the mouse while the mouse button is clicked and then of course stay pointing in that direction after the mouse is lifted. void Square::handle_input() { //If a key was pressed if( event.type == SDL_KEYDOWN ) { //Adjust the velocity switch( event.key.keysym.sym ) { case SDLK_UP: upUp = false; yVel = -1; break; case SDLK_DOWN: downUp = false; yVel = 1; break; case SDLK_LEFT: leftUp = false; xVel = -1; break; case SDLK_RIGHT: rightUp = false; xVel = 1; break; case SDLK_w: wUp = false; sAng = 1; break; case SDLK_s: sUp = false; sAng = -1; break; } } //If a key was released else if( event.type == SDL_KEYUP ) { //Adjust the velocity switch( event.key.keysym.sym ) { case SDLK_UP: upUp = true; yVel = 0; break; case SDLK_DOWN: downUp = true; yVel = 0; break; case SDLK_LEFT: leftUp = true; xVel = 0; break; case SDLK_RIGHT: rightUp = true; xVel = 0; break; case SDLK_w: wUp = true; sAng = 0; break; case SDLK_s: sUp = true; sAng = 0; break; } } //If a mouse button was pressed if( event.type == SDL_MOUSEBUTTONDOWN ) { switch ( event.type ) { case SDL_MOUSEBUTTONDOWN: mouseUp = false; mousex == event.button.x; mousey == event.button.y; break; case SDL_MOUSEBUTTONUP: mouseUp = true; break; } } } And then this is called at the end of my Object::Move call which also handles x and y translation if (!mouseUp) { xVect = mousex - x; yVect = mousey - y; radAng = atan2 ( mousey - y, mousex - x ); sAng = radAng * 180 / 3.1415926l; } Right now when I click the object turns and faces down to the bottom left but then no longer changes direction. I'd really appreciate any help I could get here. I'm guessing there might be an issue here with state versus polled events but from all the tutorials that I've been through I was pretty sure I had fixed that. I've just hit a wall and I need some advice!

    Read the article

  • Using SDL2_gfx issues using C++

    - by Lance Zimmerman
    When I use the it with the common.c /common.h files that come with it, if I use the cpp instead of c extension using VS201X I get the LNK2019: unresolved external symbol _SDL_main What that means is if I change the file containing main to test.c it compiles. When I change it back to text.cpp it fails to compile. I think that means it only works as a C compile. Here is the code I copied from SDL2_gfxPrimitives.c. (Spaces added so they would show up.) #include < stdio.h> #include < stdlib.h> #include < string.h> #include < math.h> #include < time.h> #include "common.h" #include "SDL2_gfxPrimitives.h" static CommonState *state; int main(int argc, char* argv[]) { /* Initialize test framework */ state = CommonCreateState(argv, SDL_INIT_VIDEO); return 1; } I need to use the library in C++ but it seems I don't know enough to figure out how. Any help would be appreciated, I've spent two days attempting to figure this out.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >