dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Stack underflow [Errno 504]

 
dev.gamez.lv Forum Index -> OpenGL
View previous topic :: View next topic  
Author Message
Vecis



Joined: 01 Jan 2007
Posts: 144

PostPosted: Mon Aug 24, 2009 2:27 pm    Post subject: Stack underflow [Errno 504]

Paņēmu code example lai izveidotu plakni ar tekstūru (Python, OpenGL ES), bet rāda tikai baltu blakni (tekstūru nerāda)
Kad izeju no programmas rāda

"Traceback (most recent call list):
File "default.py", line 256, in redraw
glPopMatrix()
gles.GLerror: Stack underflow [Errno 504]"

Un šeit pilns kods:
Code:

import appuifw, key_codes, glcanvas, graphics, e32
from gles import *


WHITE = (255,255,255)
RED = (255,0,0)
BLUE = (0,0,255)
GREEN = (0,255,0)
YELLOW = (255,255,0)
BLACK = (0,0,0)


img1 = graphics.Image.open("E:\\texture1.png")
size1=img1.size


vertices = array(GL_BYTE, 3, (
     [-1,  1,  1],
     [ 1,  1,  1],
     [ 1, -1,  1],
     [-1, -1,  1]
    )
  )

triangles = array(GL_UNSIGNED_BYTE, 3, (
    # front
    [1,0,3],
    [1,3,2]
    )
  )


texcoords = array(GL_BYTE, 2, [
    -1,-1,
    0,-1,
    0,0,
    -1,0])

def resize():
    #Resize handler
    glViewport(0, 0, canvas.size[0], canvas.size[1])
    aspect = float(canvas.size[1]) / float(canvas.size[0])
    glMatrixMode( GL_PROJECTION )
    glLoadIdentity()
    glFrustumf( -1.0, 1.0, -1.0*aspect, 1.0*aspect, 3.0, 1000.0 )

def initgl():
    global render
    #Initializes OpenGL and sets up the rendering environment

    #texture
    texture=glGenTextures(1)
    glBindTexture(GL_TEXTURE_2D, texture)
   
    glClearColorx(0,0,0,65536)# Set the screen background color.
    glEnable( GL_CULL_FACE  )# Enable back face culling.
    glEnable( GL_TEXTURE_2D )
    resize()# Initialize viewport and projection.
    glTexCoordPointerb(texcoords)
    glMatrixMode( GL_MODELVIEW )
    glEnableClientState( GL_VERTEX_ARRAY )# Enable vertex arrays.
    glVertexPointerb(vertices)# Set array pointers.
    #glEnableClientState( GL_COLOR_ARRAY ) # Enable color arrays.
    #glColorPointerub(colors )# Set color pointers.
    glEnableClientState(GL_TEXTURE_COORD_ARRAY)
    #glShadeModel( GL_SMOOTH )# Set the initial shading mode
    glShadeModel( GL_FLAT )
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST )# no perspective correction



def redraw(frame):
    global running,img1,size1
    iFrame = frame
    cameraDistance = 100
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
    if running:
        glPushMatrix()
        glMatrixMode( GL_TEXTURE )
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size1[0], size1[1], 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, img1)
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
        glLoadIdentity()
        glMatrixMode( GL_MODELVIEW )
        glLoadIdentity()
        glTranslatex( 0 , 0  , -cameraDistance << 16)
        glScalef( 15, 15, 15 )
        glDrawElementsub( GL_TRIANGLES, triangles )
        glPopMatrix()


def set_exit():
    global running, canvas
    canvas=None
    running = 0





running = 1
appuifw.app.exit_key_handler=set_exit
appuifw.app.screen = 'full'
canvas=glcanvas.GLCanvas(redraw_callback=redraw, event_callback=None, resize_callback=resize)
appuifw.app.body=canvas


initgl()

while running:
    canvas.drawNow()
    e32.ao_sleep(0.01)


Pagaidām īpaši daudz no tā nesaprotu tāpēc paņēmu exampli, nav ne jausmas kur kļūda rodas.
Back to top
View user's profile Send e-mail
Storm



Joined: 11 Apr 2006
Posts: 742

PostPosted: Mon Aug 24, 2009 4:03 pm    Post subject:

Quote:

GL_STACK_UNDERFLOW is generated if glPopMatrix is called while the current
matrix stack contains only a single matrix.

_________________
Izraadaas ka dazu dev.gamez.lv lietotaaju absurdaa ignorance meedz eksisteet arii augstaakas paakaapees : http://www.gamedev.net/community/forums/topic.asp?topic_id=411552
Back to top
View user's profile
snake5
Indago dalībnieks
Indago dalībnieks


Joined: 27 Jun 2007
Posts: 2590

PostPosted: Mon Aug 24, 2009 4:17 pm    Post subject:

Tas izskaidro erroru, bet es nedomāju, ka tāpēc tekstūras nav..

Man vienreiz bija līdzīga problēma - it kā viss pareizi, bet nerādījās tekstūra. Izrādījās, ka aizmirsu kādu funkciju izsaukt.
Code:
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );

Šķiet, ka šo vēl pie koda vajadzēja pievienot..
_________________
"There are two choices here: "looks good" and "realism"." -- Paul Nettle
Back to top
View user's profile Visit poster's website
Vecis



Joined: 01 Jan 2007
Posts: 144

PostPosted: Mon Aug 24, 2009 4:20 pm    Post subject:

Vajadzēja gan, example arī tikko tika updaeitots. Smile paldies
Back to top
View user's profile Send e-mail
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Mon Aug 24, 2009 6:06 pm    Post subject:

>> glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
šo vajag lietot, ja tev nav mipmapu. Jo defaultā MIN_FILTER vērtība ir GL_NEAREST_MIPMAP_LINEAR, kas atbilst mipmapu izmantošanai. Bet ja nav mipmapu, tad rādīsies melna tekstūra.

>> glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
šo gan nav obligāti izsaukt. Defaultā vērtīa MAG_FILTER'am jau ir GL_LINEAR

>> glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
Šis jālieto, ja tev tekstūras pikseļu rinda nav izlīdzināta pa 4 baitiem rindā (32-bit'u RGBA tā ir izlīdzināta). Uzstādot vērtību 1, tu pasaki OpenGL'am, ka tev izlīdzinājuma nebūs - tb nākamā rinda sekos uzreiz aiz esošās.
Back to top
View user's profile Send e-mail
Vecis



Joined: 01 Jan 2007
Posts: 144

PostPosted: Tue Aug 25, 2009 12:51 pm    Post subject:

Lai arī lielu daļu tā visa nesaprotu, bet paldies, gan noderēs. Smile
Pirmoreiz ar 3D kko mēģinu panākt.
Back to top
View user's profile Send e-mail
Display posts from previous:   
dev.gamez.lv Forum Index -> OpenGL All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group