Member Avatar

Since OpenGL uses the strange system of 1s and 0s to represent location on the screen, I'm trying to figure out how to switch it to standard x, y coordinates like those that are used on a graph. And so far, my searches on the rest of the internet have turned out nothing. So, to clarify: How do I make it so that the bottom left corner is the starting place of 0,0 instead of the center of the screen, which is where OpenGL Defaults it too? Here is my code for reference: #include <iostream> #include <SDL2/SDL.h> #include <string> #include …

Member Avatar
+0 forum 1
Member Avatar

Hey everyone, In addition to... Lazy Foo's Tutorial http://lazyfoo.net/tutorials/SDL/index.php "SDL Game Development" - Shaun Mitchell book are there any other recommended resources (does not have to be SDL) people could suggest? I've already created a console-based text adventure game and am really interested in expanding it into a text-adventure game that has a window and uses interactive media elements. I'm not too familiar with any sort of media libraries but i'd be awesome if i could start learning some. Please let me know if there's any particular library i should know about and, if possible, links to the tutorials. Cheers,

Member Avatar
+0 forum 3
Member Avatar

Having a hard time trying to wrap my head around why my grid system fails, I'm assuming my train of thought is stuck at the moment(akin to writers block). My understanding of grids is while the current cell isn't the last one in the column/row(w/e is horizontal) /*do stuff*/ then increment to the next, else if its the last cell then go to the next "line"(row/column(w/e is vertical)). I guess what I'm asking is what is the problem with my logic and or code? and is there a std::container better suited for this task? (also sorry if this is the …

Member Avatar
+0 forum 1
Member Avatar

I need the way in SDL work with openGL for allow users input String by writing text .

Member Avatar
+0 forum 1
Member Avatar

I have used sdl_ttf in opengl . but i have this error : error LNK1104: cannot open file 'SDL_ttf.lib' i already have tried to remove the "SDL_ttf.lib" , but it didn't useful. i have trid used : lazyfoo.net for setting up the opengl with sdl pls tell me what must i do ? .

Member Avatar
+0 forum 2
Member Avatar

I quickly threw together a drawing program in SDL and I am having a couple of issues with lag. The program lags really hard when the size is larger than about 700x700 pixels, and I cannot find anything other than a couple of SDL_BlitSurface calls to the 'image' surface in the step function. How long does SDL_BlitSurface take? Also the step function returns the image that I want to blit to the screen, as such I call SDL_BlitSurface to blit its return value to the screen surface. How much time would I save by passing the screen surface to my …

Member Avatar
+0 forum 3
Member Avatar

Anybody out there that used Python on an Android system? Something like the subset on http://pygame.renpy.org/

Member Avatar
+0 forum 1
Member Avatar

*Hello people of the DaniWebs! It's been a long time since I've been talking and asking here, under the name of **katmai539**. I've lost account information and also the email address linked to it. I haven't been active in the software development-branch for the past few years but recently I decided to pick up the old habit of coding some stuff, next to my awesome job as a cashier at the local supermarket monopolist Albert Heijn.* Now to BUSINESS! As you can see I'm still using **SDL** for a thing and another. I managed to compile a dll for sdl_draw …

+0 forum 0
Member Avatar

Hi! The keypresses in my new project does not seem to be registered. I've never had this issue before and I don't think it is SDL:s fault this time. Here is the code in main: #include <cstdlib> #include <iostream> #include <SDL.h> #include "playertank.h" int main ( int argc, char** argv ) { SDL_Init(SDL_INIT_VIDEO); SDL_Surface* screen = SDL_SetVideoMode(720, 480, 24, SDL_HWSURFACE|SDL_DOUBLEBUF); SDL_Surface* background = SDL_LoadBMP("Grass.bmp"); SDL_Surface* tank_body = SDL_LoadBMP("TankBody.bmp"); PlayerTank player1(200,200,32,32,10); SDL_SetColorKey( tank_body, SDL_SRCCOLORKEY, SDL_MapRGB(screen->format, 0, 255, 255) ); bool quit = false; while(!quit) { //Controls player1.move(SDL_GetKeyState(NULL)); //logics //draw SDL_BlitSurface(background, NULL,screen,NULL); SDL_BlitSurface(tank_body,NULL,screen,player1.getPos()); SDL_Rect* copy = player1.getPos(); std::cout<<copy->y<<std::endl; SDL_Delay(100); SDL_Flip(screen); } atexit(SDL_Quit); …

Member Avatar
+0 forum 4
Member Avatar

