• Content count

  • Joined

  • Last visited

Community Reputation

128 Neutral

About Polas22

  • Rank
  1. I take my words back the performance is really good, tried to draw like 60 small objects and get 2000+ draw calls the performance didnt drop below 60fps, it seems the more i draw the less the performence is impacted, if i add even more objects and draw more shadows, then the performence bearly drop.   Tested with 100 small object and I get nearly perfect 60, so if I make good level designe, the performence will be excellent always.
  2. Well no, I use textures, will optimise the code later by drawing on the texture the shadows and only then render them.
  3. Will do it, but its very bruteforce way(found a way to improve it), will post everything and try to add little comments in the code.
  4. As the title say I want to draw 2d shadows only unsing sdl2 without openg, I have done it but the performence isnt the best, I get like from 300fps+ to 90fps+ with 17 rectangles.   video: https://www.youtube.com/watch?v=TJ3oH51sVME Pc Spec: Cpu i3-3110M Gpu Nvidia 630M Render everything in: 1280x720   when I get low fps My shadow drawing algorithm call 300+ drawing call to draw shadow for every object thats is on the screen; to draw shadows I use triangles(still rectangle just the texture is triangle) and few rectangles pic:   In the code I calculate the position from the mouse to the rectangle ant how much should the shadow go until it reaches the screen end,the calculation doesnt hit much in performence, but the drawing is just killing everything, I need somehow to lower the drawing calls.   Does anybody know any better way to draw without OpenGL?   Some tutorials that I saw draw the light itself, but I dont know how would I do it with out OpenGL for triangle drawing.             //EDIT: Added source and executable (you can compile the code on android too)  
  5. Yesterday was a big day to me as I realeased my first simple game on Android market. Its is really my first complete game,it was hard, I had to learn a lot of stuff that doesnt have many of tutorials on the internet, how to set up sdk and ndk. This game was developed using 99% c/c++ SDL, the 1% is for creating a highscore file in app directory, had to use jni(which i still dont understad very well). If removing the jni stuff the game works on Windows and linux, probably even on IOS. The hardest part was the begining and the end, the reason why is because in the begining you dont know from where to start and in the end there is too much stuff, but you get used to it and everything becomes quite easy. The main reason why I created the was to improve my developing skill and to understand game logic, how do they work. Development took about 2 weeks a lot of brainstorming was done, and a lot of motivation was needed. My best friend during the work time was google and sdl wiki, I learned to coding wiki and its just an amazing info source. I worked on the game during the time every day, from like 20min up to whole day. I hope you can test the game and leave feedback at google store thx. TLDR: it was hard, but I did it.     You can download the game from here: https://play.google.com/store/apps/details?id=org.Snake_.app
  6. SDL and android?

    I recently released an android game develped on Android using C/C++ and SDL, what can I say is that the pc code is 99% the same as the android and I think I would use the same code on IOS,Linux and MacOS.
  7. Normali the coordinates should be from 0 to 64 in that arena, but not from 0 to 1. The are which shows coordinates from 0 to 1 is the same size as the white cube.
  8. [quote name='Ectara' timestamp='1333559867' post='4928246'] Just a quick question, is the origin for your screen at the top, as one might guess for a plain array of pixels, or at the bottom, which one might expect from a Cartesian sense? [/quote] The cube is rendered but under the cube mouse coordinates are wrong, in that area witch is in the picture the coordinates are X from 0 to 1 and, y from 0 to 1, but when the cursor goes out of hat are the coordinates sudenly become much bigger.
  9. As the title says, I am getting wrong mouse information in specific area Here is the picture in wich are I get wrong coordinates: [img]http://img26.imageshack.us/img26/4752/lolmh.png[/img] The code: [CODE] #include "SDL.h" #include <SDL_opengl.h> #include <GL/glu.h> #include <sstream> int SCREEN_WIDTH = 800; int SCREEN_HEIGHT = 640; const int SCREEN_BPP = 32; const int FRAMES_PER_SECOND = 60; SDL_Surface *surface; SDL_Event event; GLvoid ReSizeGLScene(GLsizei width, GLsizei height) { if (height==0) // Prevent A Divide By Zero By { height=1; // Making Height Equal One } glViewport( 0, 0, width, height ); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); gluPerspective( 45.0f, ( GLfloat )width / ( GLfloat )height, 0.1f, 100.0f ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); } int initGL( GLvoid ) { glEnable(GL_TEXTURE_2D); // Enable Texture Mapping ( NEW ) glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations return TRUE ; } void clean_up() { //Quit SDL SDL_Quit(); } void GLDRAW(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,0.0f,-10.0f); glBegin(GL_QUADS); // Draw A Quad glVertex3f(0.0f , 0.64f, 0.0f); // Top Left glVertex3f(0.64f ,0.64f, 0.0f); // Top Right glVertex3f(0.64f ,0.0f , 0.0f); // Bottom Right glVertex3f(0.0f , 0.0f , 0.0f); // Bottom Left glEnd(); } int Timer() { int startTicks = 0; startTicks = SDL_GetTicks(); return SDL_GetTicks() - startTicks; } int main( int argc, char *argv[] ) { //Quit flag bool quit = false; if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 ) { return false; } if( SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL ) == NULL ) { return false; } initGL( ); ReSizeGLScene( SCREEN_WIDTH, SCREEN_HEIGHT ); int x = 0, y = 0; float x3d,y3d,z3d; //Wait for user exit while( quit == false ) { //Start the frame timer //While there are events to handle while( SDL_PollEvent( &event ) ) { if( event.type == SDL_MOUSEMOTION ) { x = event.motion.x; y = event.motion.y; GLdouble model_view[16]; glGetDoublev(GL_MODELVIEW_MATRIX, model_view); GLdouble projection[16]; glGetDoublev(GL_PROJECTION_MATRIX, projection); GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); double dx; double dy; double dz; GLfloat depth[2]; glReadPixels (x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, depth); gluUnProject(x, y, depth[0], model_view, projection, viewport, &dx, &dy, &dz); x3d = float(dx); y3d = float(dy); z3d = float(dz); } if( event.type == SDL_QUIT ) { quit = true; } } //Clear the screen glClear( GL_COLOR_BUFFER_BIT ); //Show the square GLDRAW(); //Update screen SDL_GL_SwapBuffers(); std::stringstream time; time << "X: " << x3d << " Y: " << y3d; SDL_WM_SetCaption( time.str().c_str(), NULL ); } //Clean up clean_up(); return 0; } [/CODE]
  10. [C++/OpenGL] Can't load multyple textures.

    [quote name='yckx' timestamp='1332781822' post='4925402'] Shouldn't you call glGenTextures before SOIL_load_Ogl_texture, rather than after it? Or am I misremembering my OpenGL? [/quote] Still the same..
  11. I am trying to create multyple texture with soil, but when I compile I only see white cube without textures. I think glGenTextures is causing the problem, because without it textures load. Can I use SOIL and glGentextures? [CODE] int LoadGLTextures() // Load Bitmaps And Convert To Textures { /* load an image file directly as a new OpenGL texture */ texture[0] = SOIL_load_OGL_texture ( "lol.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y ); if(texture[0] == 0) return false; glGenTextures(3,&texture[0]); // Create Nearest Filtered Texture glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // ( NEW ) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); // ( NEW ) // Typical Texture Generation Using Data From The Bitmap glBindTexture(GL_TEXTURE_2D, texture[1]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Create MipMapped Texture glBindTexture(GL_TEXTURE_2D, texture[2]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); // ( NEW ) return true; // Return Success } [/CODE]
  12. I get this error when I link SOIL.lib [CODE] 1>------ Build started: Project: OpenGL, Configuration: Debug Win32 ------ 1>SOIL.lib(stb_image_aug.o) : error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer 1>SOIL.lib(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2 1>C:\Users\Pc\Documents\Visual Studio 2010\Projects\Project\Debug\OpenGL.exe : fatal error LNK1120: 2 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== [/CODE] SOLVED: Needed to rebuild the lib. Used the vc8 project.
  13. SDL move an image to specific coordinates

    found solution: Bresenham Line Drawing algorithm: [code]if (CU_UP == true) { double x1 = mousex - x; //mousex - mouse x coordinate; x -image x coordinate double y1 = mousey - y; //mousey - mouse y coordinate; y -image y coordinate double length = sqrt( x1*x1 + y1*y1 ); double xVel = x1 / length; double yVel = y1 / length; apply_surface( (int)x, (int)y, cube, screen, &clipsLeft[ 0 ] ); x += xVel ; y += yVel ; }[/code]
  14. SDL move an image to specific coordinates

    but how do I move image by vector on x y coord? I want the image to follow mouse coordinates. So if I press up arrow it would go to that direction.