Click here to Skip to main content
15,902,299 members
Home / Discussions / Graphics
   

Graphics

 
GeneralAlgorithm to divide image into rectangulars of the same color [modified] Pin
xax14-Apr-08 5:37
xax14-Apr-08 5:37 
GeneralRe: Algorithm to divide image into rectangulars of the same color Pin
Luc Pattyn14-Apr-08 5:54
sitebuilderLuc Pattyn14-Apr-08 5:54 
GeneralRe: Algorithm to divide image into rectangulars of the same color Pin
xax15-Apr-08 12:43
xax15-Apr-08 12:43 
GeneralRe: Algorithm to divide image into rectangulars of the same colo Pin
Luc Pattyn15-Apr-08 13:10
sitebuilderLuc Pattyn15-Apr-08 13:10 
GeneralProcessor Intensive Programming [modified] Pin
Reelix14-Apr-08 1:52
Reelix14-Apr-08 1:52 
GeneralRe: Processor Intensive Programming Pin
El Corazon14-Apr-08 4:33
El Corazon14-Apr-08 4:33 
Generalwant suggestion Pin
bharathn8712-Apr-08 8:46
bharathn8712-Apr-08 8:46 
GeneralShading Pin
meister_skypie6-Apr-08 1:13
meister_skypie6-Apr-08 1:13 
Hello..

I have a problem about shading. Actually, I want to apply a phong shading to the 3d object.Here is the code:

#include "Global.h"<br />
 #include "lightComponent.h"<br />
<br />
/*--Read input file-------------------------------------------------*/<br />
<br />
<br />
//--------------------------------------------------------------------------------------------------------------------------<br />
<br />
 void setOrthographicProjection() <br />
 {<br />
     glMatrixMode(GL_PROJECTION);<br />
	 glPushMatrix();<br />
	 glLoadIdentity();<br />
	 gluOrtho2D(0, screen_width, 0, screen_height);<br />
	 glScalef(1, -1, 1);<br />
	 glTranslatef(0, -screen_height, 0);<br />
	 glMatrixMode(GL_MODELVIEW);<br />
 } <br />
<br />
/*------------------------------------------------------------------*/<br />
<br />
 void resetPerspectiveProjection() <br />
 {<br />
	 glMatrixMode(GL_PROJECTION);<br />
	 glPopMatrix();<br />
	 glMatrixMode(GL_MODELVIEW);<br />
 }<br />
<br />
/*------------------------------------------------------------------*/<br />
<br />
 void renderBitmapString(float x, float y, void *font,char *string)<br />
 {<br />
     char *c;<br />
<br />
     glRasterPos2f(x, y);<br />
     for (c=string; *c != '\0'; c++) {<br />
     glutBitmapCharacter(font, *c);<br />
	 }<br />
 }<br />
<br />
/*------------------------------------------------------------------*/<br />
<br />
<br />
 void Myinit(void) <br />
{<br />
	glClearColor (0.0, 0.0, 0.0, 1.0);<br />
	glShadeModel (GL_SMOOTH);<br />
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br />
	<br />
	glMatrixMode(GL_PROJECTION);				<br />
	glLoadIdentity();<br />
	gluPerspective(60,1.0,0.1,100);					<br />
	glMatrixMode(GL_MODELVIEW);<br />
<br />
	// Lighting parameters<br />
<br />
	init_light();<br />
<br />
   	glEnable(GL_LIGHTING);<br />
   	glEnable(GL_LIGHT0);<br />
	glEnable(GL_COLOR_MATERIAL);<br />
	<br />
	glEnable(GL_DEPTH_TEST);<br />
	glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);	//test<br />
}<br />
<br />
/*------------------------------------------------------------------*/<br />
<br />
 void resize (int width, int height)<br />
 {<br />
     screen_width=width; <br />
     screen_height=height; <br />
<br />
     glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); <br />
     glViewport(0,0,screen_width,screen_height); <br />
<br />
     glMatrixMode(GL_PROJECTION); <br />
     glLoadIdentity(); <br />
     gluPerspective(45.0f,(GLfloat)screen_width/(GLfloat)screen_height,1.0f,1000.0f);<br />
<br />
	 glTranslatef(0.0,0.0,-7.0); <br />
 }<br />