Hi, Im new to SDL, when i compile this example program i got these linker errors first defined here .drectve `/manifestdependency:"type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized [Linker error] undefined reference to `__security_cookie' [Linker error] undefined reference to `_alloca_probe_16' [Linker error] undefined reference to `@__security_check_cookie@4' [Linker error] undefined reference to `_imp____iob_func' [Linker error] undefined reference to `_imp____iob_func' [Linker error] undefined reference to `_imp____iob_func' [Linker error] undefined reference to `__security_cookie' [Linker error] undefined reference to `_alloca_probe_16' [Linker error] undefined reference to `@__security_check_cookie@4' [Linker error] undefined reference to `__security_cookie' [Linker error] undefined reference to `_imp____iob_func' [Linker error] undefined reference to …

+0 forum 0
Member Avatar

So I was trying out SDL_gfx lib and tryed using the rotozoomSurface() [Click Here](http://www.ferzkopp.net/Software/SDL_gfx-2.0/Docs/html/_s_d_l__rotozoom_8h.html#a3cb0c11d5edc929579c807dc7612348c) which should've rotated my surface at runtime, but it seems that whenever I do that my surface turns invisible. It doesn't matter if I predefine the rotation or use it at runtime, the same happens, I've tryed using the other rotation functions, still the same. Any info on this? SDL_Surface* rot = rotozoomSurface(surface[0], 10, 1, 0); surface[0] = rot; SDL_FreeSurface(rot); Later I blit the surface[0] as usual. Note that without the code above the surface blits perfectly.

Member Avatar
+0 forum 6
Member Avatar

So, I'm playing around with SDL and I've come across a bit of a bump. I have one image and I am trying to "free" that image to put on another one. Here is what my code looks like.. [CODE] // I did get a good section of this code from LazyFoo productions. I have modified it // I don't take credit for the parts that LazyFoo productions did. :P int main( int argc, char* args[] ) { //Make sure the program waits for a quit bool quit = false; //Initialize if( init() == false ) { return 1; } …

Member Avatar
+0 forum 3
Member Avatar

Hello, I'm creating a game using SDL, and what I'd like to happen is: if the character jumps on a button, then it'll disappear. However, I cannot find a way of accomplishing this, as all the SDL functions I know of start at runtime and cannot be changed. If I'm wrong, would someone please enlighten me? Is there a way that I can get this accomplished? Thank you for your time!

-1 forum 0
Member Avatar

So im learning SDL to get an idea on game programming for my career as a game developer. I havent done any learning for a couple of months after getting stuck on this problem. So im using a lazyfoo.net tutorial engine. that moves a player and has a collision with a wall. All that works fine. But then i tried adding my own feature, when you press space. It displays a box where you were when you pressed space and there is a collision with that box. I called the function "dropBox". But it doesnt work? i get no errors …

Member Avatar
+0 forum 6
Member Avatar

I'm trying to use Box2D lib with SDL lib. NOTE that I only get the errors below after I link in SDL too. I think i link everything accordingly but in the end when I write up some code i get errors like: 1>------ Build started: Project: box2d test2, Configuration: Debug Win32 ------ 1> main.cpp 1>Box2D.lib(b2PolygonShape.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 1>Box2D.lib(b2BlockAllocator.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 1>Box2D.lib(b2Settings.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value …

Member Avatar
+0 forum 5
Member Avatar

Hi All, I have a doubt regarding SDL programming. Can some one please help me how can i subdivide a Image lets say into 4 parts and then store them in SDL_Surface array. I intend to animate later using these subdivided images by using SDL_BlitSurface function. I am new to SDL,so it would be great if someone could provide some codes for reference. Please note that i am using Microsoft visual c++ 2010 compiler.. Thanks Jatin

Member Avatar
+0 forum 1
Member Avatar

Hello I'm trying to get my game to update the screen and draw graphics on its own I kind of made it happen but it still flickers which you can see in this video I made just too showcase this problem [URL="http://www.youtube.com/watch?v=9j_ZDHr1x_8"]http://www.youtube.com/watch?v=9j_ZDHr1x_8[/URL] Now I really don't know what is causing this its really strange if you look at the code you will know what I mean and here is the code of which the problem lies [url]http://pastebin.com/kvtaUqiM[/url] any solutions would be great thanks :)

Member Avatar
+0 forum 5
Member Avatar

Hi, I'm trying to write text using SDL_ttf I've set up everything according to this tutorial on lazyfoo ([url]http://lazyfoo.net/SDL_tutorials/lesson03/windows/msvsnet2010e/index.php[/url]) but when I compile my program I keep getting this error: fatal error LNK1104: cannot open file 'SDL_ttf.libkernel32.lib' Did anyone have the same problem? I don't know what I'm doing wrong. I'm using Microsoft Visual Studio 2010

+0 forum 0
Member Avatar

Recently I started working with game development and I came with a problem, when I started working with this SDL_image.h library and I can not understand why the program, does not display the image, screen just flashes and disappears, I can't figure out what's the problem. I am using Microsoft Visual C + + Express 2010. Can you help me out?

+0 forum 0
Member Avatar

How do I stop this from happening in SDL [URL="http://i.imgur.com/D6M2X.png"]http://i.imgur.com/D6M2X.png[/URL] where the background just stops. I want it to carry on too the left for ever or atleast the width of the image on the SDL_Surface here is a video to showcase the problem [URL="http://www.youtube.com/watch?v=KROV7eq8RLo"]http://www.youtube.com/watch?v=KROV7eq8RLo[/URL] and here is the code [URL="http://pastebin.com/xQguRnVS"]http://pastebin.com/xQguRnVS[/URL]

Member Avatar
+0 forum 1
Member Avatar

Hi, DaniWeb forum members! I am an above-amateur programmer and this is my first more complex SDL-based program. I am trying to make the menu of a game, but SDL cannot capture the key presses when a single key was pressed. I use only UP and DOWN arrows, in this code fragment i need to switch between the choices of the menu, but when i hit only one arrow key nothing happens. Instead of that when i hit two arrows (might even be UP and LEFT, any two keys), just then SDL_PollEvent() realizes I have hit a button. I have …

Member Avatar
+0 forum 4
Member Avatar

Theres this thing that i dont fully understand. Im using this tutorial: [url]http://lazyfoo.net/SDL_tutorials/lesson08/index.php[/url] and i in here we first set up some surfaces with text and then asign their value to the message and then for some reason we have to reset the message value to 0 in order for the program to quit properly, but if i dont set up the surfaces with text from the start and just set up the message myself when coding the event itself, i dont need to reset it and everything works just fine, whats the deal? I think i wasnt very clear …

Member Avatar
+0 forum 49
Member Avatar

Ok, I found this code after searching for days, and to my delight it actually worked. It loads a TGA file into the memory... but I have no idea about how to load it into an OpenGL texture that I can use to texture a cube. I have literally spent days trying to work on this and I have no idea how to get it to work. Here is the TGA Loader: [URL="http://steinsoft.net/index.php?site=Programming/Code%20Snippets/Cpp/no8"]Link[/URL] Here is my overall code: [CODE] /* ************************************************************************************************ */ /* ****************************** INCLUDES *********************************** */ /* ************************************************************************************************ */ #include "SDL.h" #include "SDL_opengl.h" #include "stdio.h" const int triangle = …

Member Avatar
+0 forum 1
Member Avatar

I was watching a tutorial that says that we first need to check if any direction key was pressed, and only then we check which key was pressed, like this: [CODE]while( running == true ) { while( SDL_PollEvent(&event) ) { if ( event.type == SDL_KEYDOWN ) //checking if any key was pressed { switch( event.key.keysym.sym ) //checking for specific { case SDLK_UP: yC -= 10; break; // yC -coordinates of a surface case SDLK_DOWN: yC +=10; break; } } else if ( event.type == SDL_QUIT ) { running = false; } }[/CODE] But then i tried to do it wihouth …

Member Avatar
+0 forum 1
Member Avatar

So i just started learning SDL and came across "Event driven programming", just wanted to be sure if i understood the tutorial correcly. So lets say by adding: [CODE]SDL_Event event;[/CODE] i add lets say a container that keeps track of every event i do? After that i start using: [CODE]while ( program == true ) { while(SDL_PollEvent(&event) { if ( event.type == SDL_QUIT ) { program = false; } } }[/CODE] If i understand correcly, in the second loop we say that while theres some sort of event ( and we send a list of events ) do the loop …

Member Avatar
+0 forum 2
Member Avatar

Just recently started learning SDL and have this problem, this program should properly display my background and message on the screen, but instead its just a black screen. Did the Blit, did the Flip, maybe im missing something? Heres the code: P.S i know i might forgot to add some simple line or something, but i just cant find it ^^ [CODE]#include <SDL.h> #include <string> SDL_Surface* Load_image(std::string filename) { SDL_Surface* loadedimage = 0; SDL_Surface* optimizedimage = 0; loadedimage = SDL_LoadBMP(filename.c_str()); if ( loadedimage != 0 ) { SDL_Surface* optimizedimage = SDL_DisplayFormat(loadedimage); SDL_FreeSurface(loadedimage); } return optimizedimage; } void apply_surface(int x,int y, …

Member Avatar
+0 forum 2
Member Avatar

I am looking to make a 3D game, I have made plenty of fun ones in 2D using SDL but have yet to attempt a 3D (fps style) game. Does anybody know either a way to do 3D with SDL, or some other similar or easy to use library that would allow me to use 3D?

Member Avatar
+0 forum 13
Member Avatar

How can you play videos in C++, I am quite willing to use more than less any headers, I basically need a code that will work like this: [CODE]#include "PlayVideos.h" int main(int argc, char *argv[]) { SDL_Surface *screen=SDL_SetVideoMode(WINWIDTH,WINHEIGHT,WINBPP,SDL_SWSURFACE); ShowVideo("MyVideo.avi",0,0,screen);//play a video at position 0,0 and apply it to the screen while playing sound return 0; }[/CODE] or if it can't be done via blitting to a screen surface then I would settle for an external command like: [CODE]#include "PlayVideos.h" int main(int argc, char *argv[]) { ShowVideo("MyVideo.avi");//Play a video return 0; }[/CODE] Any Ideas?

Member Avatar
+0 forum 3
Member Avatar

#include "includes.h" #include "constants.h" #include "functions.h" int pscore=0,cscore=0,ppaddle=185,cpaddle=185,ballSpeed = 0,cpuPadSpd = 0,frame = 0; SDL_Surface *screen=NULL,*secondary=NULL,*playerscore=NULL,*cpuscore=NULL,*cpuwin=NULL,*playerwin=NULL; bool gameEnded = false,selectedDiff=false; TTF_Font *font,*humungo; SDL_Event e; //PongBall ball; void cleanup() { SDL_Quit(); SDL_EnableUNICODE(0); exit(0); } bool init() { if (SDL_Init(SDL_INIT_EVERYTHING) == -1) return false; if (TTF_Init() == -1) return false; screen = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,COLORDEPTH,SDL_HWSURFACE); if (screen == NULL) return false; SDL_EnableUNICODE(1); SDL_WM_SetCaption("Pong", NULL); font = TTF_OpenFont("imagine_font.ttf",72); humungo = TTF_OpenFont("denmark.ttf",96); SDL_EnableKeyRepeat(50, 5); cpuwin = TTF_RenderText_Blended(humungo,"You lose!",createColor(255,255,255)); playerwin = TTF_RenderText_Blended(humungo,"You win!",createColor(255,255,255)); return true; } int main (int argc, char *argv[]) { if (!init()) return 1; fillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,0,0,0); secondary = loadImage("c0v3r.png"); applySurface(0,0,secondary,screen); SDL_Flip(screen); SDL_Delay(2500); cleanup(); return 0; …

Member Avatar
+0 forum 4
Member Avatar

Hi, I'm trying to make a pong game on Xcode 3.2 with SDL but nothing displays, just a black window. Codes: [CODE]#include "includes.h" #include "constants.h" #include "functions.h" int pscore=0,cscore=0,ppaddle=185,cpaddle=185,ballSpeed = 0,cpuPadSpd = 0,frame = 0; SDL_Surface *screen=NULL,*secondary=NULL,*playerscore=NULL,*cpuscore=NULL,*cpuwin=NULL,*playerwin=NULL; bool gameEnded = false,selectedDiff=false; TTF_Font *font,*humungo; SDL_Event e; //PongBall ball; void cleanup() { SDL_Quit(); SDL_EnableUNICODE(0); exit(0); } bool init() { if (SDL_Init(SDL_INIT_EVERYTHING) == -1) return false; if (TTF_Init() == -1) return false; screen = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,COLORDEPTH,SDL_HWSURFACE); if (screen == NULL) return false; SDL_EnableUNICODE(1); SDL_WM_SetCaption("Pong", NULL); font = TTF_OpenFont("imagine_font.ttf",72); humungo = TTF_OpenFont("denmark.ttf",96); SDL_EnableKeyRepeat(50, 5); cpuwin = TTF_RenderText_Blended(humungo,"You lose!",createColor(255,255,255)); playerwin = TTF_RenderText_Blended(humungo,"You win!",createColor(255,255,255)); return true; } …

+0 forum 0

The End.