• Content count

  • Joined

  • Last visited

Community Reputation

570 Good

About leagal4ever

  • Rank
  1. Hello, im having problem with drawing 2D very basic shapes. Questions: 1. How draw Quad just with lines, corner should be sharp. 2. Quad with border and filled color, each with different color. 3. Triangle is again not sharp also bottom line seems to be thiner. 4. Position in code is set to 100, 100 (quad) in window position does not match(y only?) its more like on half so on 300px. Edit: just saw problem there are many width and height to set, forgot one I have added code since its very small and have many mistakes inside. Thanks for help. #include "sdl.h" #include "sdl_opengl.h" #include <iostream> #include <SDL_image.h> #include <string> #include <vector> using std::vector; using std::cout; using std::endl; vector < vector <int> >  points_vec; int WIDTH = 800; int HEIGHT = 600; int main(int argc, char* argv[]) {     //initialize SDL     SDL_Init(SDL_INIT_EVERYTHING);     //Set OpenGL memory usage     SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8);     SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8);     SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8);     SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8);     SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32);     SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);     SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);     //Caption of the window     SDL_WM_SetCaption("Our first game", NULL);     //Size of the window     SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL);     //Specific the clear color     glClearColor(1, 1, 1, 1);// RED, GREEN, BLUE, ALPHA     //What portion of the screen we will display     glViewport(0, 0, WIDTH, HEIGHT);     //Shader model - use this     glShadeModel(GL_SMOOTH);     //2D rendering     glMatrixMode(GL_PROJECTION | GL_MODELVIEW);     //"Save it"     glLoadIdentity();     // Disable depth test     glDisable(GL_DEPTH_TEST);     glEnable(GL_BLEND);     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);     //Handle the main loop     bool isRunning = true;     //For handling with event     SDL_Event event;     // Main game loop     while(isRunning)     {         // events         while( SDL_PollEvent(&event) )         {             if( event.type == SDL_QUIT )             {                 isRunning = false;             }         }         //RENDERING to the screen         glClear(GL_COLOR_BUFFER_BIT);         glPushMatrix();             glOrtho(0, WIDTH, HEIGHT, 0, -1, 1);//Set the matrix             glColor4ub(0, 0, 0, 255);                  glLineWidth(10);             // quad with lines             glBegin(GL_LINES);                 glVertex2d(100, 100);                 glVertex2d(200, 100);                 glVertex2d(200, 100);                 glVertex2d(200, 200);                 glVertex2d(200, 200);                 glVertex2d(100, 200);                 glVertex2d(100, 200);                 glVertex2d(100, 100);                        glEnd();                // triangle with lines             glBegin(GL_LINES);                 glVertex2d(300, 300);                 glVertex2d(400, 400);                 glVertex2d(400, 400);                 glVertex2d(200, 400);                 glVertex2d(200, 400);                 glVertex2d(300, 300);                      glEnd();         glPopMatrix();         SDL_GL_SwapBuffers();     }     SDL_Quit();     return 0; }.h>
  2. key press in vector

    Hello, im changing handling how keys are pressed, basicly im having number keys 1-9 and for each key same function is run. case SDLK_1: KeyPress(1); break; case SDLK_2: KeyPress(2); break;   it should look like this std::vector < SDLKey > numberEnum_vec; numberEnum_vec.push_back( SDLK_1 ); numberEnum_vec.push_back( SDLK_2 ); for(int i=0; i<numberEnum_vec.size(); i++) { case numberEnum_vec[i+1]: break; } Thanks for answer!
  3. sdl distorted SDL_FillRect and images

    No, Init(); is in constructor it run only once, Render(); , Update(); and Fps(); run every frame
  4. sdl distorted SDL_FillRect and images

    Yeah its tearning. // init SDL_Init(SDL_INIT_EVERYTHING); screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_DOUBLEBUF); // render SDL_FillRect(screen, NULL, 0); for(int i=0; i<box_vec.size(); i++) { SDL_FillRect(screen, &box_vec[i]->rect, box_vec[i]->color); // problem rect } SDL_Flip(screen); // update box_vec[i]->rect.x += box_vec[i]->xvel; box_vec[i]->rect.y += box_vec[i]->yvel;
  5. Hello i have problem with distorted rectangle, this problem also happen with images. [URL=http://imageshack.us/photo/my-images/580/examplejy.png/][IMG]http://img580.imageshack.us/img580/1310/examplejy.png[/IMG][/URL] Distorted rectangle looks like this. Its happen only for moment every few seconds, it become obvious while moving ,any idea how to fix it?
  6. c++, sdl - how to make installer? .exe

    Oh souch silly error as told: [quote name='Lauris Kaplinski' timestamp='1349294053' post='4986513']Just create the proper directory structure, add all relevant .dll and data files and pack it into zip archive.[/quote] I had no idea proper foler is Release folder there were no images i just copy SDL files. SDL_Surface* tmp; tmp = IMG_Load©; SDL_DisplayFormatAlpha(tmp);// problem Problem is there was no image loaded. if (tmp != NULL) SDL_DisplayFormatAlpha(tmp); Now i avoid problem just in case something is not loaded Thans for all help
  7. c++, sdl - how to make installer? .exe

    [url="http://imageshack.us/photo/my-images/337/error2ep.png/"][img]http://imageshack.us/a/img337/6391/error2ep.png[/img][/url] I dont have any warnings have also minimize notices, when click on any Call Stack line only Dissembly lines are changed i dont see my code. [url="http://imageshack.us/photo/my-images/88/error4l.png/"][img]http://imageshack.us/a/img88/3126/error4l.png[/img][/url] When run from Release folder i get window as normal with error message =( I have made copy of project folder take most out and i have build it in Release so must be problem in my code.
  8. c++, sdl - how to make installer? .exe

    Continue is just throwing same window with same message, break give me disassembly tab. [URL=http://imageshack.us/photo/my-images/829/error1ii.png/][IMG]http://imageshack.us/a/img829/4109/error1ii.png[/IMG][/URL] So somewhere in my code is mistake to somehow use NULL pointer, why there is no problem with debug mode?
  9. c++, sdl - how to make installer? .exe

    So to use on another computer it only need to be build as release, insert used files and thats it? I have error when building, any idea how to solve it? Error is only when release, debug is working fine. [URL=http://imageshack.us/photo/my-images/222/errorpo.png/][IMG]http://imageshack.us/a/img222/9387/errorpo.png[/IMG][/URL] @Lauris Kaplinski - didnt know that, sure at start would be better and easier to make simple zip, however for future im interested in installer @JustABeginner - no not polish
  10. Hello i have make part of my game which i want show to other people. I would like to make installer to make game available on every computer with all files included. I am using c++, sdl, sdl_ttf and build game in visual studio 2010 with debug option. Thanks fo help.
  11. c++, sdl - game editor questions

    Hello im making my first game editor and have some questions. 1 I have some const and functions like message which is simple cout, collision, openimage, xypos.. which should be accesable in every class and main, how? 2 I make twodimensional vector for storing grid, also im making option for increasing grid if needed. Increasing at botom and right was easy, however up is making problems (its changing camera going up). Im not sure if this code is ok, code should add add vector at first place at 0. [CODE] if(map[0][0]){// insert UP vector<int> tmpvec; tmpvec.assign(map[0].size(), 0); map.insert(map.begin(), tmpvec); } [/CODE] 3 I have two class menu and map, menu have options like new game, save, load . Map class is saving, loading game. Where is better to put onclick logic? Thanks for answers