Scet

Members
  • Content count

    2127
  • Joined

  • Last visited

Community Reputation

960 Good

About Scet

  • Rank
    GDNet+
  1. Thanks, problem was that building the texture resets the filter states.
  2. Hello, I'm working on an OpenGL project and am attemping to use a volume texture as a texture atlas. The problem is that when I try to test it by rendering one of the slices, I just get a white square. I know that the data in the atlas is correct because I exported it. Here are the relevent functions: uint32_t atlas_build( uint32_t type ) { atlas_t* atlas; atlas = atlases[type]; if( atlas->modified ) { atlas->modified = 0; glDeleteTextures( 1, &atlas->handle ); glGenTextures( 1, &atlas->handle ); glBindTexture( GL_TEXTURE_3D, atlas->handle ); glTexImage3D( GL_TEXTURE_3D, 0, 4, atlas->width, atlas->height, atlas->depth, 0, GL_RGBA, GL_UNSIGNED_BYTE, atlas->data ); } return atlas->handle; } void video_initialize( int32_t count, int8_t** arguments ) { video_parse( count, arguments ); if( SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ) == -1 ) { log_print( LOG_ERROR, "SDL_GL_SetAttribute failed in video_initialize" ); } if( SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ) == -1 ) { log_print( LOG_ERROR, "SDL_GL_SetAttribute failed in video_initialize" ); } if( SDL_SetVideoMode( SCREENWIDTH, SCREENHEIGHT, 32, ( SDL_OPENGL | SDL_SWSURFACE ) ) == NULL ) { log_print( LOG_ERROR, "SDL_SetVideoMode failed in video_initialize" ); } glewInit(); glShadeModel( GL_FLAT ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClearDepth( 1.0f ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); glEnable( GL_TEXTURE_3D ); glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glViewport( 0, 0, SCREENWIDTH, SCREENHEIGHT ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45.0f, (GLfloat)SCREENWIDTH / (GLfloat)SCREENHEIGHT, 0.1f, 1000.0f ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); return; } void video_run( void ) { uint32_t error; glBindTexture( GL_TEXTURE_3D, atlas_build( ATLAS_TEXTURES ) ); error = glGetError(); glBegin( GL_QUADS ); //glColor3f( 1.0f, 1.0f, 1.0f ); glTexCoord3f( 0.0f, 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, -3.0f ); glTexCoord3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 1.0f, -1.0f, -3.0f ); glTexCoord3f( 1.0f, 1.0f, 0.0f ); glVertex3f( 1.0f, 1.0f, -3.0f ); glTexCoord3f( 0.0f, 1.0f, 0.0f ); glVertex3f( -1.0f, 1.0f, -3.0f ); glEnd(); SDL_GL_SwapBuffers(); return; } The dimensions are 2048*2048*2, which my video card does support. I've tried different formats for glTexImage3D, but nothing has worked. glGetError returns zero. I've tried Google, but there isn't a lot of info on 3D textures. [Edited by - Scet on April 21, 2010 3:16:26 PM]
  3. Why exactly do you need this information? I ask because usually the people asking your question don't know about orthographic projection and foolishly try to do 2D in perspective.
  4. Quote:Original post by jmpeer I tried malloc, but it didn't make a difference in this case. Oh I bet it did since bensmith87 is correct. There's a reason it's called "re-allocate", you need to allocate first. Quote:Original post by jmpeer Now, it executes, but the size still does not change. Well of course it doesn't, sizeof is a compile-time constant. sizeof(*(array.data)) is the same as sizeof(Data), which is good because otherwise your first printf would crash due to array.data not being allocated. If malloc was successful then the memory is allocated, use array.data[1] to access it. Edit: Antheus why did you delete your post? I was about to delete this one, good thing I noticed.
  5. I want another program of mine to send "virtual" key press to another(an SDL program to be specific). I've been able to get SendInput to work, but it seems like a horrible hack. I'd like something that doesn't require the window be in focus, because all the functions to tell if a window is in focus(IsVisible,GetForegroundWindow) will report it is in focus even when still switching or drawing. I've tried sending messages to the handle with SendMessage/PostMessage, but that doesn't work at all. Does anyone know of a better way?
  6. STM8S-Discovery review and tutorial

    Holy hell, I just had to comment because this is the longest journal entry I've ever seen! This should seriously be made into an article, hopefully the staff see it. Any plans to hook it up to a TV like the Atmel project? That's a lot cooler than blinking some LEDs.
  7. PixelToaster in Haskell

    HSDL, is a Haskell wrapper for SDL.
  8. Pirates!

    I thought this thread was going to be about Pirates!.
  9. Doom Graphics Programming

    http://doom.wikia.com/wiki/Doom_rendering_engine
  10. You could create a union that contains both types of function pointers. If you want to be truly evil you can cast the functions address to a void pointer and then cast it back to the correct type when you want to call it, but beware the evil involved.
  11. dieing in drscheme

    stonemetals approach could also work for question 1. 1. Create a function to test if an integer is even and positive. 2. Filter the list. 3. If the resulting list is empty, return false. Otherwise find the highest integer in it.
  12. Quote:Original post by ManaStone they just use a pencil to mark the ballots so they would have to be counted by hand Not necessarily. Here in Canada ballets are also marked in pencil, but they are machine counted. Results are usually available on election night.
  13. That's not it. If I check the projected Y values, they are wrong, and that's before anything is drawn. There's something wrong with either spMultMatrixVertex, spPerspective or spProject.
  14. Hi, I have a very simple problem with my software rasterizer that I think is realted to faulty matrix math. Basically the Y axis is flipped, negative is "up" and positive is "down". This is with the model view matrix set as identity. Here is my matrix code: #include <math.h> #include "sp_matrix.h" #include "sp_state.h" #include "sp_viewport.h" /***************************** local constants *****************************/ #define SP_CURRENT_MATRIX 0x0023 /***************************** local variables *****************************/ static SPfloat ModelViewStack[1][16]; static SPfloat ProjectionStack[1][16]; /*static*/ SPfloat* StackPointer[2] = { ModelViewStack[0], ProjectionStack[0] }; static SPboolean WorldInvalid = SP_TRUE; static SPfloat WorldMatrix[16]; /***************************** local functions *****************************/ static SPvoid spMatrixMultiply( SPfloat* left, SPfloat* right, SPfloat* output ) { SPsize r, c, i; static SPfloat result[16]; for( r = 0; r < 4; r++ ) { for( c = 0; c < 16; c += 4 ) { for( i = 0; i < 4; i++ ) { result[r+c] += ( left[r+(i<<2)] * right[i+c] ); } } } for( i = 0; i < 16; i++ ) { output[i] = result[i]; result[i] = 0; } return; } static SPvoid spMultMatrixVertex( SPfloat* matrix, SPvertex* in, SPvertex* out ) { SPint i; SPfloat* result; for( i = 0, result = &out->X; i < 4; i++, result++ ) { *result = ( ( in->X * matrix[i] ) + ( in->Y * matrix[4+i] ) + ( in->Z * matrix[8+i] ) + ( in->W * matrix[12+i] ) ); } return; } /***************************** global functions *****************************/ SPvoid spLoadIdentity( SPvoid ) { SPfloat identity[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; spLoadMatrix( identity ); return; } SPvoid spLoadMatrix( SPfloat* matrix ) { SPsize i; SPfloat* current; current = spGetStateV( SP_CURRENT_MATRIX ); for( i = 0; i < 16; i++ ) { current[i] = matrix[i]; } WorldInvalid = SP_TRUE; return; } SPvoid spMatrixMode( SPenum mode ) { spSetStateI( SP_MATRIX_MODE, mode ); spSetStateV( SP_CURRENT_MATRIX, StackPointer[mode&1] ); return; } SPvoid spMultMatrix( SPfloat* right ) { SPfloat* left; left = spGetStateV( SP_CURRENT_MATRIX ); spMatrixMultiply( left, right, left ); WorldInvalid = SP_TRUE; return; } SPvoid spPerspective( SPfloat fovy, SPfloat aspect, SPfloat znear, SPfloat zfar ) { SPfloat cot, radians; static SPfloat perspective[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; radians = ( ( fovy * 0.5f ) * ( 3.14159f / 180.0f ) ); cot = (SPfloat)( cos( radians ) / sin( radians ) ); perspective[0] = ( cot / aspect ); perspective[5] = cot; perspective[10] = ( -( zfar + znear ) / ( zfar - znear ) ); perspective[11] = -1.0f; perspective[14] = ( ( -2.0f * znear * zfar ) / ( zfar - znear ) ); perspective[15] = 0.0f; spMultMatrix( perspective ); Viewport.ZFar = zfar; Viewport.ZNear = znear; return; } SPvoid spProject( SPvertex* input, SPvertex* output, SPsize count ) { SPsize i; SPvertex temp; for( i = 0; i < count; i++, input++, output++ ) { input->W = 1.0f; spMultMatrixVertex( StackPointer[0], input, &temp ); spMultMatrixVertex( StackPointer[1], &temp, output ); if( output->W == 0.0f ) { continue; } output->X /= output->W; output->X = ( ( output->X * 0.5f ) + 0.5f ); output->X *= Viewport.Width; output->Y /= output->W; output->Y = ( ( output->Y * 0.5f ) + 0.5f ); output->Y *= Viewport.Height; output->Z = output->W; } return; } SPvoid spTranslate( SPfloat x, SPfloat y, SPfloat z ) { static SPfloat translation[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; translation[12] = x; translation[13] = y; translation[14] = z; spMultMatrix( translation ); return; } After projection the X and Z values are correct, it's just the Y that's wrong. I tried changing "perspective[11] = -1.0f" to "perspective[11] = 1.0f" in spPerspective. That fixed the Y axis, but flipped the X axis. What's wrong? Thanks. Edit: Changing "output->Y = ( ( output->Y * 0.5f ) + 0.5f );" to "output->Y = ( ( output->Y * -0.5f ) + 0.5f );" seems to fix the problem. [Edited by - Scet on September 13, 2009 5:31:07 PM]
  15. Need new Keyboard

    Since you're in Toronto, I would suggest going to Factory Direct and getting this. There's no picture, but I have that model keyboard and it has what you want. Even though it's cheap, mine still works fine after about five years.