forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSPGL Quad Implementation

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
stinkymeat



Joined: 18 Oct 2005
Posts: 10

PostPosted: Fri Oct 21, 2005 10:36 pm    Post subject: PSPGL Quad Implementation Reply with quote

I'm having some problems with my code that is a modified version of the glut example for PSPgl. The main problem is that the code for drawing a triangle works, but its counterpart, the square, doesnt seem to work. As you can see from the code below, both are present, with the triangle code commented out. This code works. The quad code doesnt. I get zero compile errors, but the result on the PSP is a black screen :(

Code snippet in question:
Code:
   GLCHK(glClear(GL_COLOR_BUFFER_BIT));
   GLCHK(glBegin(GL_QUADS));                                              // Draw A Quad
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f(-1.0f, 1.0f, 0.0f));   // Top Left
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f( 1.0f, 1.0f, 0.0f));   // Top Right
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f( 1.0f,-1.0f, 0.0f));   // Bottom Right
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f(-1.0f,-1.0f, 0.0f));   // Bottom Left
   GLCHK(glEnd());                                                         // Done Drawing The Quad



The whole code:
Code:
#include <stdlib.h>
#include <GL/glut.h>


/******* PSP specific debugging ********************************************/
extern void __psp_log (const char *fmt, ...);

/* enable GLerror logging to "ms0:/log.txt" */
#if 1
   #define GLCHK(x)                  \
   do {                        \
      GLint errcode;                  \
      x;                     \
      errcode = glGetError();               \
      if (errcode != GL_NO_ERROR) {            \
         __psp_log("%s (%d): GL error 0x%04x\n",      \
            __FUNCTION__, __LINE__,         \
            (unsigned int) errcode);      \
      }                     \
   } while (0)
#else
   #define GLCHK(x) x
#endif
/******* end of PSP specific debugging *************************************/


static
void reshape (int w, int h)
{
   GLCHK(glViewport(0, 0, w, h));
   GLCHK(glMatrixMode(GL_PROJECTION));
   GLCHK(glLoadIdentity());
   GLCHK(glOrtho(-2, 2, -2, 2, -2, 2));
   GLCHK(glMatrixMode(GL_MODELVIEW));
   GLCHK(glLoadIdentity());
}


static float delta = 1.0;

static
void display (void)
{
   static GLfloat angle;
   angle += delta;

   GLCHK(glMatrixMode(GL_MODELVIEW));
   GLCHK(glLoadIdentity());
   
//   GLCHK(glTranslatef(0.0f, 0.0f, -2.5f));
//   GLCHK(glRotatef(angle * 0.79f, 1.0f, 0.0f, 0.0f));
//   GLCHK(glRotatef(angle * 0.98f, 0.0f, 1.0f, 0.0f));
//   GLCHK(glRotatef(angle * 1.32f, 0.0f, 0.0f, 1.0f));

   GLCHK(glShadeModel(GL_SMOOTH));
   
   GLCHK(glClear(GL_COLOR_BUFFER_BIT));
   GLCHK(glBegin(GL_QUADS));                                              // Draw A Quad
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f(-1.0f, 1.0f, 0.0f));   // Top Left
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f( 1.0f, 1.0f, 0.0f));   // Top Right
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f( 1.0f,-1.0f, 0.0f));   // Bottom Right
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f(-1.0f,-1.0f, 0.0f));   // Bottom Left
   GLCHK(glEnd());                                                         // Done Drawing The Quad

   /*
   GLCHK(glClear(GL_COLOR_BUFFER_BIT));
   GLCHK(glBegin(GL_TRIANGLES));
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f(1.0f, 0.0f, 0.0f));
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f(0.0f, 1.0f, 0.0f));
      GLCHK(glColor3f(1.0f, 1.0f, 1.0f)); GLCHK(glVertex3f(0.0f, 0.0f, 1.0f));
   GLCHK(glEnd());
   */
   
   glutSwapBuffers();
   glutPostRedisplay();
}

int main(int argc, char* argv[])
{
   glutInit(&argc, argv);
   glutCreateWindow( __FILE__ );
   glutReshapeFunc(reshape);
   glutDisplayFunc(display);
   glutMainLoop();
   return 0;
}

Back to top
View user's profile Send private message
jsgf



Joined: 12 Jul 2005
Posts: 254

PostPosted: Sat Oct 22, 2005 2:24 am    Post subject: Re: PSPGL Quad Implementation Reply with quote

stinkymeat wrote:
I'm having some problems with my code that is a modified version of the glut example for PSPgl. The main problem is that the code for drawing a triangle works, but its counterpart, the square, doesnt seem to work. As you can see from the code below, both are present, with the triangle code commented out. This code works. The quad code doesnt. I get zero compile errors, but the result on the PSP is a black screen :(

Quads aren't implemented. Use a triangle fan, it should just drop in (replace QUADS with TRIANGLE_FAN); obviously it won't work if you want to draw more than one per begin/end.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 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