Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

570 Good

About leagal4ever

  • Rank
  1. leagal4ever

    Favor Small Components in Unity

  2. 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>
  3. leagal4ever

    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!
  4. leagal4ever

    sdl distorted SDL_FillRect and images

    No, Init(); is in constructor it run only once, Render(); , Update(); and Fps(); run every frame
  5. leagal4ever

    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->rect, box_vec->color); // problem rect } SDL_Flip(screen); // update box_vec->rect.x += box_vec->xvel; box_vec->rect.y += box_vec->yvel;
  6. Hello i have problem with distorted rectangle, this problem also happen with images. Distorted rectangle looks like this. Its happen only for moment every few seconds, it become obvious while moving ,any idea how to fix it?
  7. leagal4ever

    c++, sdl - how to make installer? .exe

    Oh souch silly error as told: 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
  8. leagal4ever

    c++, sdl - how to make installer? .exe

    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. 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.
  9. leagal4ever

    c++, sdl - how to make installer? .exe

    Continue is just throwing same window with same message, break give me disassembly tab. So somewhere in my code is mistake to somehow use NULL pointer, why there is no problem with debug mode?
  10. leagal4ever

    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. @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
  11. 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.
  12. 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. if(map[0][0]){// insert UP vector<int> tmpvec; tmpvec.assign(map[0].size(), 0); map.insert(map.begin(), tmpvec); } 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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!