<br />
<br />
/*--Display object--------------------------------------------------*/<br />
<br />
 void  display(void)<br />
 {<br />
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); <br />
     glMatrixMode(GL_MODELVIEW); <br />
     glLoadIdentity();<br />
<br />
    <br />
	 if ( data_type == 1 )<br />
	 {<br />
               //display data<br />
	 }<br />
        <br />
	 rotate+=1.5;<br />
<br />
	 glPushMatrix();<br />
	 glColor3f(1.0,1.0,0.0);<br />
	 setOrthographicProjection();<br />
	 glLoadIdentity();<br />
	 renderBitmapString(10,30,(void *)font,"Display Object From File ");<br />
        <br />
   	 resetPerspectiveProjection();<br />
	 glPopMatrix();<br />
	<br />
     glFlush(); <br />
     glutSwapBuffers(); <br />
 }<br />
<br />
/*------------------------------------------------------------------*/<br />
<br />
 void processMenuEvents(int option) <br />
 {<br />
	<br />
 }<br />
<br />
/*------------------------------------------------------------------*/<br />
<br />
 void create_Menu() <br />
 {<br />
	<br />
 }<br />
<br />
/*--Main function---------------------------------------------------*/<br />
<br />
 int main(int argc, char **argv)<br />
 {<br />
     glutInit(&argc, argv);    <br />
     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);<br />
     glutInitWindowSize(screen_width,screen_height);<br />
     glutInitWindowPosition(0,0);<br />
     glutCreateWindow("View Object");<br />
     glutDisplayFunc(display);<br />
     glutIdleFunc(display);<br />
     glutReshapeFunc (resize);<br />
	 create_Menu();<br />
	 Myinit();<br />
     glutMainLoop();<br />
<br />
     return(0);   <br />
	<br />
 }<br />


But, it doesn't work. Can somebody fix my code? Frown | :(
GeneralRe: Shading Pin
Tim Craig6-Apr-08 16:05
Tim Craig6-Apr-08 16:05 
GeneralRe: Shading Pin
El Corazon8-Apr-08 7:20
El Corazon8-Apr-08 7:20 
QuestionPartially redraw Image Pin
invader824-Apr-08 3:31
invader824-Apr-08 3:31 
GeneralRe: Partially redraw Image Pin
Luc Pattyn4-Apr-08 3:41
sitebuilderLuc Pattyn4-Apr-08 3:41 
GeneralRe: Partially redraw Image Pin
invader824-Apr-08 3:50
invader824-Apr-08 3:50 
GeneralGDI+ - Disposing Pin
molcaobarman30-Mar-08 7:14
molcaobarman30-Mar-08 7:14 
GeneralRe: GDI+ - Disposing Pin
Mark Salsbery30-Mar-08 9:40
Mark Salsbery30-Mar-08 9:40 
GeneralRe: GDI+ - Disposing Pin
Luc Pattyn30-Mar-08 10:24
sitebuilderLuc Pattyn30-Mar-08 10:24 
GeneralRe: GDI+ - Disposing Pin
molcaobarman1-Apr-08 21:23
molcaobarman1-Apr-08 21:23 
GeneralRe: GDI+ - Disposing Pin
Luc Pattyn1-Apr-08 23:38
sitebuilderLuc Pattyn1-Apr-08 23:38 
GeneralRe: GDI+ - Disposing Pin
molcaobarman2-Apr-08 0:16
molcaobarman2-Apr-08 0:16 
QuestionSemi Transparent UserControl Pin
maxatlis30-Mar-08 0:04
maxatlis30-Mar-08 0:04 
GeneralRe: Semi Transparent UserControl [modified] Pin
Rob Smiley18-Apr-08 9:48
Rob Smiley18-Apr-08 9:48 
GeneralFlashy GDI+ Pin
Reelix28-Mar-08 0:58
Reelix28-Mar-08 0:58 
GeneralRe: Flashy GDI+ Pin
Christian Graus6-Apr-08 16:30
protectorChristian Graus6-Apr-08 16:30 
QuestionTemplate Matching? Pin
jamilkhan00727-Mar-08 21:45
jamilkhan00727-Mar-08 21:45 
QuestionHighest quality text using TextRender Pin
danreber18-Mar-08 6:16
danreber18-Mar-08 6:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.